import { IErrorConfig, IPageViewConfig, IUniversalConfig, IGoogleAnalyticsInit, IComponentScrollConfig, ICustomAnalyticsConfig, IThirdPartyCookiesDisabledConfig } from './google-analytics.interfaces'; /** * Proper documentation ;) */ export default class GoogleAnalytics { static initialized: boolean; private instanceInitialized; private lastLocation; private locationPollInterval; private eventCategory; private dataLayer; private gtmId; private gritUniversalGtmId; private formatCss; universalEventBaseConfig: IUniversalConfig; errorEventBaseConfig: IErrorConfig; pageViewEventBaseConfig: IPageViewConfig; componentScrollBaseConfig: IComponentScrollConfig; thirdPartyCookiesDisabledConfig: IThirdPartyCookiesDisabledConfig; static instance: GoogleAnalytics; static getInstance(): GoogleAnalytics; private constructor(); /** * * @param eventCategory Identifier of universal and custom events (ie., 'Retail DB Engagement'). * @param flowType Name you want to call this edition of the platform (ie., 'Retail Dashboard Phase 1'). * @param flowName Name you want to call this edition of the platform (ie., 'Retail Dashboard Phase 1'). * @param version Name you want to call this version of the platform (ie., 'Retail Dashboard'). * @param pageView Object that contains flowType, flowName, and version */ static init({ gtmId, eventCategory, flowType, flowName, version, pageView, logPageViews, }: IGoogleAnalyticsInit): Promise; /** * Set the basic configuration for the app's universal events * @param eventCategory */ private setUniversalEventBaseConfig; /** * Set the basic configuration for the scroll events * @param eventCategory */ private setComponentScrollBaseConfig; /** * Set the basic configuration for the Third Party Cookies Disabled */ private setThirdPartyCookiesDisabledConfig; /** *Set the basic configuration for the app's error events */ private setErrorEventBaseConfig; /** * Set the basic configuration for the apps page view events * @param flowType * @param flowName * @param version * @param logInStatus */ private setPageViewEventBaseConfig; /** * Build a universal event from a label and an action. * @param eventLabel * @param eventAction */ private buildUniversalEvent; /** * Build an error event from a label, an action and a form field name * if it exists. * @param eventAction * @param eventLabel * @param formFieldName */ private buildErrorEvent; /** * Build page view event from a location, url and title. * @param location * @param url * @param title */ private buildPageViewObject; /** * Build scroll event from a eventCategory and eventLabel. * @param eventCategory * @param eventLabel */ private buildScrollEventObject; /** * Build Third Party Cookies Disabled Object */ private buildThirdPartyCookiesDisabledObject; /** * Function to fire when the application's user log in. * @param logInEvent custom object to send after * a user has logged in the application. */ pushLoginEvent(logInEvent: any, logInStatus: boolean): void; /** * Function to check if 3rd party cookies are disabled * @param thirdPartyCookiesDisabled */ pushThirdPartyCookiesDisabled(): void; /** * In case there is need to pass a 100% custom * event into the dataLayer. * @param customEvent any custom object to be pushed */ pushCustomEvent(customEvent: ICustomAnalyticsConfig): void; /** * Build scroll event into the dataLayer. * @param eventCategory * @param eventLabel */ pushScrollEventsToDataLayer(eventCategory: string, eventLabel: string): void; /** * Build a universal event from the Universal configuration and * the event's label and action, and pushes it to the dataLayer. * @param eventLabel * @param eventAction */ pushUniversalEvent({ eventLabel, eventAction, eventNonInteraction, ...rest }: IUniversalConfig): void; /** * Build a formFill event from the Universal configuration and * the event's label and action, and pushes it to the dataLayer. * @param eventLabel * @param eventAction * @param formFillName */ pushFormFillEvent({ eventLabel, fieldName, eventAction }: { eventLabel: any; fieldName: any; eventAction?: string; }): void; /** * Build a error event from the Error configuration and * the event's label and action, and pushes it to the dataLayer. * If the error is from a form field, it takes a formFieldName. * @param eventAction * @param eventLabel * @param formFieldName */ pushErrorEvent({ eventAction, eventLabel, eventNonInteraction, formFieldName, ...rest }: IErrorConfig): void; /** * Build a pageView event from the page view configuration and * the location, url & title and pushes it to the dataLayer. * @param location * @param url * @param title */ pushHistoryEvent(location?: string, url?: string, title?: string): void; /** * Build a pageView event from the page view configuration and * the location, url & title with a overlayId and pushes it to the dataLayer. * @param overlayId */ pushOverlayHistoryEvent(overlayId: string): void; /** * WIP * Initialized a polling to check current location every 50ms, * if currentLocation is different to previously polled location, * then we push a new pageView event to the dataLayer/ * */ initializeHistoryEventLogging(): void; /** * Build a pageView event from the page view configuration and * the location, url & title and pushes it to the dataLayer. * @param location * @param url * @param title * @param logInStatus */ private pushHistoryToDataLayer; /** * Check to see if data layer already exists on the current * window object. If it doesn't appends the GTM script and * no script tags */ appendGtmScriptTag(gtmId?: string): void; /** * Set events for the components * @param components */ setScrollAnalytics(components: HTMLElement[] | HTMLElement, customEvent: any): void; private createEvents; private handleScrollBindComponent; private handleScrollBindWindow; private checkRules; /** * Returns true if browser is Internet Explorer 11 * or older. * @returns */ private isIE; private checkDataEventLength; private logGTMIdError; /** * This sets analytics to a component `host` that has the attributes * analyticsEnabled and analyticsCustomObj. Used with all components * which have analytics usage. * * universalEventCb should return an object with at least eventLabel, * and eventAction. formEventCb should return the same + fieldName * @param {host, universalEventCb, formEventCb} Object */ static setAnalytics({ host, universalEventCb, formEventCb, errorEventCb, }: { host: any; universalEventCb?: () => IUniversalConfig; formEventCb?: () => IUniversalConfig; errorEventCb?: () => IErrorConfig; }): void; }