@rudderstack/analytics-js 3.0.0-beta.2 → 3.0.0-beta.20
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +200 -3
- package/README.md +57 -10
- package/dist/npm/index.d.ts +1335 -0
- package/dist/npm/legacy/cjs/index.js +3801 -0
- package/dist/npm/legacy/esm/index.js +3799 -0
- package/dist/npm/legacy/umd/index.js +3807 -0
- package/dist/npm/modern/bundled/cjs/index.js +3257 -0
- package/dist/npm/modern/bundled/esm/index.js +3253 -0
- package/dist/npm/modern/bundled/umd/index.js +3263 -0
- package/{modern → dist/npm/modern}/cjs/index.js +427 -516
- package/dist/npm/modern/content-script/cjs/index.js +3233 -0
- package/dist/npm/modern/content-script/esm/index.js +3229 -0
- package/dist/npm/modern/content-script/umd/index.js +3239 -0
- package/{modern → dist/npm/modern}/esm/index.js +428 -512
- package/{modern → dist/npm/modern}/umd/index.js +427 -516
- package/package.json +46 -118
- package/index.d.ts +0 -387
- package/legacy/cjs/index.js +0 -3887
- package/legacy/esm/index.js +0 -3880
- package/legacy/umd/index.js +0 -3893
@@ -0,0 +1,1335 @@
|
|
1
|
+
/// <reference types="../node_modules/user-agent-data-types/index.d.ts" />
|
2
|
+
import { Signal } from '@preact/signals-core';
|
3
|
+
|
4
|
+
type LoggerProvider$1 = Record<Exclude<Lowercase<LogLevel>, Lowercase<'NONE'>>, (...data: any[]) => void>;
|
5
|
+
interface ILogger {
|
6
|
+
minLogLevel: number;
|
7
|
+
scope?: string;
|
8
|
+
logProvider: LoggerProvider$1;
|
9
|
+
log(...data: any[]): void;
|
10
|
+
info(...data: any[]): void;
|
11
|
+
debug(...data: any[]): void;
|
12
|
+
warn(...data: any[]): void;
|
13
|
+
error(...data: any[]): void;
|
14
|
+
setScope(scopeVal: string): void;
|
15
|
+
setMinLogLevel(logLevel: LogLevel): void;
|
16
|
+
}
|
17
|
+
type LogLevel = 'LOG' | 'INFO' | 'DEBUG' | 'WARN' | 'ERROR' | 'NONE';
|
18
|
+
|
19
|
+
type LoggerProvider = Record<Exclude<Lowercase<LogLevel>, Lowercase<'NONE'>>, (...data: any[]) => void>;
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Service to log messages/data to output provider, default is console
|
23
|
+
*/
|
24
|
+
declare class Logger implements ILogger {
|
25
|
+
minLogLevel: number;
|
26
|
+
scope?: string;
|
27
|
+
logProvider: LoggerProvider;
|
28
|
+
constructor(minLogLevel?: LogLevel, scope?: string, logProvider?: Console);
|
29
|
+
log(...data: any[]): void;
|
30
|
+
info(...data: any[]): void;
|
31
|
+
debug(...data: any[]): void;
|
32
|
+
warn(...data: any[]): void;
|
33
|
+
error(...data: any[]): void;
|
34
|
+
outputLog(logMethod: LogLevel, data: any[]): void;
|
35
|
+
setScope(scopeVal: string): void;
|
36
|
+
setMinLogLevel(logLevel: LogLevel): void;
|
37
|
+
/**
|
38
|
+
* Formats the console message using `scope` and styles
|
39
|
+
*/
|
40
|
+
formatLogData(data: any[]): any[];
|
41
|
+
}//# sourceMappingURL=Logger.d.ts.map
|
42
|
+
|
43
|
+
type Nullable<T> = T | null;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Represents a generic object in the APIs
|
47
|
+
* Use for parameters like properties, traits etc.
|
48
|
+
*/
|
49
|
+
type ApiObject = {
|
50
|
+
[index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | null | ApiObject)[] | undefined;
|
51
|
+
};
|
52
|
+
|
53
|
+
type DestinationIntgConfig = boolean | undefined | ApiObject;
|
54
|
+
/**
|
55
|
+
* Represents the integration options object
|
56
|
+
* Example usages:
|
57
|
+
* integrationOptions { All: false, "Google Analytics": true, "Braze": true}
|
58
|
+
* integrationOptions { All: true, "Chartbeat": false, "Customer.io": false}
|
59
|
+
* integrationOptions { All: true, "GA4": { "clientId": "1234" }, "Google Analytics": false }
|
60
|
+
*/
|
61
|
+
type IntegrationOpts = {
|
62
|
+
All?: boolean;
|
63
|
+
[index: string]: DestinationIntgConfig;
|
64
|
+
};
|
65
|
+
|
66
|
+
type Traits = Nullable<ApiObject>;
|
67
|
+
type ApiCallback = (data?: any) => void;
|
68
|
+
/**
|
69
|
+
* Represents the options parameter in the APIs
|
70
|
+
*/
|
71
|
+
type ApiOptions = {
|
72
|
+
integrations?: IntegrationOpts;
|
73
|
+
anonymousId?: string;
|
74
|
+
originalTimestamp?: string;
|
75
|
+
[index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | ApiObject)[] | undefined;
|
76
|
+
};
|
77
|
+
type APIEvent = {
|
78
|
+
type: RudderEventType;
|
79
|
+
category?: string;
|
80
|
+
name?: string;
|
81
|
+
properties?: Nullable<ApiObject>;
|
82
|
+
options?: Nullable<ApiOptions>;
|
83
|
+
callback?: () => void;
|
84
|
+
userId?: Nullable<string>;
|
85
|
+
traits?: Nullable<ApiObject>;
|
86
|
+
to?: Nullable<string>;
|
87
|
+
from?: string;
|
88
|
+
groupId?: Nullable<string>;
|
89
|
+
};
|
90
|
+
type RudderEventType = 'page' | 'track' | 'identify' | 'alias' | 'group';
|
91
|
+
type ReadyCallback = () => void;
|
92
|
+
|
93
|
+
type RegionDetails = {
|
94
|
+
url: string;
|
95
|
+
default: boolean;
|
96
|
+
};
|
97
|
+
/**
|
98
|
+
* Represents residency server input the options
|
99
|
+
*/
|
100
|
+
type ResidencyServerRegion = 'US' | 'EU';
|
101
|
+
|
102
|
+
interface ExtensionPoint {
|
103
|
+
[lifeCycleName: string]: (...args: any[]) => unknown;
|
104
|
+
}
|
105
|
+
/**
|
106
|
+
* ExtensionPoint can be nested, e.g. 'sdk.initialize.phase1'
|
107
|
+
* When index signature is provided, every key have to match the type, the types
|
108
|
+
* for 'name', 'deps', and 'initialize' is added as index signature.
|
109
|
+
*/
|
110
|
+
interface ExtensionPlugin {
|
111
|
+
name: string;
|
112
|
+
initialize?: (state?: any) => void;
|
113
|
+
deps?: string[];
|
114
|
+
[key: string]: string | (() => void) | ExtensionPoint | ((...args: any[]) => unknown | void) | string[] | undefined;
|
115
|
+
}
|
116
|
+
type PluginEngineConfig = {
|
117
|
+
throws?: boolean | RegExp;
|
118
|
+
};
|
119
|
+
interface IPluginEngine {
|
120
|
+
plugins: ExtensionPlugin[];
|
121
|
+
byName: Record<string, ExtensionPlugin>;
|
122
|
+
cache: Record<string, ExtensionPlugin[]>;
|
123
|
+
config: PluginEngineConfig;
|
124
|
+
register: (plugin: ExtensionPlugin, state?: Record<string, any>) => void;
|
125
|
+
unregister: (name: string) => void;
|
126
|
+
getPlugin: (name: string) => ExtensionPlugin | undefined;
|
127
|
+
getPlugins: (extPoint?: string) => ExtensionPlugin[];
|
128
|
+
invoke: <T = any>(extPoint?: string, allowMultiple?: boolean, ...args: any[]) => Nullable<T>[];
|
129
|
+
invokeSingle: <T = any>(extPoint?: string, ...args: any[]) => Nullable<T>;
|
130
|
+
invokeMultiple: <T = any>(extPoint?: string, ...args: any[]) => Nullable<T>[];
|
131
|
+
}
|
132
|
+
|
133
|
+
interface IPluginsManager {
|
134
|
+
engine: IPluginEngine;
|
135
|
+
init(): void;
|
136
|
+
attachEffects(): void;
|
137
|
+
setActivePlugins(): void;
|
138
|
+
invokeMultiple<T = any>(extPoint?: string, ...args: any[]): Nullable<T>[];
|
139
|
+
invokeSingle<T = any>(extPoint?: string, ...args: any[]): Nullable<T>;
|
140
|
+
register(plugins: ExtensionPlugin[]): void;
|
141
|
+
}
|
142
|
+
type PluginName = 'BeaconQueue' | 'Bugsnag' | 'CustomConsentManager' | 'DeviceModeDestinations' | 'DeviceModeTransformation' | 'ErrorReporting' | 'ExternalAnonymousId' | 'GoogleLinker' | 'KetchConsentManager' | 'NativeDestinationQueue' | 'OneTrustConsentManager' | 'StorageEncryption' | 'StorageEncryptionLegacy' | 'StorageMigrator' | 'XhrQueue';
|
143
|
+
|
144
|
+
type OneTrustCookieCategory = {
|
145
|
+
oneTrustCookieCategory: string;
|
146
|
+
};
|
147
|
+
type ConsentManagementMetadata = {
|
148
|
+
providers: ConsentManagementProviderMetadata[];
|
149
|
+
};
|
150
|
+
type ConsentManagementProviderMetadata = {
|
151
|
+
provider: ConsentManagementProvider;
|
152
|
+
resolutionStrategy: ConsentResolutionStrategy;
|
153
|
+
};
|
154
|
+
type ConsentManagementProvider = 'oneTrust' | 'ketch' | 'custom';
|
155
|
+
type ConsentResolutionStrategy = 'and' | 'or';
|
156
|
+
type Consents = string[];
|
157
|
+
type ConsentManagementOptions = {
|
158
|
+
enabled: boolean;
|
159
|
+
provider: ConsentManagementProvider;
|
160
|
+
allowedConsentIds?: Consents;
|
161
|
+
deniedConsentIds?: Consents;
|
162
|
+
};
|
163
|
+
type ConsentsInfo = {
|
164
|
+
allowedConsentIds?: Consents;
|
165
|
+
deniedConsentIds?: Consents;
|
166
|
+
};
|
167
|
+
type KetchConsentPurpose = {
|
168
|
+
purpose: string;
|
169
|
+
};
|
170
|
+
|
171
|
+
type UserSessionKey = 'userId' | 'userTraits' | 'anonymousId' | 'groupId' | 'groupTraits' | 'initialReferrer' | 'initialReferringDomain' | 'sessionInfo' | 'authToken';
|
172
|
+
|
173
|
+
type StorageEncryptionVersion = 'legacy' | 'v3';
|
174
|
+
type StorageType = 'cookieStorage' | 'localStorage' | 'memoryStorage' | 'sessionStorage' | 'none';
|
175
|
+
type StorageEncryption = {
|
176
|
+
version: StorageEncryptionVersion;
|
177
|
+
};
|
178
|
+
type LoadOptionStorageEntry = {
|
179
|
+
type: StorageType;
|
180
|
+
};
|
181
|
+
type StorageOpts = {
|
182
|
+
encryption?: StorageEncryption;
|
183
|
+
migrate?: boolean;
|
184
|
+
type?: StorageType;
|
185
|
+
cookie?: CookieOptions;
|
186
|
+
entries?: {
|
187
|
+
[key in UserSessionKey]?: LoadOptionStorageEntry;
|
188
|
+
};
|
189
|
+
};
|
190
|
+
type CookieOptions = {
|
191
|
+
maxage?: number;
|
192
|
+
expires?: Date;
|
193
|
+
path?: string;
|
194
|
+
domain?: string;
|
195
|
+
samesite?: string;
|
196
|
+
secure?: boolean;
|
197
|
+
};
|
198
|
+
type CookieSameSite = 'Strict' | 'Lax' | 'None';
|
199
|
+
|
200
|
+
type UaChTrackLevel = 'none' | 'default' | 'full';
|
201
|
+
/**
|
202
|
+
* Represents the options parameter for anonymousId
|
203
|
+
*/
|
204
|
+
type AnonymousIdOptions = {
|
205
|
+
autoCapture?: {
|
206
|
+
enabled?: boolean;
|
207
|
+
source?: string;
|
208
|
+
};
|
209
|
+
};
|
210
|
+
type SessionOpts = {
|
211
|
+
autoTrack?: boolean;
|
212
|
+
timeout?: number;
|
213
|
+
};
|
214
|
+
type EventMapping = {
|
215
|
+
from: string;
|
216
|
+
to: string;
|
217
|
+
};
|
218
|
+
type Conversion = {
|
219
|
+
conversionLabel: string;
|
220
|
+
name: string;
|
221
|
+
};
|
222
|
+
type EventFilteringOption = 'disable' | 'whitelistedEvents' | 'blacklistedEvents';
|
223
|
+
/**
|
224
|
+
* Represents the beacon queue options parameter in loadOptions type
|
225
|
+
*/
|
226
|
+
type BeaconQueueOpts = {
|
227
|
+
maxItems?: number;
|
228
|
+
flushQueueInterval?: number;
|
229
|
+
};
|
230
|
+
type EventsTransportMode = 'xhr' | 'beacon';
|
231
|
+
type BatchOpts = {
|
232
|
+
enabled: boolean;
|
233
|
+
maxItems?: number;
|
234
|
+
maxSize?: number;
|
235
|
+
flushInterval?: number;
|
236
|
+
};
|
237
|
+
/**
|
238
|
+
* Represents the queue options parameter in loadOptions type
|
239
|
+
*/
|
240
|
+
type QueueOpts = {
|
241
|
+
maxRetryDelay?: number;
|
242
|
+
minRetryDelay?: number;
|
243
|
+
backoffFactor?: number;
|
244
|
+
backoffJitter?: number;
|
245
|
+
maxAttempts?: number;
|
246
|
+
maxItems?: number;
|
247
|
+
batch?: BatchOpts;
|
248
|
+
};
|
249
|
+
/**
|
250
|
+
* Represents the destinations queue options parameter in loadOptions type
|
251
|
+
*/
|
252
|
+
type DestinationsQueueOpts = {
|
253
|
+
maxItems?: number;
|
254
|
+
};
|
255
|
+
type OnLoadedCallback = (analytics: any) => void;
|
256
|
+
type DeliveryType = 'immediate' | 'buffer';
|
257
|
+
type StorageStrategy = 'none' | 'session' | 'anonymousId';
|
258
|
+
type PreConsentStorageOptions = {
|
259
|
+
strategy: StorageStrategy;
|
260
|
+
};
|
261
|
+
type PreConsentEventsOptions = {
|
262
|
+
delivery: DeliveryType;
|
263
|
+
};
|
264
|
+
type PreConsentOptions = {
|
265
|
+
enabled: boolean;
|
266
|
+
storage?: PreConsentStorageOptions;
|
267
|
+
events?: PreConsentEventsOptions;
|
268
|
+
};
|
269
|
+
/**
|
270
|
+
* Represents the options parameter in the load API
|
271
|
+
*/
|
272
|
+
type LoadOptions = {
|
273
|
+
logLevel?: LogLevel;
|
274
|
+
integrations?: IntegrationOpts;
|
275
|
+
configUrl?: string;
|
276
|
+
queueOptions?: QueueOpts;
|
277
|
+
loadIntegration?: boolean;
|
278
|
+
sessions?: SessionOpts;
|
279
|
+
secureCookie?: boolean;
|
280
|
+
destSDKBaseURL?: string;
|
281
|
+
pluginsSDKBaseURL?: string;
|
282
|
+
useBeacon?: boolean;
|
283
|
+
beaconQueueOptions?: BeaconQueueOpts;
|
284
|
+
destinationsQueueOptions?: DestinationsQueueOpts;
|
285
|
+
anonymousIdOptions?: AnonymousIdOptions;
|
286
|
+
setCookieDomain?: string;
|
287
|
+
sameSiteCookie?: CookieSameSite;
|
288
|
+
lockIntegrationsVersion?: boolean;
|
289
|
+
polyfillIfRequired?: boolean;
|
290
|
+
onLoaded?: OnLoadedCallback;
|
291
|
+
uaChTrackLevel?: UaChTrackLevel;
|
292
|
+
residencyServer?: ResidencyServerRegion;
|
293
|
+
getSourceConfig?: () => string | ApiObject | Promise<ApiObject> | Promise<string>;
|
294
|
+
sendAdblockPage?: boolean;
|
295
|
+
sendAdblockPageOptions?: ApiOptions;
|
296
|
+
plugins?: Nullable<PluginName[]>;
|
297
|
+
polyfillURL?: string;
|
298
|
+
useGlobalIntegrationsConfigInEvents?: boolean;
|
299
|
+
bufferDataPlaneEventsUntilReady?: boolean;
|
300
|
+
dataPlaneEventsBufferTimeout?: number;
|
301
|
+
storage?: StorageOpts;
|
302
|
+
preConsent?: PreConsentOptions;
|
303
|
+
transportMode?: EventsTransportMode;
|
304
|
+
consentManagement?: ConsentManagementOptions;
|
305
|
+
sameDomainCookiesOnly?: boolean;
|
306
|
+
};
|
307
|
+
type ConsentOptions = {
|
308
|
+
storage?: StorageOpts;
|
309
|
+
consentManagement?: ConsentManagementOptions;
|
310
|
+
integrations?: IntegrationOpts;
|
311
|
+
discardPreConsentEvents?: boolean;
|
312
|
+
sendPageEvent?: boolean;
|
313
|
+
trackConsent?: boolean;
|
314
|
+
};
|
315
|
+
|
316
|
+
type Address = {
|
317
|
+
city?: string;
|
318
|
+
City?: string;
|
319
|
+
country?: string;
|
320
|
+
Country?: string;
|
321
|
+
postalCode?: string;
|
322
|
+
state?: string;
|
323
|
+
State?: string;
|
324
|
+
street?: string;
|
325
|
+
};
|
326
|
+
type Company = {
|
327
|
+
name?: string;
|
328
|
+
id?: string;
|
329
|
+
industry?: string;
|
330
|
+
employee_count?: string;
|
331
|
+
plan?: string;
|
332
|
+
};
|
333
|
+
/**
|
334
|
+
* Represents a traits object in the Identify API
|
335
|
+
*/
|
336
|
+
type IdentifyTraits = {
|
337
|
+
id?: string;
|
338
|
+
userId?: string;
|
339
|
+
firstName?: string;
|
340
|
+
firstname?: string;
|
341
|
+
first_name?: string;
|
342
|
+
lastName?: string;
|
343
|
+
lastname?: string;
|
344
|
+
last_name?: string;
|
345
|
+
name?: string;
|
346
|
+
Name?: string;
|
347
|
+
age?: number;
|
348
|
+
email?: string;
|
349
|
+
Email?: string;
|
350
|
+
'E-mail'?: string;
|
351
|
+
phone?: string;
|
352
|
+
address?: string | Address;
|
353
|
+
birthday?: string;
|
354
|
+
company?: Company;
|
355
|
+
createdAt?: string;
|
356
|
+
description?: string;
|
357
|
+
gender?: string;
|
358
|
+
title?: string;
|
359
|
+
username?: string;
|
360
|
+
website?: string;
|
361
|
+
avatar?: string;
|
362
|
+
zip?: string | number;
|
363
|
+
state?: string;
|
364
|
+
State?: string;
|
365
|
+
dob?: string;
|
366
|
+
employed?: string | boolean;
|
367
|
+
education?: string;
|
368
|
+
married?: string | boolean;
|
369
|
+
customerType?: string | number;
|
370
|
+
euConsent?: string;
|
371
|
+
euConsentMessage?: string;
|
372
|
+
newEmail?: string;
|
373
|
+
tags?: string | string[];
|
374
|
+
removeTags?: string | string[];
|
375
|
+
prospect?: string | boolean;
|
376
|
+
doubleOptin?: string | boolean;
|
377
|
+
event_id?: string;
|
378
|
+
constructor?: Record<string, string>;
|
379
|
+
organization?: string;
|
380
|
+
region?: string;
|
381
|
+
anonymous?: string | boolean;
|
382
|
+
country?: string;
|
383
|
+
custom?: string;
|
384
|
+
ip?: string;
|
385
|
+
privateAttributeNames?: any;
|
386
|
+
secondary?: any;
|
387
|
+
customPageId?: string;
|
388
|
+
isRudderEvents?: boolean;
|
389
|
+
optOutType?: boolean | string | number;
|
390
|
+
groupType?: string | number;
|
391
|
+
anonymousId?: string | number;
|
392
|
+
ip_address?: string;
|
393
|
+
number?: string | number;
|
394
|
+
[index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | null | ApiObject)[] | undefined;
|
395
|
+
};
|
396
|
+
|
397
|
+
type AnalyticsIdentifyMethod = {
|
398
|
+
(userId?: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
399
|
+
(userId: string, traits: Nullable<IdentifyTraits>, callback: ApiCallback): void;
|
400
|
+
(userId: string, callback: ApiCallback): void;
|
401
|
+
(traits: Nullable<IdentifyTraits>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
402
|
+
(traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
|
403
|
+
};
|
404
|
+
type AnalyticsPageMethod = {
|
405
|
+
(category?: string, name?: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
406
|
+
(category: string, name: string, properties: Nullable<ApiObject>, callback: ApiCallback): void;
|
407
|
+
(name: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
408
|
+
(category: string, name: string, callback: ApiCallback): void;
|
409
|
+
(name: string, properties: Nullable<ApiObject>, callback: ApiCallback): void;
|
410
|
+
(name: string, callback: ApiCallback): void;
|
411
|
+
(properties: Nullable<ApiObject>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
412
|
+
(properties: Nullable<ApiObject>, callback?: ApiCallback): void;
|
413
|
+
};
|
414
|
+
type AnalyticsTrackMethod = {
|
415
|
+
(event: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
416
|
+
(event: string, properties: Nullable<ApiObject>, callback: ApiCallback): void;
|
417
|
+
(event: string, callback: ApiCallback): void;
|
418
|
+
};
|
419
|
+
type AnalyticsGroupMethod = {
|
420
|
+
(groupId: string | number, traits?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
421
|
+
(groupId: string | number, traits: Nullable<ApiObject>, callback: ApiCallback): void;
|
422
|
+
(groupId: string | number, callback: ApiCallback): void;
|
423
|
+
(traits: Nullable<ApiObject>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
424
|
+
(traits: Nullable<ApiObject>, callback?: ApiCallback): void;
|
425
|
+
};
|
426
|
+
type AnalyticsAliasMethod = {
|
427
|
+
(to: Nullable<string>, from?: string, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
428
|
+
(to: Nullable<string>, from: string, callback: ApiCallback): void;
|
429
|
+
(to: Nullable<string>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
|
430
|
+
(to: Nullable<string>, callback: ApiCallback): void;
|
431
|
+
(to: ApiCallback): void;
|
432
|
+
(): void;
|
433
|
+
};
|
434
|
+
interface IRudderAnalytics<T = any> {
|
435
|
+
analyticsInstances: Record<string, T>;
|
436
|
+
defaultAnalyticsKey: string;
|
437
|
+
logger: ILogger;
|
438
|
+
/**
|
439
|
+
* Set the writeKey of the analytics instance that should be default
|
440
|
+
*/
|
441
|
+
setDefaultInstanceKey(writeKey: string, autoSet: boolean): void;
|
442
|
+
/**
|
443
|
+
* Get the instance of Analytics that is set as default
|
444
|
+
*/
|
445
|
+
getAnalyticsInstance(writeKey?: string): T;
|
446
|
+
/**
|
447
|
+
* Trigger load event in buffer queue if exists
|
448
|
+
*/
|
449
|
+
triggerBufferedLoadEvent(): void;
|
450
|
+
/**
|
451
|
+
* Call control pane to get client configs
|
452
|
+
*/
|
453
|
+
load(writeKey: string, dataPlaneUrl: string, loadOptions?: Partial<LoadOptions>): void;
|
454
|
+
/**
|
455
|
+
* To register a callback for SDK ready state
|
456
|
+
*/
|
457
|
+
ready(callback: ApiCallback): void;
|
458
|
+
/**
|
459
|
+
* To record a page view event
|
460
|
+
*/
|
461
|
+
page: AnalyticsPageMethod;
|
462
|
+
/**
|
463
|
+
* To record a user track event
|
464
|
+
*/
|
465
|
+
track: AnalyticsTrackMethod;
|
466
|
+
/**
|
467
|
+
* To record a user identification event
|
468
|
+
*/
|
469
|
+
identify: AnalyticsIdentifyMethod;
|
470
|
+
/**
|
471
|
+
* To record a user alias event
|
472
|
+
*/
|
473
|
+
alias: AnalyticsAliasMethod;
|
474
|
+
/**
|
475
|
+
* To record a user group event
|
476
|
+
*/
|
477
|
+
group: AnalyticsGroupMethod;
|
478
|
+
/**
|
479
|
+
* Clear user information
|
480
|
+
*
|
481
|
+
* @param resetAnonymousId optionally clears anonymousId as well
|
482
|
+
*/
|
483
|
+
reset(resetAnonymousId?: boolean): void;
|
484
|
+
/**
|
485
|
+
* To get anonymousId set in the SDK
|
486
|
+
*
|
487
|
+
* @param options options for anonymousId
|
488
|
+
*/
|
489
|
+
getAnonymousId(options?: AnonymousIdOptions): string | undefined;
|
490
|
+
/**
|
491
|
+
* To set anonymousId
|
492
|
+
*
|
493
|
+
* @param anonymousId custom anonymousId value
|
494
|
+
* @param rudderAmpLinkerParam AMP Linker ID string
|
495
|
+
*/
|
496
|
+
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
|
497
|
+
/**
|
498
|
+
* To get userId set in the SDK
|
499
|
+
*/
|
500
|
+
getUserId(): Nullable<string> | undefined;
|
501
|
+
/**
|
502
|
+
* To get user traits set in the SDK
|
503
|
+
*/
|
504
|
+
getUserTraits(): Nullable<ApiObject> | undefined;
|
505
|
+
/**
|
506
|
+
* To get groupId set in the SDK
|
507
|
+
*/
|
508
|
+
getGroupId(): Nullable<string> | undefined;
|
509
|
+
/**
|
510
|
+
* To get group traits set in the SDK
|
511
|
+
*/
|
512
|
+
getGroupTraits(): Nullable<ApiObject> | undefined;
|
513
|
+
/**
|
514
|
+
* To manually start user session in the SDK
|
515
|
+
*/
|
516
|
+
startSession(sessionId?: number): void;
|
517
|
+
/**
|
518
|
+
* To manually end user session in the SDK
|
519
|
+
*/
|
520
|
+
endSession(): void;
|
521
|
+
/**
|
522
|
+
* To set authorization token
|
523
|
+
* @param token token value
|
524
|
+
*/
|
525
|
+
setAuthToken(token: string): void;
|
526
|
+
/**
|
527
|
+
* To fetch the current sessionId
|
528
|
+
*/
|
529
|
+
getSessionId(): Nullable<number>;
|
530
|
+
/**
|
531
|
+
* To provide consent
|
532
|
+
* @param options Consent API options
|
533
|
+
*/
|
534
|
+
consent(options?: ConsentOptions): void;
|
535
|
+
}
|
536
|
+
|
537
|
+
interface IExternalSourceLoadConfig {
|
538
|
+
url: string;
|
539
|
+
id: string;
|
540
|
+
callback?(id?: string): unknown;
|
541
|
+
async?: boolean;
|
542
|
+
timeout?: number;
|
543
|
+
extraAttributes?: Record<string, string>;
|
544
|
+
}
|
545
|
+
interface IExternalSrcLoader {
|
546
|
+
errorHandler?: {
|
547
|
+
onError(error: unknown, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean): void;
|
548
|
+
leaveBreadcrumb(breadcrumb: string): void;
|
549
|
+
notifyError(error: Error): void;
|
550
|
+
};
|
551
|
+
logger?: ILogger;
|
552
|
+
timeout: number;
|
553
|
+
loadJSFile(config: IExternalSourceLoadConfig): void;
|
554
|
+
}
|
555
|
+
|
556
|
+
/**
|
557
|
+
* A buffer queue to serve as a store for any type of data
|
558
|
+
*/
|
559
|
+
declare class BufferQueue<T = any> {
|
560
|
+
items: T[];
|
561
|
+
constructor();
|
562
|
+
enqueue(item: T): void;
|
563
|
+
dequeue(): Nullable<T> | undefined;
|
564
|
+
isEmpty(): boolean;
|
565
|
+
size(): number;
|
566
|
+
clear(): void;
|
567
|
+
}
|
568
|
+
//# sourceMappingURL=BufferQueue.d.ts.map
|
569
|
+
|
570
|
+
type SDKError = unknown | Error | ErrorEvent | Event | PromiseRejectionEvent;
|
571
|
+
interface IErrorHandler {
|
572
|
+
logger?: ILogger;
|
573
|
+
pluginEngine?: IPluginEngine;
|
574
|
+
errorBuffer: BufferQueue<PreLoadErrorData>;
|
575
|
+
init(externalSrcLoader: IExternalSrcLoader): void;
|
576
|
+
onError(error: SDKError, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean, errorType?: string): void;
|
577
|
+
leaveBreadcrumb(breadcrumb: string): void;
|
578
|
+
notifyError(error: Error): void;
|
579
|
+
attachErrorListeners(): void;
|
580
|
+
}
|
581
|
+
type ErrorState = {
|
582
|
+
severity: string;
|
583
|
+
unhandled: boolean;
|
584
|
+
severityReason: {
|
585
|
+
type: string;
|
586
|
+
};
|
587
|
+
};
|
588
|
+
type PreLoadErrorData = {
|
589
|
+
error: SDKError;
|
590
|
+
errorState: ErrorState;
|
591
|
+
};
|
592
|
+
|
593
|
+
interface IRequestConfig {
|
594
|
+
url: string;
|
595
|
+
options?: Partial<IXHRRequestOptions>;
|
596
|
+
isRawResponse?: boolean;
|
597
|
+
timeout?: number;
|
598
|
+
}
|
599
|
+
type ResponseDetails = {
|
600
|
+
response: string;
|
601
|
+
error?: Error;
|
602
|
+
xhr?: XMLHttpRequest;
|
603
|
+
options: IXHRRequestOptions;
|
604
|
+
};
|
605
|
+
interface IAsyncRequestConfig<T> extends IRequestConfig {
|
606
|
+
callback?(data?: T | string | undefined, details?: ResponseDetails): void;
|
607
|
+
}
|
608
|
+
interface IXHRRequestOptions {
|
609
|
+
method: HTTPClientMethod;
|
610
|
+
url: string;
|
611
|
+
headers: Record<string, string | undefined>;
|
612
|
+
data?: XMLHttpRequestBodyInit;
|
613
|
+
sendRawData?: boolean;
|
614
|
+
}
|
615
|
+
type HTTPClientMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
|
616
|
+
interface IHttpClient {
|
617
|
+
errorHandler?: IErrorHandler;
|
618
|
+
logger?: ILogger;
|
619
|
+
basicAuthHeader?: string;
|
620
|
+
hasErrorHandler: boolean;
|
621
|
+
getData<T = any>(config: IRequestConfig): Promise<{
|
622
|
+
data: T | string | undefined;
|
623
|
+
details?: ResponseDetails;
|
624
|
+
}>;
|
625
|
+
getAsyncData<T = any>(config: IAsyncRequestConfig<T>): void;
|
626
|
+
setAuthHeader(value: string, noBto?: boolean): void;
|
627
|
+
resetAuthHeader(): void;
|
628
|
+
}
|
629
|
+
|
630
|
+
type StoreId = string;
|
631
|
+
interface IStoreConfig {
|
632
|
+
name: string;
|
633
|
+
id: StoreId;
|
634
|
+
isEncrypted?: boolean;
|
635
|
+
validKeys?: Record<string, string>;
|
636
|
+
noCompoundKey?: boolean;
|
637
|
+
errorHandler?: IErrorHandler;
|
638
|
+
logger?: ILogger;
|
639
|
+
type?: StorageType;
|
640
|
+
}
|
641
|
+
interface IStoreManager {
|
642
|
+
stores?: Record<StoreId, IStore>;
|
643
|
+
isInitialized?: boolean;
|
644
|
+
errorHandler?: IErrorHandler;
|
645
|
+
logger?: ILogger;
|
646
|
+
init(): void;
|
647
|
+
initializeStorageState(): void;
|
648
|
+
setStore(storeConfig: IStoreConfig): IStore;
|
649
|
+
getStore(id: StoreId): IStore | undefined;
|
650
|
+
}
|
651
|
+
interface IStore {
|
652
|
+
id: string;
|
653
|
+
name: string;
|
654
|
+
isEncrypted: boolean;
|
655
|
+
validKeys: Record<string, string>;
|
656
|
+
engine: IStorage;
|
657
|
+
originalEngine: IStorage;
|
658
|
+
noKeyValidation?: boolean;
|
659
|
+
noCompoundKey?: boolean;
|
660
|
+
errorHandler?: IErrorHandler;
|
661
|
+
logger?: ILogger;
|
662
|
+
pluginsManager?: IPluginsManager;
|
663
|
+
createValidKey(key: string): string | undefined;
|
664
|
+
swapQueueStoreToInMemoryEngine(): void;
|
665
|
+
set(key: string, value: any): void;
|
666
|
+
get<T = any>(key: string): Nullable<T>;
|
667
|
+
remove(key: string): void;
|
668
|
+
getOriginalEngine(): IStorage;
|
669
|
+
decrypt(value?: Nullable<string>): Nullable<string>;
|
670
|
+
encrypt(value: any): string;
|
671
|
+
crypto(value: string, mode: 'encrypt' | 'decrypt'): string;
|
672
|
+
onError(error: unknown): void;
|
673
|
+
}
|
674
|
+
interface IStorage extends Storage {
|
675
|
+
configure?(options: StorageOptions): void;
|
676
|
+
isEnabled?: boolean;
|
677
|
+
}
|
678
|
+
type StorageOptions = Partial<ICookieStorageOptions | ILocalStorageOptions | IInMemoryStorageOptions>;
|
679
|
+
interface ICookieStorageOptions extends CookieOptions {
|
680
|
+
samesite?: CookieSameSite;
|
681
|
+
domain?: string;
|
682
|
+
secure?: boolean;
|
683
|
+
enabled?: boolean;
|
684
|
+
sameDomainCookiesOnly?: boolean;
|
685
|
+
}
|
686
|
+
interface ILocalStorageOptions {
|
687
|
+
enabled?: boolean;
|
688
|
+
}
|
689
|
+
interface IInMemoryStorageOptions {
|
690
|
+
enabled?: boolean;
|
691
|
+
}
|
692
|
+
|
693
|
+
type PageCallOptions = {
|
694
|
+
category?: string;
|
695
|
+
name?: string;
|
696
|
+
properties?: Nullable<ApiObject>;
|
697
|
+
options?: Nullable<ApiOptions>;
|
698
|
+
callback?: ApiCallback;
|
699
|
+
};
|
700
|
+
type TrackCallOptions = {
|
701
|
+
name: string;
|
702
|
+
properties?: Nullable<ApiObject>;
|
703
|
+
options?: Nullable<ApiOptions>;
|
704
|
+
callback?: ApiCallback;
|
705
|
+
};
|
706
|
+
type IdentifyCallOptions = {
|
707
|
+
userId?: string | null;
|
708
|
+
traits?: Nullable<IdentifyTraits>;
|
709
|
+
options?: Nullable<ApiOptions>;
|
710
|
+
callback?: ApiCallback;
|
711
|
+
};
|
712
|
+
type AliasCallOptions = {
|
713
|
+
to?: Nullable<string>;
|
714
|
+
from?: Nullable<string>;
|
715
|
+
options?: Nullable<ApiOptions>;
|
716
|
+
callback?: ApiCallback;
|
717
|
+
};
|
718
|
+
type GroupCallOptions = {
|
719
|
+
groupId?: Nullable<string>;
|
720
|
+
traits?: Nullable<ApiObject>;
|
721
|
+
options?: Nullable<ApiOptions>;
|
722
|
+
callback?: ApiCallback;
|
723
|
+
};
|
724
|
+
|
725
|
+
/**
|
726
|
+
* Store Implementation with dedicated storage
|
727
|
+
*/
|
728
|
+
declare class Store implements IStore {
|
729
|
+
id: string;
|
730
|
+
name: string;
|
731
|
+
isEncrypted: boolean;
|
732
|
+
validKeys: Record<string, string>;
|
733
|
+
engine: IStorage;
|
734
|
+
originalEngine: IStorage;
|
735
|
+
noKeyValidation?: boolean;
|
736
|
+
noCompoundKey?: boolean;
|
737
|
+
errorHandler?: IErrorHandler;
|
738
|
+
hasErrorHandler: boolean;
|
739
|
+
logger?: ILogger;
|
740
|
+
pluginsManager?: IPluginsManager;
|
741
|
+
constructor(config: IStoreConfig, engine?: IStorage, pluginsManager?: IPluginsManager);
|
742
|
+
/**
|
743
|
+
* Ensure the key is valid and with correct format
|
744
|
+
*/
|
745
|
+
createValidKey(key: string): string | undefined;
|
746
|
+
/**
|
747
|
+
* Switch to inMemoryEngine, bringing any existing data with.
|
748
|
+
*/
|
749
|
+
swapQueueStoreToInMemoryEngine(): void;
|
750
|
+
/**
|
751
|
+
* Set value by key.
|
752
|
+
*/
|
753
|
+
set(key: string, value: any): void;
|
754
|
+
/**
|
755
|
+
* Get by Key.
|
756
|
+
*/
|
757
|
+
get<T = any>(key: string): Nullable<T>;
|
758
|
+
/**
|
759
|
+
* Remove by Key.
|
760
|
+
*/
|
761
|
+
remove(key: string): void;
|
762
|
+
/**
|
763
|
+
* Get original engine
|
764
|
+
*/
|
765
|
+
getOriginalEngine(): IStorage;
|
766
|
+
/**
|
767
|
+
* Decrypt values
|
768
|
+
*/
|
769
|
+
decrypt(value?: Nullable<string>): Nullable<string>;
|
770
|
+
/**
|
771
|
+
* Encrypt value
|
772
|
+
*/
|
773
|
+
encrypt(value: Nullable<any>): string;
|
774
|
+
/**
|
775
|
+
* Extension point to use with encryption plugins
|
776
|
+
*/
|
777
|
+
crypto(value: Nullable<any>, mode: 'encrypt' | 'decrypt'): string;
|
778
|
+
/**
|
779
|
+
* Handle errors
|
780
|
+
*/
|
781
|
+
onError(error: unknown): void;
|
782
|
+
}
|
783
|
+
//# sourceMappingURL=Store.d.ts.map
|
784
|
+
|
785
|
+
interface IUserSessionManager {
|
786
|
+
storeManager?: IStoreManager;
|
787
|
+
init(): void;
|
788
|
+
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
|
789
|
+
getAnonymousId(options?: AnonymousIdOptions): string;
|
790
|
+
refreshSession(): void;
|
791
|
+
getSessionId(): Nullable<number>;
|
792
|
+
getGroupId(): Nullable<string>;
|
793
|
+
getUserId(): Nullable<string>;
|
794
|
+
setUserId(userId?: null | string): void;
|
795
|
+
setUserTraits(traits?: Nullable<ApiObject>): void;
|
796
|
+
getUserTraits(): Nullable<ApiObject>;
|
797
|
+
getGroupTraits(): Nullable<ApiObject>;
|
798
|
+
setGroupId(groupId?: Nullable<string>): void;
|
799
|
+
setGroupTraits(traits?: Nullable<ApiObject>): void;
|
800
|
+
reset(resetAnonymousId?: boolean, noNewSessionStart?: boolean): void;
|
801
|
+
start(sessionId?: number): void;
|
802
|
+
end(): void;
|
803
|
+
syncStorageDataToState(): void;
|
804
|
+
setAuthToken(token: Nullable<string>): void;
|
805
|
+
}
|
806
|
+
|
807
|
+
type DestinationConnectionMode = 'hybrid' | 'cloud' | 'device';
|
808
|
+
type DestinationEvent = {
|
809
|
+
eventName: string;
|
810
|
+
};
|
811
|
+
type DeviceModeDestination = {
|
812
|
+
name: string;
|
813
|
+
destinationId: string;
|
814
|
+
shouldApplyDeviceModeTransformation: boolean;
|
815
|
+
propagateEventsUntransformedOnError: boolean;
|
816
|
+
analytics: any;
|
817
|
+
[index: string]: any;
|
818
|
+
isLoaded: () => boolean;
|
819
|
+
isReady?: () => boolean;
|
820
|
+
};
|
821
|
+
type ConsentsConfig = {
|
822
|
+
consent: string;
|
823
|
+
};
|
824
|
+
type ConsentManagementProviderConfig = {
|
825
|
+
provider: ConsentManagementProvider;
|
826
|
+
consents: ConsentsConfig[];
|
827
|
+
resolutionStrategy: string | undefined;
|
828
|
+
};
|
829
|
+
type DestinationConfig = {
|
830
|
+
blacklistedEvents: DestinationEvent[];
|
831
|
+
whitelistedEvents: DestinationEvent[];
|
832
|
+
oneTrustCookieCategories?: OneTrustCookieCategory[];
|
833
|
+
ketchConsentPurposes?: KetchConsentPurpose[];
|
834
|
+
consentManagement?: ConsentManagementProviderConfig[];
|
835
|
+
eventFilteringOption: EventFilteringOption;
|
836
|
+
clickEventConversions?: Conversion[];
|
837
|
+
pageLoadConversions?: Conversion[];
|
838
|
+
conversionID?: string;
|
839
|
+
conversionLinker?: boolean;
|
840
|
+
disableAdPersonalization?: boolean;
|
841
|
+
dynamicRemarketing?: boolean;
|
842
|
+
sendPageView?: boolean;
|
843
|
+
defaultPageConversion?: string;
|
844
|
+
enableConversionEventsFiltering?: boolean;
|
845
|
+
trackConversions?: boolean;
|
846
|
+
trackDynamicRemarketing?: boolean;
|
847
|
+
tagID?: string;
|
848
|
+
advertiserId?: string;
|
849
|
+
partnerId?: string;
|
850
|
+
measurementId?: string;
|
851
|
+
capturePageView?: string;
|
852
|
+
useNativeSDKToSend?: boolean;
|
853
|
+
connectionMode?: DestinationConnectionMode;
|
854
|
+
extendPageViewParams?: boolean;
|
855
|
+
eventMappingFromConfig?: EventMapping[];
|
856
|
+
appKey?: string;
|
857
|
+
dataCenter?: string;
|
858
|
+
enableBrazeLogging?: boolean;
|
859
|
+
enableNestedArrayOperations?: boolean;
|
860
|
+
enableSubscriptionGroupInGroupCall?: boolean;
|
861
|
+
supportDedup?: boolean;
|
862
|
+
trackAnonymousUser?: boolean;
|
863
|
+
serverUrl?: string;
|
864
|
+
containerID?: string;
|
865
|
+
fs_debug_mode?: boolean;
|
866
|
+
fs_org?: boolean;
|
867
|
+
siteID?: string;
|
868
|
+
[key: string]: any;
|
869
|
+
};
|
870
|
+
type Destination = {
|
871
|
+
id: string;
|
872
|
+
displayName: string;
|
873
|
+
userFriendlyId: string;
|
874
|
+
shouldApplyDeviceModeTransformation: boolean;
|
875
|
+
propagateEventsUntransformedOnError: boolean;
|
876
|
+
config: DestinationConfig;
|
877
|
+
instance?: DeviceModeDestination;
|
878
|
+
};
|
879
|
+
|
880
|
+
type StatsCollection = {
|
881
|
+
errors: {
|
882
|
+
enabled: boolean;
|
883
|
+
provider?: string;
|
884
|
+
};
|
885
|
+
metrics: {
|
886
|
+
enabled: boolean;
|
887
|
+
};
|
888
|
+
};
|
889
|
+
type SourceConfig = {
|
890
|
+
statsCollection?: StatsCollection;
|
891
|
+
};
|
892
|
+
type Source = {
|
893
|
+
id: string;
|
894
|
+
config?: SourceConfig;
|
895
|
+
dataplanes?: Record<ResidencyServerRegion, RegionDetails[]>;
|
896
|
+
};
|
897
|
+
|
898
|
+
interface IConfigManager {
|
899
|
+
httpClient: IHttpClient;
|
900
|
+
errorHandler?: IErrorHandler;
|
901
|
+
logger?: ILogger;
|
902
|
+
init: () => void;
|
903
|
+
getConfig: () => void;
|
904
|
+
processConfig: () => void;
|
905
|
+
}
|
906
|
+
|
907
|
+
interface IEventManager {
|
908
|
+
init(): void;
|
909
|
+
addEvent(event: APIEvent): void;
|
910
|
+
resume(): void;
|
911
|
+
}
|
912
|
+
|
913
|
+
interface ICapabilitiesManager {
|
914
|
+
logger?: ILogger;
|
915
|
+
errorHandler?: IErrorHandler;
|
916
|
+
externalSrcLoader?: IExternalSrcLoader;
|
917
|
+
init(): void;
|
918
|
+
detectBrowserCapabilities(): void;
|
919
|
+
prepareBrowserCapabilities(): void;
|
920
|
+
attachWindowListeners(): void;
|
921
|
+
onReady(): void;
|
922
|
+
}
|
923
|
+
|
924
|
+
type PreloadedEventCall = Array<string | any>;
|
925
|
+
type RudderAnalyticsPreloader = {
|
926
|
+
[index: string]: (...args: number[]) => any;
|
927
|
+
};
|
928
|
+
|
929
|
+
interface IAnalytics {
|
930
|
+
preloadBuffer: BufferQueue<PreloadedEventCall>;
|
931
|
+
initialized: boolean;
|
932
|
+
httpClient: IHttpClient;
|
933
|
+
logger: ILogger;
|
934
|
+
errorHandler: IErrorHandler;
|
935
|
+
externalSrcLoader: IExternalSrcLoader;
|
936
|
+
capabilitiesManager: ICapabilitiesManager;
|
937
|
+
storeManager?: IStoreManager;
|
938
|
+
configManager?: IConfigManager;
|
939
|
+
eventManager?: IEventManager;
|
940
|
+
userSessionManager?: IUserSessionManager;
|
941
|
+
pluginsManager?: IPluginsManager;
|
942
|
+
clientDataStore?: Store;
|
943
|
+
/**
|
944
|
+
* Start application lifecycle if not already started
|
945
|
+
*/
|
946
|
+
load(writeKey: string, dataPlaneUrl?: string | Partial<LoadOptions>, loadOptions?: Partial<LoadOptions>): void;
|
947
|
+
/**
|
948
|
+
* Orchestrate the lifecycle of the application phases/status
|
949
|
+
*/
|
950
|
+
startLifecycle(): void;
|
951
|
+
/**
|
952
|
+
* Load browser polyfill if required
|
953
|
+
*/
|
954
|
+
onMounted(): void;
|
955
|
+
/**
|
956
|
+
* Prepare internal services and load configuration
|
957
|
+
*/
|
958
|
+
onBrowserCapabilitiesReady(): void;
|
959
|
+
/**
|
960
|
+
* Enqueue in buffer the events that were triggered pre SDK initialization
|
961
|
+
*/
|
962
|
+
enqueuePreloadBufferEvents(bufferedEvents: PreloadedEventCall[]): void;
|
963
|
+
/**
|
964
|
+
* Start the process of consuming the buffered events that were triggered pre SDK initialization
|
965
|
+
*/
|
966
|
+
processDataInPreloadBuffer(): void;
|
967
|
+
/**
|
968
|
+
* Assign instances for the internal services
|
969
|
+
*/
|
970
|
+
prepareInternalServices(): void;
|
971
|
+
/**
|
972
|
+
* Load configuration
|
973
|
+
*/
|
974
|
+
loadConfig(): void;
|
975
|
+
/**
|
976
|
+
* Initialize the storage and event queue
|
977
|
+
*/
|
978
|
+
onPluginsReady(): void;
|
979
|
+
/**
|
980
|
+
* Load plugins
|
981
|
+
*/
|
982
|
+
onConfigured(): void;
|
983
|
+
/**
|
984
|
+
* Trigger onLoaded callback if any is provided in config & emit initialised event
|
985
|
+
*/
|
986
|
+
onInitialized(): void;
|
987
|
+
/**
|
988
|
+
* Emit ready event
|
989
|
+
*/
|
990
|
+
onReady(): void;
|
991
|
+
/**
|
992
|
+
* Consume preloaded events buffer
|
993
|
+
*/
|
994
|
+
processBufferedEvents(): void;
|
995
|
+
/**
|
996
|
+
* Load device mode destinations
|
997
|
+
*/
|
998
|
+
loadDestinations(): void;
|
999
|
+
/**
|
1000
|
+
* Invoke the ready callbacks if any exist
|
1001
|
+
*/
|
1002
|
+
onDestinationsReady(): void;
|
1003
|
+
/**
|
1004
|
+
* To register a callback for SDK ready state
|
1005
|
+
*/
|
1006
|
+
ready(callback: ApiCallback, isBufferedInvocation?: boolean): void;
|
1007
|
+
/**
|
1008
|
+
* To record a page view event
|
1009
|
+
*/
|
1010
|
+
page(pageOptions: PageCallOptions, isBufferedInvocation?: boolean): void;
|
1011
|
+
/**
|
1012
|
+
* To record a user track event
|
1013
|
+
*/
|
1014
|
+
track(trackCallOptions: TrackCallOptions, isBufferedInvocation?: boolean): void;
|
1015
|
+
/**
|
1016
|
+
* To record a user identification event
|
1017
|
+
*/
|
1018
|
+
identify(identifyCallOptions: IdentifyCallOptions, isBufferedInvocation?: boolean): void;
|
1019
|
+
/**
|
1020
|
+
* To record a user alias event
|
1021
|
+
*/
|
1022
|
+
alias(aliasCallOptions: AliasCallOptions, isBufferedInvocation?: boolean): void;
|
1023
|
+
/**
|
1024
|
+
* To record a user group event
|
1025
|
+
*/
|
1026
|
+
group(groupCallOptions: GroupCallOptions, isBufferedInvocation?: boolean): void;
|
1027
|
+
/**
|
1028
|
+
* To get anonymousId set in the SDK
|
1029
|
+
*/
|
1030
|
+
getAnonymousId(options?: AnonymousIdOptions): string | undefined;
|
1031
|
+
/**
|
1032
|
+
* To set anonymousId
|
1033
|
+
*/
|
1034
|
+
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string, isBufferedInvocation?: boolean): void;
|
1035
|
+
/**
|
1036
|
+
* Clear user information, optionally anonymousId as well
|
1037
|
+
*/
|
1038
|
+
reset(resetAnonymousId?: boolean, isBufferedInvocation?: boolean): void;
|
1039
|
+
/**
|
1040
|
+
* To get userId set in the SDK
|
1041
|
+
*/
|
1042
|
+
getUserId(): Nullable<string> | undefined;
|
1043
|
+
/**
|
1044
|
+
* To get user traits set in the SDK
|
1045
|
+
*/
|
1046
|
+
getUserTraits(): Nullable<ApiObject> | undefined;
|
1047
|
+
/**
|
1048
|
+
* To get groupId set in the SDK
|
1049
|
+
*/
|
1050
|
+
getGroupId(): Nullable<string> | undefined;
|
1051
|
+
/**
|
1052
|
+
* To get group traits set in the SDK
|
1053
|
+
*/
|
1054
|
+
getGroupTraits(): Nullable<ApiObject> | undefined;
|
1055
|
+
/**
|
1056
|
+
* To manually start user session in the SDK
|
1057
|
+
*/
|
1058
|
+
startSession(sessionId?: number, isBufferedInvocation?: boolean): void;
|
1059
|
+
/**
|
1060
|
+
* To manually end user session in the SDK
|
1061
|
+
*/
|
1062
|
+
endSession(isBufferedInvocation?: boolean): void;
|
1063
|
+
/**
|
1064
|
+
* To fetch the current sessionId
|
1065
|
+
*/
|
1066
|
+
getSessionId(): Nullable<number>;
|
1067
|
+
/**
|
1068
|
+
* To record consent
|
1069
|
+
* @param options Consent API options
|
1070
|
+
*/
|
1071
|
+
consent(options?: ConsentOptions, isBufferedInvocation?: boolean): void;
|
1072
|
+
/**
|
1073
|
+
* To set auth token
|
1074
|
+
*/
|
1075
|
+
setAuthToken(token: string): void;
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
|
1079
|
+
static globalSingleton: Nullable<RudderAnalytics>;
|
1080
|
+
analyticsInstances: Record<string, IAnalytics>;
|
1081
|
+
defaultAnalyticsKey: string;
|
1082
|
+
logger: Logger;
|
1083
|
+
constructor();
|
1084
|
+
/**
|
1085
|
+
* Set instance to use if no specific writeKey is provided in methods
|
1086
|
+
* automatically for the first created instance
|
1087
|
+
* TODO: to support multiple analytics instances in the near future
|
1088
|
+
*/
|
1089
|
+
setDefaultInstanceKey(writeKey: string): void;
|
1090
|
+
/**
|
1091
|
+
* Retrieve an existing analytics instance
|
1092
|
+
*/
|
1093
|
+
getAnalyticsInstance(writeKey?: string): IAnalytics;
|
1094
|
+
/**
|
1095
|
+
* Create new analytics instance and trigger application lifecycle start
|
1096
|
+
*/
|
1097
|
+
load(writeKey: string, dataPlaneUrl: string, loadOptions?: Partial<LoadOptions>): void;
|
1098
|
+
/**
|
1099
|
+
* Trigger load event in buffer queue if exists and stores the
|
1100
|
+
* remaining preloaded events array in global object
|
1101
|
+
*/
|
1102
|
+
triggerBufferedLoadEvent(): void;
|
1103
|
+
/**
|
1104
|
+
* Get ready callback arguments and forward to ready call
|
1105
|
+
*/
|
1106
|
+
ready(callback: ApiCallback): void;
|
1107
|
+
/**
|
1108
|
+
* Process page arguments and forward to page call
|
1109
|
+
*/
|
1110
|
+
page(category?: string | Nullable<ApiObject> | ApiCallback, name?: string | Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, properties?: Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
1111
|
+
/**
|
1112
|
+
* Process track arguments and forward to page call
|
1113
|
+
*/
|
1114
|
+
track(event: string, properties?: Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
1115
|
+
/**
|
1116
|
+
* Process identify arguments and forward to page call
|
1117
|
+
*/
|
1118
|
+
identify(userId?: string | number | Nullable<IdentifyTraits>, traits?: Nullable<IdentifyTraits> | Nullable<ApiOptions> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
1119
|
+
/**
|
1120
|
+
* Process alias arguments and forward to page call
|
1121
|
+
*/
|
1122
|
+
alias(to?: Nullable<string> | ApiCallback, from?: string | Nullable<ApiOptions> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
1123
|
+
/**
|
1124
|
+
* Process group arguments and forward to page call
|
1125
|
+
*/
|
1126
|
+
group(groupId: string | number | Nullable<ApiObject> | ApiCallback, traits?: Nullable<ApiOptions> | Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
|
1127
|
+
reset(resetAnonymousId?: boolean): void;
|
1128
|
+
getAnonymousId(options?: AnonymousIdOptions): string | undefined;
|
1129
|
+
setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
|
1130
|
+
getUserId(): Nullable<string> | undefined;
|
1131
|
+
getUserTraits(): Nullable<ApiObject> | undefined;
|
1132
|
+
getGroupId(): Nullable<string> | undefined;
|
1133
|
+
getGroupTraits(): Nullable<ApiObject> | undefined;
|
1134
|
+
startSession(sessionId?: number): void;
|
1135
|
+
endSession(): void;
|
1136
|
+
getSessionId(): Nullable<number>;
|
1137
|
+
setAuthToken(token: string): void;
|
1138
|
+
consent(options?: ConsentOptions): void;
|
1139
|
+
}
|
1140
|
+
//# sourceMappingURL=RudderAnalytics.d.ts.map
|
1141
|
+
|
1142
|
+
type AppInfo = {
|
1143
|
+
readonly name: string;
|
1144
|
+
readonly version: string;
|
1145
|
+
readonly namespace: string;
|
1146
|
+
};
|
1147
|
+
type LibraryInfo = {
|
1148
|
+
readonly name: string;
|
1149
|
+
readonly version: string;
|
1150
|
+
readonly snippetVersion?: string;
|
1151
|
+
};
|
1152
|
+
type OSInfo = {
|
1153
|
+
readonly name: string;
|
1154
|
+
readonly version: string;
|
1155
|
+
};
|
1156
|
+
type ScreenInfo = {
|
1157
|
+
readonly density: number;
|
1158
|
+
readonly width: number;
|
1159
|
+
readonly height: number;
|
1160
|
+
readonly innerWidth: number;
|
1161
|
+
readonly innerHeight: number;
|
1162
|
+
};
|
1163
|
+
|
1164
|
+
type BufferedEvent = any[];
|
1165
|
+
|
1166
|
+
type LifecycleStatus = 'mounted' | 'browserCapabilitiesReady' | 'configured' | 'pluginsLoading' | 'pluginsReady' | 'initialized' | 'loaded' | 'destinationsLoading' | 'destinationsReady' | 'ready' | 'readyExecuted';
|
1167
|
+
|
1168
|
+
type SessionInfo = {
|
1169
|
+
autoTrack?: boolean;
|
1170
|
+
manualTrack?: boolean;
|
1171
|
+
timeout?: number;
|
1172
|
+
expiresAt?: number;
|
1173
|
+
id?: number;
|
1174
|
+
sessionStart?: boolean;
|
1175
|
+
};
|
1176
|
+
|
1177
|
+
type CapabilitiesState = {
|
1178
|
+
isOnline: Signal<boolean>;
|
1179
|
+
storage: {
|
1180
|
+
isLocalStorageAvailable: Signal<boolean>;
|
1181
|
+
isCookieStorageAvailable: Signal<boolean>;
|
1182
|
+
isSessionStorageAvailable: Signal<boolean>;
|
1183
|
+
};
|
1184
|
+
isBeaconAvailable: Signal<boolean>;
|
1185
|
+
isLegacyDOM: Signal<boolean>;
|
1186
|
+
isUaCHAvailable: Signal<boolean>;
|
1187
|
+
isCryptoAvailable: Signal<boolean>;
|
1188
|
+
isIE11: Signal<boolean>;
|
1189
|
+
isAdBlocked: Signal<boolean>;
|
1190
|
+
};
|
1191
|
+
type ConsentsState = {
|
1192
|
+
enabled: Signal<boolean>;
|
1193
|
+
data: Signal<ConsentsInfo>;
|
1194
|
+
initialized: Signal<boolean>;
|
1195
|
+
activeConsentManagerPluginName: Signal<PluginName | undefined>;
|
1196
|
+
preConsent: Signal<PreConsentOptions>;
|
1197
|
+
postConsent: Signal<ConsentOptions>;
|
1198
|
+
resolutionStrategy: Signal<ConsentResolutionStrategy | undefined>;
|
1199
|
+
provider: Signal<ConsentManagementProvider | undefined>;
|
1200
|
+
metadata: Signal<ConsentManagementMetadata | undefined>;
|
1201
|
+
};
|
1202
|
+
type ContextState = {
|
1203
|
+
app: Signal<AppInfo>;
|
1204
|
+
traits: Signal<Nullable<Traits>>;
|
1205
|
+
library: Signal<LibraryInfo>;
|
1206
|
+
userAgent: Signal<Nullable<string>>;
|
1207
|
+
device: Signal<Nullable<any>>;
|
1208
|
+
network: Signal<Nullable<any>>;
|
1209
|
+
os: Signal<OSInfo>;
|
1210
|
+
locale: Signal<Nullable<string>>;
|
1211
|
+
screen: Signal<ScreenInfo>;
|
1212
|
+
'ua-ch': Signal<UADataValues | undefined>;
|
1213
|
+
timezone: Signal<string | undefined>;
|
1214
|
+
};
|
1215
|
+
type EventBufferState = {
|
1216
|
+
toBeProcessedArray: Signal<BufferedEvent[]>;
|
1217
|
+
readyCallbacksArray: Signal<ApiCallback[]>;
|
1218
|
+
};
|
1219
|
+
type LifecycleState = {
|
1220
|
+
activeDataplaneUrl: Signal<string | undefined>;
|
1221
|
+
integrationsCDNPath: Signal<string | undefined>;
|
1222
|
+
pluginsCDNPath: Signal<string | undefined>;
|
1223
|
+
sourceConfigUrl: Signal<string | undefined>;
|
1224
|
+
status: Signal<LifecycleStatus | undefined>;
|
1225
|
+
initialized: Signal<boolean>;
|
1226
|
+
logLevel: Signal<LogLevel>;
|
1227
|
+
loaded: Signal<boolean>;
|
1228
|
+
readyCallbacks: Signal<ReadyCallback[]>;
|
1229
|
+
writeKey: Signal<string | undefined>;
|
1230
|
+
dataPlaneUrl: Signal<string | undefined>;
|
1231
|
+
};
|
1232
|
+
type LoadOptionsState = Signal<LoadOptions>;
|
1233
|
+
type MetricsState = {
|
1234
|
+
retries: Signal<number>;
|
1235
|
+
dropped: Signal<number>;
|
1236
|
+
sent: Signal<number>;
|
1237
|
+
queued: Signal<number>;
|
1238
|
+
triggered: Signal<number>;
|
1239
|
+
};
|
1240
|
+
type NativeDestinationsState = {
|
1241
|
+
configuredDestinations: Signal<Destination[]>;
|
1242
|
+
activeDestinations: Signal<Destination[]>;
|
1243
|
+
loadOnlyIntegrations: Signal<IntegrationOpts>;
|
1244
|
+
failedDestinations: Signal<Destination[]>;
|
1245
|
+
loadIntegration: Signal<boolean>;
|
1246
|
+
initializedDestinations: Signal<Destination[]>;
|
1247
|
+
clientDestinationsReady: Signal<boolean>;
|
1248
|
+
integrationsConfig: Signal<IntegrationOpts>;
|
1249
|
+
};
|
1250
|
+
type PluginsState = {
|
1251
|
+
ready: Signal<boolean>;
|
1252
|
+
loadedPlugins: Signal<string[]>;
|
1253
|
+
failedPlugins: Signal<string[]>;
|
1254
|
+
pluginsToLoadFromConfig: Signal<string[]>;
|
1255
|
+
activePlugins: Signal<string[]>;
|
1256
|
+
totalPluginsToLoad: Signal<number>;
|
1257
|
+
};
|
1258
|
+
type ReportingState = {
|
1259
|
+
isErrorReportingEnabled: Signal<boolean>;
|
1260
|
+
isMetricsReportingEnabled: Signal<boolean>;
|
1261
|
+
errorReportingProviderPluginName: Signal<PluginName | undefined>;
|
1262
|
+
isErrorReportingPluginLoaded: Signal<boolean>;
|
1263
|
+
};
|
1264
|
+
type SessionState = {
|
1265
|
+
readonly userId: Signal<Nullable<string> | undefined>;
|
1266
|
+
readonly userTraits: Signal<Nullable<ApiObject> | undefined>;
|
1267
|
+
readonly anonymousId: Signal<string | undefined>;
|
1268
|
+
readonly groupId: Signal<Nullable<string> | undefined>;
|
1269
|
+
readonly groupTraits: Signal<Nullable<ApiObject> | undefined>;
|
1270
|
+
readonly initialReferrer: Signal<string | undefined>;
|
1271
|
+
readonly initialReferringDomain: Signal<string | undefined>;
|
1272
|
+
readonly sessionInfo: Signal<SessionInfo>;
|
1273
|
+
readonly authToken: Signal<Nullable<string>>;
|
1274
|
+
};
|
1275
|
+
type SourceConfigState = Signal<Source | undefined>;
|
1276
|
+
type StorageEntry = {
|
1277
|
+
type: StorageType;
|
1278
|
+
key: string;
|
1279
|
+
};
|
1280
|
+
type StorageEntries = {
|
1281
|
+
[key in UserSessionKey]?: StorageEntry;
|
1282
|
+
};
|
1283
|
+
type StorageState = {
|
1284
|
+
encryptionPluginName: Signal<PluginName | undefined>;
|
1285
|
+
migrate: Signal<boolean>;
|
1286
|
+
type: Signal<StorageType | undefined>;
|
1287
|
+
cookie: Signal<CookieOptions | undefined>;
|
1288
|
+
entries: Signal<StorageEntries>;
|
1289
|
+
trulyAnonymousTracking: Signal<boolean>;
|
1290
|
+
};
|
1291
|
+
interface ApplicationState {
|
1292
|
+
capabilities: CapabilitiesState;
|
1293
|
+
consents: ConsentsState;
|
1294
|
+
context: ContextState;
|
1295
|
+
eventBuffer: EventBufferState;
|
1296
|
+
lifecycle: LifecycleState;
|
1297
|
+
loadOptions: LoadOptionsState;
|
1298
|
+
metrics: MetricsState;
|
1299
|
+
nativeDestinations: NativeDestinationsState;
|
1300
|
+
plugins: PluginsState;
|
1301
|
+
reporting: ReportingState;
|
1302
|
+
session: SessionState;
|
1303
|
+
source: SourceConfigState;
|
1304
|
+
storage: StorageState;
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
/**
|
1308
|
+
* Exposed values that can be accessed as global objects per analytics instance
|
1309
|
+
* TODO: find all values that need to be exposed in globals if anything else
|
1310
|
+
*/
|
1311
|
+
type ExposedGlobals = {
|
1312
|
+
state?: ApplicationState;
|
1313
|
+
preloadedEventsBuffer?: PreloadedEventCall[];
|
1314
|
+
pluginsCDNPath?: string;
|
1315
|
+
[key: string]: any;
|
1316
|
+
};
|
1317
|
+
/**
|
1318
|
+
* Exposing all globally accessible values for all analytics instances
|
1319
|
+
* As key, we use the value of writeKey assigned to analytics instance that the values belong to
|
1320
|
+
*/
|
1321
|
+
interface IRudderStackGlobals {
|
1322
|
+
[key: string]: ExposedGlobals;
|
1323
|
+
}
|
1324
|
+
|
1325
|
+
declare global {
|
1326
|
+
interface Window {
|
1327
|
+
rudderanalytics: RudderAnalytics | PreloadedEventCall[] | RudderAnalyticsPreloader;
|
1328
|
+
RudderStackGlobals: IRudderStackGlobals;
|
1329
|
+
rudderAnalyticsMount: () => void;
|
1330
|
+
rudderAnalyticsBuildType: 'legacy' | 'modern';
|
1331
|
+
}
|
1332
|
+
}
|
1333
|
+
//# sourceMappingURL=index.d.ts.map
|
1334
|
+
|
1335
|
+
export { type AnonymousIdOptions, type ApiCallback, type ApiObject, type ApiOptions, type BeaconQueueOpts, type ConsentOptions, type CookieSameSite, type DestinationsQueueOpts, type IRudderStackGlobals, type IdentifyTraits, type IntegrationOpts, type LoadOptions, type LogLevel, type PluginName, type PreloadedEventCall, type QueueOpts, type ResidencyServerRegion, RudderAnalytics, type RudderAnalyticsPreloader, type SessionOpts, type UaChTrackLevel };
|