This repository was archived by the owner on Oct 21, 2024. It is now read-only.
forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.d.ts
More file actions
131 lines (126 loc) · 10.7 KB
/
Copy pathmain.d.ts
File metadata and controls
131 lines (126 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
declare module 'snowplow-tracker/lib/base64' {
export function base64urldecode(data: string): string;
export function base64encode(data: string): string;
export function base64decode(encodedData: string): string;
}
declare module 'snowplow-tracker/lib/payload' {
export interface PayloadData {
add: (key: string, value?: string) => void;
addDict: (dict: Object) => void;
addJson: (keyIfEncoded: string, keyIfNotEncoded: string, json: Object) => void;
build: () => Object;
}
export function isNonEmptyJson(property: any): boolean;
export function isJson(property: Object): boolean;
export function payloadBuilder(base64Encode: boolean): PayloadData;
}
declare module 'snowplow-tracker/lib/contexts' {
import { PayloadData } from 'snowplow-tracker/lib/payload';
import { SelfDescribingJson } from 'snowplow-tracker/lib/core';
export type ContextGenerator = (args?: Object) => SelfDescribingJson;
export type ContextPrimitive = SelfDescribingJson | ContextGenerator;
export type ContextFilter = (args?: Object) => boolean;
export type FilterProvider = [ContextFilter, Array<ContextPrimitive> | ContextPrimitive];
export interface RuleSet {
accept?: string[] | string;
reject?: string[] | string;
}
export type RuleSetProvider = [RuleSet, Array<ContextPrimitive> | ContextPrimitive];
export type ConditionalContextProvider = FilterProvider | RuleSetProvider;
export function getSchemaParts(input: string): Array<string> | undefined;
export function validateVendorParts(parts: Array<string>): boolean;
export function validateVendor(input: string): boolean;
export function getRuleParts(input: string): Array<string> | undefined;
export function isValidRule(input: any): boolean;
export function isStringArray(input: any): boolean;
export function isValidRuleSetArg(input: any): boolean;
export function isSelfDescribingJson(input: any): boolean;
export function isEventJson(input: any): boolean;
export function isRuleSet(input: any): boolean;
export function isContextGenerator(input: any): boolean;
export function isContextFilter(input: any): boolean;
export function isContextPrimitive(input: any): boolean;
export function isFilterProvider(input: any): boolean;
export function isRuleSetProvider(input: any): boolean;
export function isConditionalContextProvider(input: any): boolean;
export function matchSchemaAgainstRule(rule: string, schema: string): boolean;
export function matchVendor(rule: string, vendor: string): boolean;
export function matchPart(rule: string, schema: string): boolean;
export function matchSchemaAgainstRuleSet(ruleSet: RuleSet, schema: string): boolean;
export function getUsefulSchema(sb: SelfDescribingJson): string;
export function getDecodedEvent(sb: SelfDescribingJson): SelfDescribingJson;
export function getEventType(sb: {}): string;
export function buildGenerator(generator: ContextGenerator, event: SelfDescribingJson, eventType: string, eventSchema: string): SelfDescribingJson | Array<SelfDescribingJson> | undefined;
export function normalizeToArray(input: any): Array<any>;
export function generatePrimitives(contextPrimitives: Array<ContextPrimitive> | ContextPrimitive, event: SelfDescribingJson, eventType: string, eventSchema: string): Array<SelfDescribingJson>;
export function evaluatePrimitive(contextPrimitive: ContextPrimitive, event: SelfDescribingJson, eventType: string, eventSchema: string): Array<SelfDescribingJson> | undefined;
export function evaluateProvider(provider: ConditionalContextProvider, event: SelfDescribingJson, eventType: string, eventSchema: string): Array<SelfDescribingJson>;
export function generateConditionals(providers: Array<ConditionalContextProvider> | ConditionalContextProvider, event: SelfDescribingJson, eventType: string, eventSchema: string): Array<SelfDescribingJson>;
export function contextModule(): {
getGlobalPrimitives: () => ContextPrimitive[];
getConditionalProviders: () => ConditionalContextProvider[];
addGlobalContexts: (contexts: any[]) => void;
clearGlobalContexts: () => void;
removeGlobalContexts: (contexts: any[]) => void;
getApplicableContexts: (event: PayloadData) => SelfDescribingJson[];
};
}
declare module 'snowplow-tracker/lib/core' {
import * as payload from 'snowplow-tracker/lib/payload';
export interface SelfDescribingJson extends Object {
schema: string;
data: Object;
}
export type Timestamp = TrueTimestamp | DeviceTimestamp | number;
export interface TrueTimestamp {
readonly type: "ttm";
readonly value: number;
}
export interface DeviceTimestamp {
readonly type: "dtm";
readonly value: number;
}
export function trackerCore(base64: boolean, callback?: (PayloadData) => void): {
setBase64Encoding: (encode: boolean) => void;
addPayloadPair: (key: string, value: string) => void;
addPayloadDict: (dict: Object) => void;
resetPayloadPairs: (dict: Object) => void;
setTrackerVersion: (version: string) => void;
setTrackerNamespace: (name: string) => void;
setAppId: (appId: string) => void;
setPlatform: (value: string) => void;
setUserId: (userId: string) => void;
setScreenResolution: (width: string, height: string) => void;
setViewport: (width: string, height: string) => void;
setColorDepth: (depth: string) => void;
setTimezone: (timezone: string) => void;
setLang: (lang: string) => void;
setIpAddress: (ip: string) => void;
trackUnstructEvent: (properties: Object, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackSelfDescribingEvent: (properties: Object, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackPageView: (pageUrl: string, pageTitle: string, referrer: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackPagePing: (pageUrl: string, pageTitle: string, referrer: string, minXOffset: number, maxXOffset: number, minYOffset: number, maxYOffset: number, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackStructEvent: (category: string, action: string, label: string, property: string, value?: number | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackEcommerceTransaction: (orderId: string, affiliation: string, totalValue: string, taxValue?: string | undefined, shipping?: string | undefined, city?: string | undefined, state?: string | undefined, country?: string | undefined, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackEcommerceTransactionItem: (orderId: string, sku: string, name: string, category: string, price: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackScreenView: (name: string, id: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackLinkClick: (targetUrl: string, elementId: string, elementClasses: string[], elementTarget: string, elementContent: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackAdImpression: (impressionId: string, costModel: string, cost: number, targetUrl: string, bannerId: string, zoneId: string, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackAdClick: (targetUrl: string, clickId: string, costModel: string, cost: number, bannerId: string, zoneId: string, impressionId: string, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackAdConversion: (conversionId: string, costModel: string, cost: number, category: string, action: string, property: string, initialValue: number, advertiserId: string, campaignId: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackSocialInteraction: (action: string, network: string, target: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackAddToCart: (sku: string, name: string, category: string, unitPrice: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackRemoveFromCart: (sku: string, name: string, category: string, unitPrice: string, quantity: string, currency?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackFormChange: (formId: string, elementId: string, nodeName: string, type: string, elementClasses: string[], value: string, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackFormSubmission: (formId: string, formClasses: string[], elements: string[], context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackSiteSearch: (terms: string[], filters: Object, totalResults: number, pageResults: number, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackConsentWithdrawn: (all: boolean, id?: string | undefined, version?: string | undefined, name?: string | undefined, description?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
trackConsentGranted: (id: string, version: string, name?: string | undefined, description?: string | undefined, expiry?: string | undefined, context?: SelfDescribingJson[] | undefined, tstamp?: number | TrueTimestamp | DeviceTimestamp | undefined) => payload.PayloadData;
addGlobalContexts: (contexts: Object[]) => void;
clearGlobalContexts: () => void;
removeGlobalContexts: (contexts: Object[]) => void;
};
}
declare module 'snowplow-tracker/index' {
export { trackerCore } from 'snowplow-tracker/lib/core';
}