-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Create Interfaces for Events
- Loading branch information
1 parent
bd9a63d
commit f6af349
Showing
2 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { | ||
Callback, | ||
Dictionary, | ||
SDKEventAttrs, | ||
SDKEventOptions, | ||
TransactionAttributes, | ||
} from '@mparticle/web-sdk'; | ||
import { | ||
BaseEvent, | ||
SDKEventCustomFlags, | ||
SDKProduct, | ||
SDKProductImpression, | ||
SDKPromotion, | ||
} from './sdkRuntimeModels'; | ||
import { valueof } from './utils'; | ||
import { EventType, ProductActionType, PromotionActionType } from './types'; | ||
|
||
type dataFunction = (element: HTMLElement) => Dictionary<string>; | ||
type dataObject = Dictionary<string>; | ||
|
||
export interface IEvents { | ||
addEventHandler( | ||
domEvent: string, | ||
selector: string | Node, | ||
eventName: string, | ||
|
||
// QUESTION: In what cases would data be a function? | ||
data: dataObject | dataFunction, | ||
|
||
eventType: valueof<typeof EventType> | ||
): void; | ||
logCheckoutEvent( | ||
step: number, | ||
option?: SDKEventOptions, | ||
attrs?: SDKEventAttrs, | ||
customFlags?: SDKEventCustomFlags | ||
); | ||
logEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void; | ||
logImpressionEvent( | ||
impression: SDKProductImpression, | ||
attrs?: SDKEventAttrs, | ||
customFlags?: SDKEventCustomFlags, | ||
eventOptions?: SDKEventOptions | ||
); | ||
logOptOut(): void; | ||
logProductActionEvent( | ||
productActionType: valueof<typeof ProductActionType>, | ||
product: SDKProduct, | ||
attrs?: SDKEventAttrs, | ||
customFlags?: SDKEventCustomFlags, | ||
transactionAttributes?: TransactionAttributes, | ||
eventOptions?: SDKEventOptions | ||
); | ||
logPromotionEvent( | ||
promotionType: valueof<typeof PromotionActionType>, | ||
promotion: SDKPromotion, | ||
attrs?: SDKEventAttrs, | ||
customFlags?: SDKEventCustomFlags, | ||
eventOptions?: SDKEventOptions | ||
); | ||
logPurchaseEvent( | ||
product: SDKProduct, | ||
transactionAttributes?: TransactionAttributes, | ||
attrs?: SDKEventAttrs, | ||
customFlags?: SDKEventCustomFlags | ||
); | ||
logRefundEvent( | ||
transactionAttributes: TransactionAttributes, | ||
product: SDKProduct, | ||
attrs?: SDKEventAttrs, | ||
customFlags?: SDKEventCustomFlags | ||
); | ||
startTracking(callback: Callback): void; | ||
stopTracking(): void; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters