import type Decimal from 'decimal.js'; import type { BaseEvent, Campaign } from '../Analytics'; import type AnalyticsProviderConfiguration from './types/AnalyticsProviderConfiguration'; export interface Generics extends BaseEvent { eventAction: string; eventCategory: string; } export interface ClickGeneric extends Generics { identifier?: string; name?: string; index?: number; } export interface ContactCall extends Generics { number: string; } export interface ContactEmail extends Generics { to: string; } export interface ImpressionGeneric extends Generics { identifier?: string; name?: string; index?: number; } export interface LocationDirections extends Generics { identifier?: string; address?: string; } export interface SearchGeneric extends Generics { term: string; count?: number; } export interface Query { [key: string]: Query | Query[] | string[] | string | undefined; } /** * @deprecated use `ScreenView` instead (more required options) */ export interface Screenview extends BaseEvent { eventCategory: string; url: string; } export interface ScreenView extends BaseEvent { eventCategory: string; id: string; path: string; data: Record; params: Record; query: Query; url: string; isExact: boolean; title?: string; } export interface Checkout extends Generics { products: TransactionProduct[]; } export interface ImpressionProduct extends Generics { identifier: string; name: string; brand?: string; category?: string; list: string; variant?: string; price?: Decimal | string; index?: number; } export interface Product extends Generics { identifier: string; name: string; brand?: string; category?: string; variant?: string; price?: Decimal | string; quantity?: number; coupons?: string[]; index?: number; } export interface Promotion extends Generics { identifier: string; name: string; creative?: string; slot?: string; } export interface RefundProduct extends BaseEvent { identifier: string; quantity: number; price?: Decimal | string; coupons?: string[]; } export interface TransactionProduct extends BaseEvent { identifier: string; name: string; brand?: string; category?: string; variant?: string; price?: Decimal | string; quantity?: number; coupons?: string[]; index?: number; } export interface Transaction extends Generics { products: TransactionProduct[]; } export interface TransactionRefund extends Generics { products: RefundProduct[]; } export interface ProductAction extends BaseEvent { list?: string; } export interface CheckoutAction extends BaseEvent { step?: number; option?: string; } export interface TransactionAction extends BaseEvent { identifier: string; affiliation?: string; revenue?: string; tax?: string; shippingCost?: string; coupons?: string[]; } export interface App extends BaseEvent { eventAction: string; lifecycle: string; } export default abstract class AnalyticsProvider { constructor(initialConfig: AnalyticsProviderConfiguration); protected userAgent: string; protected osType: string; protected osVersion: string; protected appName: string; protected appId: string; protected appVersion: string; protected appInstallerId?: string; abstract asyncInit(): Promise; abstract clickGeneric(properties: ClickGeneric): void; abstract contactCall(properties: ContactCall): void; abstract contactEmail(properties: ContactEmail): void; abstract impressionGeneric(properties: ImpressionGeneric): void; abstract locationDirections(properties: LocationDirections): void; abstract pageview(properties: ScreenView | Screenview): void; abstract screenview(properties: ScreenView | Screenview): void; abstract searchGeneric(properties: SearchGeneric): void; abstract addProduct(properties: Product): void; abstract checkout(properties: Checkout, action: CheckoutAction): void; abstract checkoutOption(properties: Generics, action: CheckoutAction): void; abstract clickProduct(properties: Product, action?: ProductAction): void; abstract clickPromotion(properties: Promotion): void; abstract impressionProduct(properties: ImpressionProduct): void; abstract impressionPromotion(properties: Promotion): void; abstract detailProduct(properties: Product, action?: ProductAction): void; abstract purchase(properties: Transaction, action: TransactionAction): void; abstract refundAll(properties: Generics, action: TransactionAction): void; abstract refundPartial(properties: TransactionRefund, action: TransactionAction): void; abstract removeProduct(properties: Product): void; abstract lifecycle(properties: App): void; setTrafficSource(properties: Campaign): void; }