Skip to main content

node-tracker.api

API Report File for "@snowplow/node-tracker"

Do not edit this file. It is a report generated by API Extractor.


// @public
export interface AdClickEvent {
advertiserId?: string;
bannerId?: string;
campaignId?: string;
clickId?: string;
cost?: number;
costModel?: "cpa" | "cpc" | "cpm";
impressionId?: string;
targetUrl: string;
zoneId?: string;
}

// @public
export interface AdConversionEvent {
action?: string;
advertiserId?: string;
campaignId?: string;
category?: string;
conversionId?: string;
cost?: number;
costModel?: "cpa" | "cpc" | "cpm";
initialValue?: number;
property?: string;
}

// @public
export interface AddToCartEvent {
category?: string;
currency?: string;
name?: string;
quantity: number;
sku: string;
unitPrice?: number;
}

// @public
export interface AdImpressionEvent {
advertiserId?: string;
bannerId?: string;
campaignId?: string;
cost?: number;
costModel?: "cpa" | "cpc" | "cpm";
impressionId?: string;
targetUrl?: string;
zoneId?: string;
}

// @public
export function buildAdClick(event: AdClickEvent): PayloadBuilder;

// @public
export function buildAdConversion(event: AdConversionEvent): PayloadBuilder;

// @public
export function buildAddToCart(event: AddToCartEvent): PayloadBuilder;

// @public
export function buildAdImpression(event: AdImpressionEvent): PayloadBuilder;

// @public
export function buildConsentGranted(event: ConsentGrantedEvent): EventPayloadAndContext;

// @public
export function buildConsentWithdrawn(event: ConsentWithdrawnEvent): EventPayloadAndContext;

// @public
export function buildEcommerceTransaction(event: EcommerceTransactionEvent): PayloadBuilder;

// @public
export function buildEcommerceTransactionItem(event: EcommerceTransactionItemEvent): PayloadBuilder;

// @public
export function buildFormFocusOrChange(event: FormFocusOrChangeEvent): PayloadBuilder;

// @public
export function buildFormSubmission(event: FormSubmissionEvent): PayloadBuilder;

// @public
export function buildLinkClick(event: LinkClickEvent): PayloadBuilder;

// @public
export function buildPagePing(event: PagePingEvent): PayloadBuilder;

// @public
export function buildPageView(event: PageViewEvent): PayloadBuilder;

// @public
export function buildRemoveFromCart(event: RemoveFromCartEvent): PayloadBuilder;

// @public
export function buildScreenView(event: ScreenViewEvent): PayloadBuilder;

// @public
export function buildSelfDescribingEvent<T = Record<string, unknown>>(event: SelfDescribingEvent<T>): PayloadBuilder;

// @public
export function buildSiteSearch(event: SiteSearchEvent): PayloadBuilder;

// @public
export function buildSocialInteraction(event: SocialInteractionEvent): PayloadBuilder;

// @public
export function buildStructEvent(event: StructuredEvent): PayloadBuilder;

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

// @public
export interface ConsentGrantedEvent {
description?: string;
expiry?: string;
id: string;
name?: string;
version: string;
}

// @public
export interface ConsentWithdrawnEvent {
all: boolean;
description?: string;
id?: string;
name?: string;
version?: string;
}

// @public
export interface ContextEvent {
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
export interface CoreConfiguration {
/* Should payloads be base64 encoded when built */
// (undocumented)
base64?: boolean;
/* A list of all the plugins to include at load */
// (undocumented)
callback?: (PayloadData: PayloadBuilder) => void;
/* A list of all the plugins to include at load */
// (undocumented)
corePlugins?: Array<CorePlugin>;
}

// @public
export interface CorePlugin {
activateCorePlugin?: (core: TrackerCore) => void;
afterTrack?: (payload: Payload) => void;
beforeTrack?: (payloadBuilder: PayloadBuilder) => void;
contexts?: () => SelfDescribingJson[];
filter?: (payload: Payload) => boolean;
logger?: (logger: Logger) => void;
}

// @public
export interface CorePluginConfiguration {
/* The plugin to add */
// (undocumented)
plugin: CorePlugin;
}

// @public (undocumented)
export type CustomEmitter = {
/* Function returning custom Emitter or Emitter[] to be used. If set, other options are irrelevant */
customEmitter: () => Emitter | Array<Emitter>;
};

// @public
export interface DeviceTimestamp {
// (undocumented)
readonly type: "dtm";
// (undocumented)
readonly value: number;
}

// @public
export interface EcommerceTransactionEvent {
affiliation?: string;
city?: string;
country?: string;
currency?: string;
orderId: string;
shipping?: number;
state?: string;
tax?: number;
total: number;
}

// @public
export interface EcommerceTransactionItemEvent {
category?: string;
currency?: string;
name?: string;
orderId: string;
price: number;
quantity?: number;
sku: string;
}

// @public
export interface Emitter {
flush: () => Promise<void>;
input: (payload: Payload) => Promise<void>;
setAnonymousTracking: (anonymous: boolean) => void;
setBufferSize: (bufferSize: number) => void;
setCollectorUrl: (url: string) => void;
}

// @public (undocumented)
export interface EmitterConfiguration extends EmitterConfigurationBase {
/* The collector URL to which events will be sent */
// (undocumented)
endpoint: string;
/* http or https. Defaults to https */
// (undocumented)
port?: number;
/* http or https. Defaults to https */
// (undocumented)
protocol?: "http" | "https";
/* http or https. Defaults to https */
// (undocumented)
serverAnonymization?: boolean;
}

// @public (undocumented)
export interface EmitterConfigurationBase {
bufferSize?: number;
connectionTimeout?: number;
credentials?: "omit" | "same-origin" | "include";
customFetch?: (input: Request, options?: RequestInit) => Promise<Response>;
customHeaders?: Record<string, string>;
dontRetryStatusCodes?: number[];
eventMethod?: EventMethod;
eventStore?: EventStore;
idService?: string;
keepalive?: boolean;
maxGetBytes?: number;
maxPostBytes?: number;
onRequestFailure?: (data: RequestFailure, response?: Response) => void;
onRequestSuccess?: (data: EventBatch, response: Response) => void;
postPath?: string;
retryFailedRequests?: boolean;
retryStatusCodes?: number[];
useStm?: boolean;
}

// @public
export type EventBatch = Payload[];

// @public
export type EventJson = Array<EventJsonWithKeys>;

// @public
export type EventJsonWithKeys = {
keyIfEncoded: string;
keyIfNotEncoded: string;
json: Record<string, unknown>;
};

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

// @public
export interface EventPayloadAndContext {
context: Array<SelfDescribingJson>;
event: PayloadBuilder;
}

// @public
export interface EventStore {
add: (payload: EventStorePayload) => Promise<number>;
count: () => Promise<number>;
getAll: () => Promise<readonly EventStorePayload[]>;
getAllPayloads: () => Promise<readonly Payload[]>;
iterator: () => EventStoreIterator;
removeHead: (count: number) => Promise<void>;
}

// @public (undocumented)
export interface EventStoreConfiguration {
maxSize?: number;
}

// @public
export interface EventStoreIterator {
// Warning: (ae-forgotten-export) The symbol "EventStoreIteratorNextResult" needs to be exported by the entry point index.module.d.ts
next: () => Promise<EventStoreIteratorNextResult>;
}

// @public (undocumented)
export interface EventStorePayload {
payload: Payload;
svrAnon?: boolean;
}

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

// @public
export type FormElement = {
name: string;
value: string | null;
nodeName: string;
type?: string | null;
};

// @public
export interface FormFocusOrChangeEvent {
elementClasses?: Array<string> | null;
elementId: string;
formId: string;
nodeName: string;
schema: "change_form" | "focus_form";
type?: string | null;
value: string | null;
}

// @public
export interface FormSubmissionEvent {
elements?: Array<FormElement>;
formClasses?: Array<string>;
formId: string;
}

// @public
export type JsonProcessor = (payloadBuilder: PayloadBuilder, jsonForProcessing: EventJson, contextEntitiesForProcessing: SelfDescribingJson[]) => void;

// @public
export interface LinkClickEvent {
elementClasses?: Array<string>;
elementContent?: string;
elementId?: string;
elementTarget?: string;
targetUrl: string;
}

// @public (undocumented)
export enum LOG_LEVEL {
// (undocumented)
debug = 3,
// (undocumented)
error = 1,
// (undocumented)
info = 4,
// (undocumented)
none = 0,
// (undocumented)
warn = 2
}

// @public (undocumented)
export interface Logger {
// (undocumented)
debug: (message: string, ...extraParams: unknown[]) => void;
// (undocumented)
error: (message: string, error?: unknown, ...extraParams: unknown[]) => void;
// (undocumented)
info: (message: string, ...extraParams: unknown[]) => void;
// (undocumented)
setLogLevel: (level: LOG_LEVEL) => void;
// (undocumented)
warn: (message: string, error?: unknown, ...extraParams: unknown[]) => void;
}

// @public (undocumented)
export function newTracker(trackerConfiguration: TrackerConfiguration, emitterConfiguration: NodeEmitterConfiguration | NodeEmitterConfiguration[]): Tracker;

// @public (undocumented)
export type NodeEmitterConfiguration = CustomEmitter | EmitterConfiguration;

// @public
export interface PagePingEvent extends PageViewEvent {
maxXOffset?: number;
maxYOffset?: number;
minXOffset?: number;
minYOffset?: number;
}

// @public
export interface PageViewEvent {
pageTitle?: string | null;
pageUrl?: string | null;
referrer?: string | null;
}

// @public
export type Payload = Record<string, unknown>;

// @public
export interface PayloadBuilder {
add: (key: string, value: unknown) => void;
addContextEntity: (entity: SelfDescribingJson) => void;
addDict: (dict: Payload) => void;
addJson: (keyIfEncoded: string, keyIfNotEncoded: string, json: Record<string, unknown>) => void;
build: () => Payload;
getJson: () => EventJson;
getPayload: () => Payload;
withJsonProcessor: (jsonProcessor: JsonProcessor) => void;
}

// @public
export interface RemoveFromCartEvent {
category?: string;
currency?: string;
name?: string;
quantity: number;
sku: string;
unitPrice?: number;
}

// @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 ScreenViewEvent {
id?: string;
name?: string;
}

// @public
export interface SelfDescribingEvent<T = Record<string, unknown>> {
event: SelfDescribingJson<T>;
}

// @public
export type SelfDescribingJson<T = Record<string, unknown>> = {
schema: string;
data: T extends any[] ? never : T extends {} ? T : never;
};

// @public
export interface SiteSearchEvent {
filters?: Record<string, string | boolean>;
pageResults?: number;
terms: Array<string>;
totalResults?: number;
}

// @public
export interface SocialInteractionEvent {
action: string;
network: string;
target?: string;
}

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

// @public
export type Timestamp = TrueTimestamp | DeviceTimestamp | number;

// @public (undocumented)
export interface Tracker extends TrackerCore {
flush: () => Promise<void>;
setDomainUserId: (userId: string) => void;
setNetworkUserId: (userId: string) => void;
setSessionId: (sessionId: string) => void;
setSessionIndex: (sessionIndex: string | number) => void;
}

// @public (undocumented)
export interface TrackerConfiguration {
/* The namespace of the tracker */
// (undocumented)
appId: string;
/* The application ID */
encodeBase64?: boolean;
/* The application ID */
// (undocumented)
namespace: string;
}

// @public
export interface TrackerCore {
addGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive> | Record<string, ConditionalContextProvider | ContextPrimitive>): void;
addPayloadDict(dict: Payload): void;
addPayloadPair: (key: string, value: unknown) => void;
addPlugin(configuration: CorePluginConfiguration): void;
clearGlobalContexts(): void;
getBase64Encoding(): boolean;
removeGlobalContexts(contexts: Array<ConditionalContextProvider | ContextPrimitive | string>): void;
resetPayloadPairs(dict: Payload): void;
setAppId(appId: string): void;
setBase64Encoding(encode: boolean): void;
setColorDepth(depth: string): void;
setIpAddress(ip: string): void;
setLang(lang: string): void;
setPlatform(value: string): void;
setScreenResolution(width: string, height: string): void;
setTimezone(timezone: string): void;
setTrackerNamespace(name: string): void;
setTrackerVersion(version: string): void;
setUseragent(useragent: string): void;
setUserId(userId: string): void;
setViewport(width: string, height: string): void;
track: (pb: PayloadBuilder, context?: Array<SelfDescribingJson> | null, timestamp?: Timestamp | null) => Payload | undefined;
}

// @public
export interface TrueTimestamp {
// (undocumented)
readonly type: "ttm";
// (undocumented)
readonly value: number;
}

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

// (No @packageDocumentation comment for this package)