declare const version: string; declare enum LOG_LEVEL { none = 0, error = 1, warn = 2, debug = 3, info = 4 } interface Logger { setLogLevel: (level: LOG_LEVEL) => void; info: (message: string, ...extraParams: unknown[]) => void; debug: (message: string, ...extraParams: unknown[]) => void; warn: (message: string, error?: unknown, ...extraParams: unknown[]) => void; error: (message: string, error?: unknown, ...extraParams: unknown[]) => void; } declare const LOG: Logger; /** * Interface which defines Core Plugins */ interface CorePlugin { /** * Called when the plugin is initialised during the trackerCore construction * * @remarks * Use to capture the specific core instance for each instance of a core plugin */ activateCorePlugin?: (core: TrackerCore) => void; /** * Called just before the trackerCore callback fires * @param payloadBuilder - The payloadBuilder which will be sent to the callback, can be modified */ beforeTrack?: (payloadBuilder: PayloadBuilder) => void; /** * Called just after the trackerCore callback fires * @param payload - The final built payload */ afterTrack?: (payload: Payload) => void; /** * Called when constructing the context for each event * Useful for adding additional context to events */ contexts?: () => SelfDescribingJson[]; /** * Passed a logger instance which can be used to send log information * to the active logger */ logger?: (logger: Logger) => void; } declare enum nwSchemaAttr { response_body = "rsb", request_body = "rqb", response_headers = "rsh", request_headers = "rqh" } /** * export interface for any Self-Describing JSON such as context or Self Describing events * @typeParam T - The type of the data object within a SelfDescribingJson */ type SelfDescribingJson = Record> = { /** * The schema string * @example 'iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0' */ sc: string; /** * The data object which should conform to the supplied schema */ dt: T; }; /** * export interface for any Self-Describing JSON which has the data attribute as an array * @typeParam T - The type of the data object within the SelfDescribingJson data array */ type SelfDescribingJsonArray = Record> = { /** * The schema string * @example 'iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1' */ sc: string; /** * The data array which should conform to the supplied schema */ dt: Array; }; /** * Algebraic datatype representing possible timestamp type choice */ type Timestamp = TrueTimestamp | DeviceTimestamp | number; /** * A representation of a True Timestamp (ttm) */ interface TrueTimestamp { readonly type: "ttm"; readonly value: number; } /** * A representation of a Device Timestamp (dtm) */ interface DeviceTimestamp { readonly type: "dtm"; readonly value: number; } /** Additional data points to set when tracking an event */ interface CommonEventProperties { /** Add context to an event by setting an Array of Self Describing JSON */ context?: Array | null; /** Set the true timestamp or overwrite the device sent timestamp on an event */ timestamp?: Timestamp | null; } /** * export interface containing all Core functions */ interface TrackerCore { /** * Call with a payload from a buildX function * Adds context and payloadPairs name-value pairs to the payload * Applies the callback to the built payload * * @param pb - Payload * @param context - Custom contexts relating to the event * @param timestamp - Timestamp of the event * @returns Payload after the callback is applied */ track: (/** A PayloadBuilder created by one of the `buildX` functions */ pb: PayloadBuilder, /** The additional contextual information related to the event */ context?: Array | null, /** Timestamp override */ timestamp?: Timestamp | null) => Payload; /** * Set a persistent key-value pair to be added to every payload * * @param key - Field name * @param value - Field value */ addPayloadPair: (key: string, value: string | number) => void; /** * Get current base64 encoding state */ getBase64Encoding(): boolean; /** * Turn base 64 encoding on or off * * @param encode - Whether to encode payload */ setBase64Encoding(encode: boolean): void; /** * Merges a dictionary into payloadPairs * * @param dict - Adds a new payload dictionary to the existing one */ addPayloadDict(dict: Payload): void; /** * Replace payloadPairs with a new dictionary * * @param dict - Resets all current payload pairs with a new dictionary of pairs */ resetPayloadPairs(dict: Payload): void; /** * Set the tracker version * * @param version - The version of the current tracker */ setTrackerVersion(version: string): void; /** * Set the tracker namespace * * @param name - The trackers namespace */ setTrackerNamespace(name: string): void; /** * Set the application ID * * @param appId - An application ID which identifies the current application */ setAppId(appId: string): void; /** * Set the platform * * @param value - A valid Conviva platform value */ setPlatform(value: string): void; /** * Set the user ID * * @param userId - The custom user id */ setUserId(userId: string): void; /** * Set the screen resolution * * @param width - screen resolution width * @param height - screen resolution height */ setScreenResolution(width: string, height: string): void; /** * Set the viewport dimensions * * @param width - viewport width * @param height - viewport height */ setViewport(width: string, height: string): void; /** * Set the color depth * * @param depth - A color depth value as string */ setColorDepth(depth: string): void; /** * Set the timezone * * @param timezone - A timezone string */ setTimezone(timezone: string): void; /** * Set the language * * @param lang - A language string e.g. 'en-UK' */ setLang(lang: string): void; /** * Set the IP address * * @param ip - An IP Address string */ setIpAddress(ip: string): void; /** * Set the Useragent * * @param useragent - A useragent string */ setUseragent(useragent: string): void; /** * Adds contexts globally, contexts added here will be attached to all applicable events * @param contexts - An array containing either contexts or a conditional contexts */ addGlobalContexts(contexts: Array): void; /** * Removes all global contexts */ clearGlobalContexts(): void; /** * Removes previously added global context, performs a deep comparison of the contexts or conditional contexts * @param contexts - An array containing either contexts or a conditional contexts */ removeGlobalContexts(contexts: Array): void; /** * Add a plugin into the plugin collection after Core has already been initialised * @param configuration - The plugin to add */ addPlugin(configuration: CorePluginConfiguration): void; getConfig(): CoreConfiguration; setConfig(config: CoreConfiguration): void; } /** * The configuration object for the tracker core library */ interface CoreConfiguration { cacheRefreshInterval?: number; /* Should payloads be base64 encoded when built */ base64?: boolean; /* A list of all the plugins to include at load */ corePlugins?: Array; /* The callback which will fire each time `track()` is called */ callback?: (PayloadData: PayloadBuilder) => void; /* Conviva specific configuration read from remote server */ lifecycleAutotracking?: boolean; exceptionAutotracking?: boolean; enablePeriodicHeartbeat?: boolean; periodicHeartbeatInterval?: number; enc?: string; maxLocalStorageQueueSize?: number; maxGetBytes?: number; bufferSize?: number; customEventTrackingConfiguration?: any; networkRequestTrackingConfiguration?: any; traceparentconfig?: any; metaTagsTrackingConfiguration?: any; performanceContextConfig?: number; mend?: boolean; configurationVersion?: number; catRcLastUpdatedTs?: number; endpoint?: string; controlIngestConfig?: any; applicationContext?: boolean; emitterConfiguration?: { batching?: { enabled: boolean; byteLimitPostInKB?: number; batchingIntervalInSec?: number; urgentEvents?: string[]; }; }; di?: { en: boolean; lim: number; }; clickcc?: { en: boolean; cssSelectorList?: string; uiMode?: string; block?: any; collect?: any; collectattr?: Array; }; collectionRateLimit?: { exceptionAutotracking?: { maxEvents: number; timeWindow: number; disconnectDuration: number; }; }; } /** * The configuration of the plugin to add */ interface CorePluginConfiguration { /* The plugin to add */ plugin: CorePlugin; } /** * SetCustomTags event object */ interface CustomTags { [key: string]: any; length?: never; } /** * Create a tracker core object * * @param base64 - Whether to base 64 encode contexts and self describing event JSONs * @param corePlugins - The core plugins to be processed with each event * @param callback - Function applied to every payload dictionary object * @returns Tracker core */ declare function trackerCore(configuration?: CoreConfiguration): TrackerCore; /** * A Self Describing Event * A custom event type, allowing for an event to be tracked using your own custom schema * and a data object which conforms to the supplied schema */ interface SelfDescribingEvent { /** The Self Describing JSON which describes the event */ event: SelfDescribingJson; } /** * Build a self-describing event * A custom event type, allowing for an event to be tracked using your own custom schema * and a data object which conforms to the supplied schema * * @param event - Contains the properties and schema location for the event * @returns PayloadBuilder to be sent to {@link @convivainc/tracker-core#TrackerCore.track} */ declare function buildSelfDescribingEvent(event: SelfDescribingEvent): PayloadBuilder; /** * A Page View Event * Represents a Page View, which is typically fired as soon as possible when a web page * is loaded within the users browser. Often also fired on "virtual page views" within * Single Page Applications (SPA). */ interface PageViewEvent { /** The current URL visible in the users browser */ pageUrl?: string | null; /** The current page title in the users browser */ pageTitle?: string | null; /** The URL of the referring page */ referrer?: string | null; } /** * Build a Page View Event * Represents a Page View, which is typically fired as soon as possible when a web page * is loaded within the users browser. Often also fired on "virtual page views" within * Single Page Applications (SPA). * * @param event - Contains the properties for the Page View event * @returns PayloadBuilder to be sent to {@link @convivainc/tracker-core#TrackerCore.track} */ declare function buildPageView(event: PageViewEvent): PayloadBuilder; /** * A Page Ping Event * Fires when activity tracking is enabled in the browser. * Tracks same information as the last tracked Page View and includes scroll * information from the current page view */ interface PagePingEvent extends PageViewEvent { /** The minimum X scroll position for the current page view */ minXOffset?: number; /** The maximum X scroll position for the current page view */ maxXOffset?: number; /** The minimum Y scroll position for the current page view */ minYOffset?: number; /** The maximum Y scroll position for the current page view */ maxYOffset?: number; } /** * Build a Page Ping Event * Fires when activity tracking is enabled in the browser. * Tracks same information as the last tracked Page View and includes scroll * information from the current page view * * @param event - Contains the properties for the Page Ping event * @returns PayloadBuilder to be sent to {@link @convivainc/tracker-core#TrackerCore.track} */ declare function buildPagePing(event: PagePingEvent): PayloadBuilder; /** * A Structured Event * A classic style of event tracking, allows for easier movement between analytics * systems. A loosely typed event, creating a Self Describing event is preferred, but * useful for interoperability. */ interface StructuredEvent { category: string; action: string; label?: string; property?: string; value?: number; } /** * A Custom Event * A classic style of event tracking, allows for easier movement between analytics * systems. A loosely typed event, creating a custom event is preferred, but * useful for interoperability. */ interface CustomEvent { name: string; data: any; } /** * A Network Request event * A classic style of event tracking, allows for easier movement between analytics * systems. A loosely typed event, creating a custom event is preferred, but * useful for interoperability. */ interface NetworkRequestEvent { targetUrl: string; method?: string; contentType?: string; queryParameters?: string; responseStatusCode?: number; responseStatusText?: string; [nwSchemaAttr.request_body]?: any; [nwSchemaAttr.response_body]?: any; [nwSchemaAttr.request_headers]?: any; [nwSchemaAttr.response_headers]?: any; requestTimestamp?: number; responseTimestamp?: number; webResourceTiming?: any; duration?: number; requestSize?: number; responseSize?: number; } /** * Build a Structured Event * A classic style of event tracking, allows for easier movement between analytics * systems. A loosely typed event, creating a Self Describing event is preferred, but * useful for interoperability. * * @param event - Contains the properties for the Structured event * @returns PayloadBuilder to be sent to {@link @convivainc/tracker-core#TrackerCore.track} */ declare function buildStructEvent(event: StructuredEvent): PayloadBuilder; /** * Build a Custom Event * A classic style of event tracking, allows for easier movement between analytics * systems. A loosely typed event, creating a Custom event is preferred, but * useful for interoperability. * * @param event - Contains the properties for the Custom event * @returns PayloadBuilder */ declare function buildCustomEvent(event: CustomEvent): PayloadBuilder; /** * Build a NetworkRequest Event * A classic style of event tracking, allows for easier movement between analytics * systems. A loosely typed event, creating a Custom event is preferred, but * useful for interoperability. * * @param event - Contains the properties for the Custom event * @returns PayloadBuilder */ declare function buildNetworkRequestEvent(event: NetworkRequestEvent): PayloadBuilder; /** * Build a Conviva Video Event * A classic style of event tracking, allows for easier movement between analytics * systems. A loosely typed event, creating a Custom Conviva Video event is preferred, but * useful for interoperability. * * @param event - Contains the properties for the Custom event * @returns PayloadBuilder */ declare function buildConvivaVideoEvent(event: any): PayloadBuilder; /** * A Link Click Event * Used when a user clicks on a link on a webpage, typically an anchor tag */ interface LinkClickEvent { /** The target URL of the link */ targetUrl: string; /** The ID of the element clicked if present */ elementId?: string; /** An array of class names from the element clicked */ elementClasses?: Array; /** The target value of the element if present */ elementTarget?: string; /** The content of the element if present and enabled */ elementContent?: string; } /** * A Button Click Event * Used when a user clicks on a button on a webpage, typically a button tag