snowplow/snowplow-javascript-tracker

View on GitHub
api-docs/docs/browser-tracker/browser-tracker.api.md

Summary

Maintainability
Test Coverage
## API Report File for "@snowplow/browser-tracker"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// @public
export type ActivityCallback = (data: ActivityCallbackData) => void;

// @public
export type ActivityCallbackData = {
    context: Array<SelfDescribingJson>;
    pageViewId: string;
    minXOffset: number;
    minYOffset: number;
    maxXOffset: number;
    maxYOffset: number;
};

// @public
export interface ActivityTrackingConfiguration {
    heartbeatDelay: number;
    minimumVisitLength: number;
}

// @public
export interface ActivityTrackingConfigurationCallback {
    callback: ActivityCallback;
}

// @public
export function addGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive>, trackers?: Array<string>): void;

// @public
export function addPlugin(configuration: BrowserPluginConfiguration, trackers?: Array<string>): void;

// @public (undocumented)
export type AnonymousTrackingOptions = boolean | {
    withSessionTracking?: boolean;
    withServerAnonymisation?: boolean;
};

// Warning: (ae-forgotten-export) The symbol "CorePlugin" needs to be exported by the entry point index.module.d.ts
//
// @public
export interface BrowserPlugin extends CorePlugin {
    activateBrowserPlugin?: (tracker: BrowserTracker) => void;
}

// Warning: (ae-forgotten-export) The symbol "CorePluginConfiguration" needs to be exported by the entry point index.module.d.ts
//
// @public
export interface BrowserPluginConfiguration extends CorePluginConfiguration {
    /* The plugin to add */
    // (undocumented)
    plugin: BrowserPlugin;
}

// @public
export interface BrowserTracker {
    addPlugin: (configuration: BrowserPluginConfiguration) => void;
    clearUserData: (configuration?: ClearUserDataConfiguration) => void;
    // Warning: (ae-forgotten-export) The symbol "TrackerCore" needs to be exported by the entry point index.module.d.ts
    core: TrackerCore;
    crossDomainLinker: (crossDomainLinkerCriterion: (elt: HTMLAnchorElement | HTMLAreaElement) => boolean) => void;
    disableActivityTracking: () => void;
    disableActivityTrackingCallback: () => void;
    disableAnonymousTracking: (configuration?: DisableAnonymousTrackingConfiguration) => void;
    discardBrace: (enableFilter: boolean) => void;
    discardHashTag: (enableFilter: boolean) => void;
    enableActivityTracking: (configuration: ActivityTrackingConfiguration) => void;
    enableActivityTrackingCallback: (configuration: ActivityTrackingConfiguration & ActivityTrackingConfigurationCallback) => void;
    enableAnonymousTracking: (configuration?: EnableAnonymousTrackingConfiguration) => void;
    flushBuffer: (configuration?: FlushBufferConfiguration) => void;
    getCookieName: (basename: string) => string;
    getDomainSessionIndex: () => number;
    getDomainUserId: () => string;
    getDomainUserInfo: () => ParsedIdCookie;
    getPageViewId: () => string;
    getTabId: () => string | null;
    getUserId: () => string | null | undefined;
    id: string;
    namespace: string;
    newSession: () => void;
    preservePageViewId: () => void;
    setBufferSize: (newBufferSize: number) => void;
    setCollectorUrl: (collectorUrl: string) => void;
    setCookiePath: (path: string) => void;
    setCustomUrl: (url: string) => void;
    setDocumentTitle: (title: string) => void;
    setOptOutCookie: (name?: string | null) => void;
    setReferrerUrl: (url: string) => void;
    setUserId: (userId?: string | null) => void;
    setUserIdFromCookie: (cookieName: string) => void;
    setUserIdFromLocation: (querystringField: string) => void;
    setUserIdFromReferrer: (querystringField: string) => void;
    setVisitorCookieTimeout: (timeout: number) => void;
    // Warning: (ae-forgotten-export) The symbol "SharedState" needs to be exported by the entry point index.module.d.ts
    sharedState: SharedState;
    trackPageView: (event?: PageViewEvent & CommonEventProperties) => void;
    updatePageActivity: () => void;
}

// Warning: (ae-forgotten-export) The symbol "RequireAtLeastOne" needs to be exported by the entry point index.module.d.ts
//
// @public (undocumented)
export type BuiltInContexts = RequireAtLeastOne<{
    /* Toggles the web_page context */
    webPage: boolean;
    /* Toggles the session context */
    session: boolean;
    /* Toggles the browser context */
    browser: boolean;
}> | Record<string, never>;

// @public
export function clearGlobalContexts(trackers?: Array<string>): void;

// @public
export function clearUserData(configuration?: ClearUserDataConfiguration, trackers?: Array<string>): void;

// @public
export interface ClearUserDataConfiguration {
    /* Store session information in memory for subsequent events */
    // (undocumented)
    preserveSession: boolean;
    /* Store user information in memory for subsequent events */
    // (undocumented)
    preserveUser: boolean;
}

// @public
export interface ClientSession extends Record<string, unknown> {
    eventIndex: number;
    firstEventId: string | null;
    firstEventTimestamp: string | null;
    previousSessionId: string | null;
    sessionId: string;
    sessionIndex: number;
    storageMechanism: string;
    userId: string;
}

// @public
export interface CommonEventProperties<T = Record<string, unknown>> {
    context?: Array<SelfDescribingJson<T>> | null;
    // Warning: (ae-forgotten-export) The symbol "Timestamp" needs to be exported by the entry point index.module.d.ts
    timestamp?: Timestamp | null;
}

// @public
export type ConditionalContextProvider = FilterProvider | RuleSetProvider;

// @public
export interface ContextEvent {
    // Warning: (ae-forgotten-export) The symbol "Payload" needs to be exported by the entry point index.module.d.ts
    event: Payload;
    eventSchema: string;
    eventType: string;
}

// @public
export type ContextFilter = (args?: ContextEvent) => boolean;

// @public
export type ContextGenerator = (args?: ContextEvent) => SelfDescribingJson | SelfDescribingJson[] | undefined;

// @public
export type ContextPrimitive = SelfDescribingJson | ContextGenerator;

// @public (undocumented)
export type CookieSameSite = "None" | "Lax" | "Strict";

// @public
export function crossDomainLinker(crossDomainLinkerCriterion: (elt: HTMLAnchorElement | HTMLAreaElement) => boolean, trackers?: Array<string>): void;

// @public
export function disableActivityTracking(trackers?: Array<string>): void;

// @public
export function disableActivityTrackingCallback(trackers?: Array<string>): void;

// @public
export function disableAnonymousTracking(configuration?: DisableAnonymousTrackingConfiguration, trackers?: Array<string>): void;

// @public
export interface DisableAnonymousTrackingConfiguration {
    /* Available configurations for different storage strategies */
    // (undocumented)
    stateStorageStrategy?: StateStorageStrategy;
}

// @public
export function discardBrace(enable: boolean, trackers?: Array<string>): void;

// @public
export function discardHashTag(enable: boolean, trackers?: Array<string>): void;

// @public
export function enableActivityTracking(configuration: ActivityTrackingConfiguration, trackers?: Array<string>): void;

// @public
export function enableActivityTrackingCallback(configuration: ActivityTrackingConfiguration & ActivityTrackingConfigurationCallback, trackers?: Array<string>): void;

// @public
export function enableAnonymousTracking(configuration?: EnableAnonymousTrackingConfiguration, trackers?: Array<string>): void;

// @public
export interface EnableAnonymousTrackingConfiguration {
    /* Configuration for Anonymous Tracking */
    // (undocumented)
    options?: AnonymousTrackingOptions;
    /* Available configurations for different storage strategies */
    // (undocumented)
    stateStorageStrategy?: StateStorageStrategy;
}

// @public
export type EventBatch = GetBatch | PostBatch;

// @public (undocumented)
export type EventMethod = "post" | "get" | "beacon";

// @public (undocumented)
export type ExtendedCrossDomainLinkerAttributes = {
    userId?: boolean;
    sessionId?: boolean;
    sourceId?: boolean;
    sourcePlatform?: boolean;
    reason?: boolean | ((evt: Event) => string);
};

// @public (undocumented)
export type ExtendedCrossDomainLinkerOptions = boolean | ExtendedCrossDomainLinkerAttributes;

// @public
export type FilterProvider = [
ContextFilter,
Array<ContextPrimitive> | ContextPrimitive
];

// @public
export function flushBuffer(configuration?: FlushBufferConfiguration, trackers?: Array<string>): void;

// @public
export interface FlushBufferConfiguration {
    /* The size of the buffer after this flush */
    // (undocumented)
    newBufferSize?: number;
}

// @public
export type GetBatch = string[];

// @public
export function newSession(trackers?: Array<string>): void;

// @public
export function newTracker(trackerId: string, endpoint: string): BrowserTracker;

// @public
export function newTracker(trackerId: string, endpoint: string, configuration: TrackerConfiguration): BrowserTracker;

// @public
export interface PageViewEvent {
    contextCallback?: (() => Array<SelfDescribingJson>) | null;
    title?: string | null;
}

// @public
export type ParsedIdCookie = [
cookieDisabled: string,
domainUserId: string,
cookieCreateTs: number,
visitCount: number,
nowTs: number,
lastVisitTs: number | undefined,
sessionId: string,
previousSessionId: string,
firstEventId: string,
firstEventTs: number | undefined,
eventIndex: number
];

// @public (undocumented)
export type Platform = "web" | "mob" | "pc" | "srv" | "app" | "tv" | "cnsl" | "iot";

// @public
export type PostBatch = Record<string, unknown>[];

// @public
export function preservePageViewId(trackers?: Array<string>): void;

// @public
export function removeGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive>, trackers?: Array<string>): void;

// @public
export type RequestFailure = {
    events: EventBatch;
    status?: number;
    message?: string;
    willRetry: boolean;
};

// @public
export interface RuleSet {
    // (undocumented)
    accept?: Array<string> | string;
    // (undocumented)
    reject?: Array<string> | string;
}

// @public
export type RuleSetProvider = [
RuleSet,
Array<ContextPrimitive> | ContextPrimitive
];

// @public
export interface SelfDescribingEvent {
    event: SelfDescribingJson;
}

// @public
export type SelfDescribingJson<T extends Record<keyof T, unknown> = Record<string, unknown>> = {
    schema: string;
    data: T;
};

// @public
export function setBufferSize(newBufferSize: number, trackers?: Array<string>): void;

// @public
export function setCollectorUrl(collectorUrl: string, trackers?: Array<string>): void;

// @public
export function setCookiePath(path: string, trackers?: Array<string>): void;

// @public
export function setCustomUrl(url: string, trackers?: Array<string>): void;

// @public
export function setDocumentTitle(title: string, trackers?: Array<string>): void;

// @public
export function setOptOutCookie(name?: string | null, trackers?: Array<string>): void;

// @public
export function setReferrerUrl(url: string, trackers?: Array<string>): void;

// @public
export function setUserId(userId?: string | null, trackers?: Array<string>): void;

// @public
export function setUserIdFromCookie(cookieName: string, trackers?: Array<string>): void;

// @public
export function setUserIdFromLocation(querystringField: string, trackers?: Array<string>): void;

// @public
export function setUserIdFromReferrer(querystringField: string, trackers?: Array<string>): void;

// @public
export function setVisitorCookieTimeout(timeout: number, trackers?: Array<string>): void;

// @public (undocumented)
export type StateStorageStrategy = "cookieAndLocalStorage" | "cookie" | "localStorage" | "none";

// @public
export interface StructuredEvent {
    // (undocumented)
    action: string;
    // (undocumented)
    category: string;
    // (undocumented)
    label?: string;
    // (undocumented)
    property?: string;
    // (undocumented)
    value?: number;
}

// @public
export type TrackerConfiguration = {
    encodeBase64?: boolean;
    cookieDomain?: string;
    cookieName?: string;
    cookieSameSite?: CookieSameSite;
    cookieSecure?: boolean;
    cookieLifetime?: number;
    withCredentials?: boolean;
    sessionCookieTimeout?: number;
    appId?: string;
    platform?: Platform;
    respectDoNotTrack?: boolean;
    eventMethod?: EventMethod;
    postPath?: string;
    useStm?: boolean;
    bufferSize?: number;
    crossDomainLinker?: (elt: HTMLAnchorElement | HTMLAreaElement) => boolean;
    useExtendedCrossDomainLinker?: ExtendedCrossDomainLinkerOptions;
    maxPostBytes?: number;
    maxGetBytes?: number;
    discoverRootDomain?: boolean;
    stateStorageStrategy?: StateStorageStrategy;
    maxLocalStorageQueueSize?: number;
    resetActivityTrackingOnPageView?: boolean;
    connectionTimeout?: number;
    anonymousTracking?: AnonymousTrackingOptions;
    contexts?: BuiltInContexts;
    plugins?: Array<BrowserPlugin>;
    customHeaders?: Record<string, string>;
    retryStatusCodes?: number[];
    dontRetryStatusCodes?: number[];
    onSessionUpdateCallback?: (updatedSession: ClientSession) => void;
    idService?: string;
    retryFailedRequests?: boolean;
    onRequestSuccess?: (data: EventBatch) => void;
    onRequestFailure?: (data: RequestFailure) => void;
};

// @public
export function trackPageView(event?: PageViewEvent & CommonEventProperties, trackers?: Array<string>): void;

// @public
export function trackSelfDescribingEvent(event: SelfDescribingEvent & CommonEventProperties, trackers?: Array<string>): void;

// @public
export function trackStructEvent(event: StructuredEvent & CommonEventProperties, trackers?: Array<string>): void;

// @public
export function updatePageActivity(trackers?: Array<string>): void;

// @public (undocumented)
export const version: string;

// (No @packageDocumentation comment for this package)

```