import { Component } from 'react'; import type AnalyticsProvider from './providers/AnalyticsProvider'; export declare type BaseEvent = Record & { gaQueryParams?: object; }; export interface ClickGeneric extends BaseEvent { identifier?: string; name?: string; index?: number; } export interface ContactCall extends BaseEvent { number: string; } export interface ContactEmail extends BaseEvent { to: string; } export interface ImpressionGeneric extends BaseEvent { identifier?: string; name?: string; index?: number; } export interface LocationDirections extends BaseEvent { identifier?: string; address?: string; } export interface SearchGeneric extends BaseEvent { 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 { url: string; } export interface ScreenView extends BaseEvent { id: string; path: string; data: Record; params: Record; query: Query; url: string; isExact: boolean; title?: string; } export interface ImpressionProduct extends BaseEvent { identifier: string; name: string; brand?: string; category?: string; list: string; variant?: string; price?: string; index?: number; } export interface Product extends BaseEvent { identifier: string; name: string; brand?: string; category?: string; variant?: string; price?: string; quantity?: number; coupons?: string[]; index?: number; } export interface Promotion extends BaseEvent { identifier: string; name: string; creative?: string; slot?: string; } export interface RefundProduct extends BaseEvent { identifier: string; quantity: number; price?: string; coupons?: string[]; } 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 Campaign { /** * Campaign id; used to identify particular campaign by an external identifier */ id?: string; /** * Campaign source; used to identify a search engine, newsletter, or other source */ source?: string; /** * Campaign medium; used to identify a medium such as email or cost-per-click (cpc) */ medium?: string; /** * Campaign name; used for keyword analysis to identify a specific product promotion or * strategic campaign */ campaign?: string; /** * Campaign term; used with paid search to supply the keywords for ads */ term?: string; /** * Campaign content; used for A/B testing and content-targeted ads to differentiate ads or * links that point to the same URL */ content?: string; } export default class Analytics { constructor(providers: AnalyticsProvider[]); private readonly providers; private readonly clickGeneric; private readonly contactCall; private readonly contactEmail; private readonly impressionGeneric; private readonly locationDirections; private readonly searchGeneric; private readonly impressionPromotion; private readonly impressionProduct; private readonly clickPromotion; private readonly clickProduct; private readonly detailProduct; private readonly addProduct; private readonly removeProduct; private readonly refundPartial; private readonly refundAll; private readonly lifecycleActive; private readonly lifecycleBackground; private readonly lifecycleCreate; private readonly lifecycleClose; private readonly lifecycleInactive; private readonly lifecycleStart; private readonly lifecycleSuspend; private geteventCategoryFromComponent; private triggerTask; private log; readonly add: { product: (component: Component | string, properties: Product) => void; }; readonly click: { generic: (component: Component | string, properties: ClickGeneric) => void; product: (component: Component | string, properties: Product, action?: ProductAction) => void; promotion: (component: Component | string, properties: Promotion) => void; }; readonly contact: { call: (component: Component | string, properties: ContactCall) => void; email: (component: Component | string, properties: ContactEmail) => void; }; readonly detail: { product: (component: Component | string, properties: Product, action?: ProductAction) => void; }; readonly location: { directions: (component: Component | string, properties: LocationDirections) => void; }; readonly refund: { all: (component: Component | string, action: TransactionAction) => void; partial: (component: Component | string, products: RefundProduct[], action: TransactionAction) => void; }; readonly remove: { product: (component: Component | string, properties: Product) => void; }; readonly search: { generic: (component: Component | string, properties: SearchGeneric) => void; }; readonly impression: { generic: (component: Component | string, properties: ImpressionGeneric) => void; product: (component: Component | string, properties: ImpressionProduct) => void; promotion: (component: Component | string, properties: Promotion) => void; }; readonly lifecycle: { active: () => void; background: () => void; close: () => void; create: () => void; inactive: () => void; start: () => void; suspend: () => void; }; screenview(component: Component | string, properties: ScreenView | Screenview): void; checkout(component: Component | string, products: Product[], action: CheckoutAction): void; checkoutOption(component: Component | string, action: CheckoutAction): void; purchase(component: Component | string, products: Product[], action: TransactionAction): void; setTrafficSource(campaignData: Campaign): void; }