UNPKG

@aftership/web-pixels

Version:

AfterShip Web Pixels for data anaylsis

417 lines (388 loc) 13.2 kB
export declare enum AvoEnv { Prod = "prod", Dev = "dev" } export interface CustomDestination { make?(env: AvoEnv, apiKey: string): void; logEvent?: (eventName: string, eventProperties: Record<string, any>) => void; setUserProperties?: (userId: string, userProperties: Record<string, any>) => void; identify?: (userId: string) => void; unidentify?: () => void; logPage?: (pageName: string, eventProperties: Record<string, any>) => void; revenue?: (amount: number, eventProperties: Record<string, any>) => void; setGroupProperties?: (groupType: string, groupId: string, groupProperties: Record<string, any>) => void; addCurrentUserToGroup?: (groupType: string, groupId: string, groupProperties: Record<string, any>) => void; logEventWithGroups?: (eventName: string, eventProperties: any, groupTypesToGroupIds: Record<string, string>) => void; } export declare const avoInspectorApiKey = "iBpUdao4JDjN3qloDbHw"; interface AvoInspector { } interface AvoLogger { logDebug(env: AvoEnv | null, message: string): boolean; logWarn(env: AvoEnv | null, message: string): boolean; logError(env: AvoEnv | null, error: string): boolean; } declare enum webDebuggerArea { BottomRight = "BottomRight", BottomLeft = "BottomLeft", TopRight = "TopRight", TopLeft = "TopLeft" } interface bottomRightParameters { bottom: number; right: number; } interface bottomLeftParameters { bottom: number; left: number; } interface topRightParameters { top: number; right: number; } interface topLeftParameters { top: number; left: number; } interface webDebuggerPosition { position: webDebuggerArea; top?: number; right?: number; bottom?: number; left?: number; } interface webDebuggerOptions { position?: webDebuggerPosition; } interface WebDebuggerPositionSetter { BottomRight(p: bottomRightParameters): webDebuggerPosition; BottomLeft(p: bottomLeftParameters): webDebuggerPosition; TopRight(p: topRightParameters): webDebuggerPosition; TopLeft(p: topLeftParameters): webDebuggerPosition; } export declare const WebDebuggerPosition: WebDebuggerPositionSetter; export interface FormProperty { formId: string; formName: string; succeed: boolean; } export interface Items { productId: string; productTitle: string; variantId: string; variantTitle: string; variantBrand: string; variantListId: string; variantCategory: string; variantCategory2: string; variantCategory3: string; variantCategory4: string; variantCategory5: string; variantListTitle: string; coupon: string; discount: number; index: number; unitPrices: UnitPrices[]; quantity: number; } export interface PageObject { pageTitle: string; pageLocation: string; pageReferrer: string; } export interface UnitPrices { currency: string; amount: number; } export interface PromotionProperty { promotionId: string; promotionAssetName: string; promotionSceneName: string; appName: string; } export declare function setSystemProperties(properties: { pixelId: string; env: string; }): void; export declare function initAvo(options: { env: AvoEnv; webDebugger?: boolean; webDebuggerOptions?: webDebuggerOptions; strict?: boolean; noop?: boolean; reportFailureAs?: 'error' | 'warn' | 'log'; inspector?: AvoInspector; avoLogger?: AvoLogger; }, systemProperties: { pixelId: string; env: string; }, destinationOptions: any, PixelEndpointDestination: CustomDestination): void; export declare function setAvoLogger(avoLogger: AvoLogger | null): void; export interface ClickedProperties { linkUrl: string; label: string; pageObject?: PageObject; } /** * $clicked: each time a user clicks a link that leads away from the current domain * * @param properties the properties associatied with this event * @param properties.linkUrl: The full URL for an outbound link or file download. , should match regex: ^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([\/\w .-]*)*\/?$ * @param properties.label: The button label * @param properties.pageObject: The property group of page * * */ export declare function clicked(properties: ClickedProperties): void; export interface PageViewedProperties { pageObject?: PageObject; } /** * $page_viewed: each time the page loads or the browser history state is changed by the active site * * @param properties the properties associatied with this event * @param properties.pageObject: The property group of page * * */ export declare function pageViewed(properties: PageViewedProperties): void; export interface ModalViewedProperties { modalName: string; pageObject?: PageObject; } /** * $modal_viewed: when a modal transition occurs * * @param properties the properties associatied with this event * @param properties.modalName: The full name of modal * @param properties.pageObject: The property group of page * * */ export declare function modalViewed(properties: ModalViewedProperties): void; export interface SubmittedProperties { formProperty: FormProperty; pageObject?: PageObject; } /** * $submitted: when the user submits a form * * @param properties the properties associatied with this event * @param properties.formProperty: The property group of from * @param properties.pageObject: The property group of page * * */ export declare function submitted(properties: SubmittedProperties): void; export interface PurchaseCompletedProperties { items: Items[]; currency: string; totalAmount: number; orderId: string; pageObject?: PageObject; } /** * $purchase_completed: To report an event when a customer completes a purchase. * * @param properties the properties associatied with this event * @param properties.items: The property group of items * @param properties.currency: Currency code for the amount, adhering to the ISO 4217 standard. * @param properties.totalAmount: The total value of the viewed products. * @param properties.orderId: The unique identifier of the order. * @param properties.pageObject: The property group of page * * */ export declare function purchaseCompleted(properties: PurchaseCompletedProperties): void; export interface RefundCompletedProperties { items: Items[]; currency: string; totalAmount: number; orderId: string; pageObject?: PageObject; } /** * $refund_completed: To report an event when an order refund is completed. * * @param properties the properties associatied with this event * @param properties.items: The property group of items * @param properties.currency: Currency code for the amount, adhering to the ISO 4217 standard. * @param properties.totalAmount: The total value of the viewed products. * @param properties.orderId: The unique identifier of the order. * @param properties.pageObject: The property group of page * * */ export declare function refundCompleted(properties: RefundCompletedProperties): void; export interface SearchSubmittedProperties { searchTerm: string; pageObject?: PageObject; } /** * $search_submitted: To report an event when a visitor submits a search query. * * @param properties the properties associatied with this event * @param properties.searchTerm: The term used in the search query. * @param properties.pageObject: The property group of page * * */ export declare function searchSubmitted(properties: SearchSubmittedProperties): void; export interface ItemViewedProperties { items: Items[]; pageObject?: PageObject; } /** * $item_viewed: To report an event when a customer views a product. * * @param properties the properties associatied with this event * @param properties.items: The property group of items * @param properties.pageObject: The property group of page * * */ export declare function itemViewed(properties: ItemViewedProperties): void; export interface ItemClickedProperties { items: Items[]; pageObject?: PageObject; } /** * $item_clicked: To report an event when a customer clicks a product. * * @param properties the properties associatied with this event * @param properties.items: The property group of items * @param properties.pageObject: The property group of page * * */ export declare function itemClicked(properties: ItemClickedProperties): void; export interface AddedToCartProperties { items: Items[]; totalAmount: number; currency: string; pageObject?: PageObject; } /** * $added_to_cart: To report an event when items are added to the shopping cart. * * @param properties the properties associatied with this event * @param properties.items: The property group of items * @param properties.totalAmount: The total value of the viewed products. * @param properties.currency: Currency code for the amount, adhering to the ISO 4217 standard. * @param properties.pageObject: The property group of page * * */ export declare function addedToCart(properties: AddedToCartProperties): void; export interface CheckoutStartedProperties { items: Items[]; currency: string; totalAmount: number; pageObject?: PageObject; } /** * $checkout_started: To report an event when a customer begins the checkout process * * @param properties the properties associatied with this event * @param properties.items: The property group of items * @param properties.currency: Currency code for the amount, adhering to the ISO 4217 standard. * @param properties.totalAmount: The total value of the viewed products. * @param properties.pageObject: The property group of page * * */ export declare function checkoutStarted(properties: CheckoutStartedProperties): void; export interface CartViewedProperties { items: Items[]; totalAmount: number; currency: string; pageObject?: PageObject; } /** * $cart_viewed: To report an event when a customer views their shopping cart. * * @param properties the properties associatied with this event * @param properties.items: The property group of items * @param properties.totalAmount: The total value of the viewed products. * @param properties.currency: Currency code for the amount, adhering to the ISO 4217 standard. * @param properties.pageObject: The property group of page * * */ export declare function cartViewed(properties: CartViewedProperties): void; export interface PromotionViewedProperties { promotionProperty: PromotionProperty; pageObject?: PageObject; } /** * $promotion_viewed: To report an event when a customer views a promotional event. * * @param properties the properties associatied with this event * @param properties.promotionProperty: The property group of promotion * @param properties.pageObject: The property group of page * * */ export declare function promotionViewed(properties: PromotionViewedProperties): void; export interface PromotionEngagedProperties { promotionProperty: PromotionProperty; engageMethod: string; pageObject?: PageObject; } /** * $promotion_engaged: To report an event when a customer engages with a promotional event. * * @param properties the properties associatied with this event * @param properties.promotionProperty: The property group of promotion * @param properties.engageMethod: Describe how the user interacts with the promotion * @param properties.pageObject: The property group of page * * */ export declare function promotionEngaged(properties: PromotionEngagedProperties): void; export interface IdentifyProperties { userId_: string; } /** * $identify: Linking events to specific users enables you to build a full picture of how they're using your product across different sessions, devices, and platforms. * * @param properties the properties associatied with this event * @param properties.userId_: The value used to identify the user. Make sure it's a unique sequence of characters used to identify the user. * * */ export declare function identify(properties: IdentifyProperties): void; /** * $reset_identity: Clear the current user id identifier * * When to trigger this event: * 1. Logout * View in Avo: https://www.avo.app/schemas/tLvqZe7vIUgYITePLioH/branches/GFfmqbtbQNglVaRZXsm9I/events/Z2vxGg_8CFxBiCVM0WWXe/trigger/u5npcbBrLoFGcNHPHqPMW * * */ export declare function resetIdentity(): void; declare const _default: { AvoEnv: typeof AvoEnv; initAvo: typeof initAvo; setSystemProperties: typeof setSystemProperties; avoInspectorApiKey: string; clicked: typeof clicked; pageViewed: typeof pageViewed; modalViewed: typeof modalViewed; submitted: typeof submitted; purchaseCompleted: typeof purchaseCompleted; refundCompleted: typeof refundCompleted; searchSubmitted: typeof searchSubmitted; itemViewed: typeof itemViewed; itemClicked: typeof itemClicked; addedToCart: typeof addedToCart; checkoutStarted: typeof checkoutStarted; cartViewed: typeof cartViewed; promotionViewed: typeof promotionViewed; promotionEngaged: typeof promotionEngaged; identify: typeof identify; resetIdentity: typeof resetIdentity; }; export default _default;