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