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