@rudderstack/analytics-js 3.0.0-beta.9 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="../node_modules/user-agent-data-types/index.d.ts" />
2
2
  import { Signal } from '@preact/signals-core';
3
3
 
4
- type LoggerProvider$1 = Record<Exclude<Lowercase<LogLevel>, Lowercase<LogLevel.None>>, (...data: any[]) => void>;
4
+ type LoggerProvider$1 = Record<Exclude<Lowercase<LogLevel>, Lowercase<'NONE'>>, (...data: any[]) => void>;
5
5
  interface ILogger {
6
6
  minLogLevel: number;
7
7
  scope?: string;
@@ -14,92 +14,40 @@ interface ILogger {
14
14
  setScope(scopeVal: string): void;
15
15
  setMinLogLevel(logLevel: LogLevel): void;
16
16
  }
17
- declare enum LogLevel {
18
- Log = "LOG",
19
- Info = "INFO",
20
- Debug = "DEBUG",
21
- Warn = "WARN",
22
- Error = "ERROR",
23
- None = "NONE"
24
- }
17
+ type LogLevel = 'LOG' | 'INFO' | 'DEBUG' | 'WARN' | 'ERROR' | 'NONE';
25
18
 
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;
19
+ type LoggerProvider = Record<Exclude<Lowercase<LogLevel>, Lowercase<'NONE'>>, (...data: any[]) => void>;
39
20
 
40
- interface ExtensionPoint {
41
- [lifeCycleName: string]: (...args: any[]) => unknown;
42
- }
43
21
  /**
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.
22
+ * Service to log messages/data to output provider, default is console
47
23
  */
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
- }
24
+ declare class Logger implements ILogger {
25
+ minLogLevel: number;
26
+ scope?: string;
27
+ logProvider: LoggerProvider;
28
+ constructor(minLogLevel?: LogLevel, scope?: string, logProvider?: Console);
29
+ log(...data: any[]): void;
30
+ info(...data: any[]): void;
31
+ debug(...data: any[]): void;
32
+ warn(...data: any[]): void;
33
+ error(...data: any[]): void;
34
+ outputLog(logMethod: LogLevel, data: any[]): void;
35
+ setScope(scopeVal: string): void;
36
+ setMinLogLevel(logLevel: LogLevel): void;
37
+ /**
38
+ * Formats the console message using `scope` and styles
39
+ */
40
+ formatLogData(data: any[]): any[];
41
+ }//# sourceMappingURL=Logger.d.ts.map
70
42
 
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
- }
43
+ type Nullable<T> = T | null;
96
44
 
97
45
  /**
98
46
  * Represents a generic object in the APIs
99
47
  * Use for parameters like properties, traits etc.
100
48
  */
101
49
  type ApiObject = {
102
- [index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | null | ApiObject)[] | undefined;
50
+ [index: string]: string | number | boolean | ApiObject | null | Date | (string | number | boolean | null | ApiObject)[] | undefined;
103
51
  };
104
52
 
105
53
  type DestinationIntgConfig = boolean | undefined | ApiObject;
@@ -124,7 +72,7 @@ type ApiOptions = {
124
72
  integrations?: IntegrationOpts;
125
73
  anonymousId?: string;
126
74
  originalTimestamp?: string;
127
- [index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | ApiObject)[] | undefined;
75
+ [index: string]: string | number | boolean | ApiObject | null | Date | (string | number | boolean | ApiObject)[] | undefined;
128
76
  };
129
77
  type APIEvent = {
130
78
  type: RudderEventType;
@@ -139,47 +87,90 @@ type APIEvent = {
139
87
  from?: string;
140
88
  groupId?: Nullable<string>;
141
89
  };
142
- declare enum RudderEventType {
143
- Page = "page",
144
- Track = "track",
145
- Identify = "identify",
146
- Alias = "alias",
147
- Group = "group"
148
- }
90
+ type RudderEventType = 'page' | 'track' | 'identify' | 'alias' | 'group';
149
91
  type ReadyCallback = () => void;
150
92
 
93
+ type RegionDetails = {
94
+ url: string;
95
+ default: boolean;
96
+ };
97
+ /**
98
+ * Represents residency server input the options
99
+ */
100
+ type ResidencyServerRegion = 'US' | 'EU';
101
+
102
+ interface ExtensionPoint {
103
+ [lifeCycleName: string]: (...args: any[]) => unknown;
104
+ }
105
+ /**
106
+ * ExtensionPoint can be nested, e.g. 'sdk.initialize.phase1'
107
+ * When index signature is provided, every key have to match the type, the types
108
+ * for 'name', 'deps', and 'initialize' is added as index signature.
109
+ */
110
+ interface ExtensionPlugin {
111
+ name: string;
112
+ initialize?: (state?: any) => void;
113
+ deps?: string[];
114
+ [key: string]: string | (() => void) | ExtensionPoint | ((...args: any[]) => unknown | void) | string[] | undefined;
115
+ }
116
+ type PluginEngineConfig = {
117
+ throws?: boolean | RegExp;
118
+ };
119
+ interface IPluginEngine {
120
+ plugins: ExtensionPlugin[];
121
+ byName: Record<string, ExtensionPlugin>;
122
+ cache: Record<string, ExtensionPlugin[]>;
123
+ config: PluginEngineConfig;
124
+ register: (plugin: ExtensionPlugin, state?: Record<string, any>) => void;
125
+ unregister: (name: string) => void;
126
+ getPlugin: (name: string) => ExtensionPlugin | undefined;
127
+ getPlugins: (extPoint?: string) => ExtensionPlugin[];
128
+ invoke: <T = any>(extPoint?: string, allowMultiple?: boolean, ...args: any[]) => Nullable<T>[];
129
+ invokeSingle: <T = any>(extPoint?: string, ...args: any[]) => Nullable<T>;
130
+ invokeMultiple: <T = any>(extPoint?: string, ...args: any[]) => Nullable<T>[];
131
+ }
132
+
133
+ interface IPluginsManager {
134
+ engine: IPluginEngine;
135
+ init(): void;
136
+ attachEffects(): void;
137
+ setActivePlugins(): void;
138
+ invokeMultiple<T = any>(extPoint?: string, ...args: any[]): Nullable<T>[];
139
+ invokeSingle<T = any>(extPoint?: string, ...args: any[]): Nullable<T>;
140
+ register(plugins: ExtensionPlugin[]): void;
141
+ }
142
+ type PluginName = 'BeaconQueue' | 'Bugsnag' | 'CustomConsentManager' | 'DeviceModeDestinations' | 'DeviceModeTransformation' | 'ErrorReporting' | 'ExternalAnonymousId' | 'GoogleLinker' | 'KetchConsentManager' | 'NativeDestinationQueue' | 'OneTrustConsentManager' | 'StorageEncryption' | 'StorageEncryptionLegacy' | 'StorageMigrator' | 'XhrQueue';
143
+
151
144
  type OneTrustCookieCategory = {
152
145
  oneTrustCookieCategory: string;
153
146
  };
154
- type CookieConsentOptions = {
155
- [key: string]: {
156
- enabled: boolean;
157
- };
147
+ type ConsentManagementMetadata = {
148
+ providers: ConsentManagementProviderMetadata[];
158
149
  };
159
- type ConsentInfo = {
160
- initialized: boolean;
161
- allowedConsents?: Record<string, string> | string[];
162
- deniedConsentIds?: string[];
150
+ type ConsentManagementProviderMetadata = {
151
+ provider: ConsentManagementProvider;
152
+ resolutionStrategy: ConsentResolutionStrategy;
153
+ };
154
+ type ConsentManagementProvider = 'oneTrust' | 'ketch' | 'custom';
155
+ type ConsentResolutionStrategy = 'and' | 'or';
156
+ type Consents = string[];
157
+ type ConsentManagementOptions = {
158
+ enabled?: boolean;
159
+ provider?: ConsentManagementProvider;
160
+ allowedConsentIds?: Consents;
161
+ deniedConsentIds?: Consents;
162
+ };
163
+ type ConsentsInfo = {
164
+ allowedConsentIds?: Consents;
165
+ deniedConsentIds?: Consents;
163
166
  };
164
167
  type KetchConsentPurpose = {
165
168
  purpose: string;
166
169
  };
167
170
 
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
- }
171
+ type UserSessionKey = 'userId' | 'userTraits' | 'anonymousId' | 'groupId' | 'groupTraits' | 'initialReferrer' | 'initialReferringDomain' | 'sessionInfo' | 'authToken';
178
172
 
179
- declare enum StorageEncryptionVersion {
180
- Legacy = "legacy",
181
- V3 = "v3"
182
- }
173
+ type StorageEncryptionVersion = 'legacy' | 'v3';
183
174
  type StorageType = 'cookieStorage' | 'localStorage' | 'memoryStorage' | 'sessionStorage' | 'none';
184
175
  type StorageEncryption = {
185
176
  version: StorageEncryptionVersion;
@@ -193,7 +184,7 @@ type StorageOpts = {
193
184
  type?: StorageType;
194
185
  cookie?: CookieOptions;
195
186
  entries?: {
196
- [key in UserSessionKeys]?: LoadOptionStorageEntry;
187
+ [key in UserSessionKey]?: LoadOptionStorageEntry;
197
188
  };
198
189
  };
199
190
  type CookieOptions = {
@@ -204,17 +195,9 @@ type CookieOptions = {
204
195
  samesite?: string;
205
196
  secure?: boolean;
206
197
  };
207
- declare enum CookieSameSite {
208
- Strict = "Strict",
209
- Lax = "Lax",
210
- None = "None"
211
- }
198
+ type CookieSameSite = 'Strict' | 'Lax' | 'None';
212
199
 
213
- declare enum UaChTrackLevel {
214
- None = "none",
215
- Default = "default",
216
- Full = "full"
217
- }
200
+ type UaChTrackLevel = 'none' | 'default' | 'full';
218
201
  /**
219
202
  * Represents the options parameter for anonymousId
220
203
  */
@@ -244,6 +227,13 @@ type BeaconQueueOpts = {
244
227
  maxItems?: number;
245
228
  flushQueueInterval?: number;
246
229
  };
230
+ type EventsTransportMode = 'xhr' | 'beacon';
231
+ type BatchOpts = {
232
+ enabled: boolean;
233
+ maxItems?: number;
234
+ maxSize?: number;
235
+ flushInterval?: number;
236
+ };
247
237
  /**
248
238
  * Represents the queue options parameter in loadOptions type
249
239
  */
@@ -251,8 +241,11 @@ type QueueOpts = {
251
241
  maxRetryDelay?: number;
252
242
  minRetryDelay?: number;
253
243
  backoffFactor?: number;
244
+ backoffJitter?: number;
254
245
  maxAttempts?: number;
255
246
  maxItems?: number;
247
+ batch?: BatchOpts;
248
+ timerScaleFactor?: number;
256
249
  };
257
250
  /**
258
251
  * Represents the destinations queue options parameter in loadOptions type
@@ -261,15 +254,8 @@ type DestinationsQueueOpts = {
261
254
  maxItems?: number;
262
255
  };
263
256
  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
- }
257
+ type DeliveryType = 'immediate' | 'buffer';
258
+ type StorageStrategy = 'none' | 'session' | 'anonymousId';
273
259
  type PreConsentStorageOptions = {
274
260
  strategy: StorageStrategy;
275
261
  };
@@ -280,7 +266,6 @@ type PreConsentOptions = {
280
266
  enabled: boolean;
281
267
  storage?: PreConsentStorageOptions;
282
268
  events?: PreConsentEventsOptions;
283
- trackConsent?: boolean;
284
269
  };
285
270
  /**
286
271
  * Represents the options parameter in the load API
@@ -288,22 +273,21 @@ type PreConsentOptions = {
288
273
  type LoadOptions = {
289
274
  logLevel?: LogLevel;
290
275
  integrations?: IntegrationOpts;
291
- configUrl: string;
276
+ configUrl?: string;
292
277
  queueOptions?: QueueOpts;
293
278
  loadIntegration?: boolean;
294
- sessions: SessionOpts;
279
+ sessions?: SessionOpts;
295
280
  secureCookie?: boolean;
296
281
  destSDKBaseURL?: string;
297
282
  pluginsSDKBaseURL?: string;
298
283
  useBeacon?: boolean;
299
284
  beaconQueueOptions?: BeaconQueueOpts;
300
285
  destinationsQueueOptions?: DestinationsQueueOpts;
301
- cookieConsentManager?: CookieConsentOptions;
302
286
  anonymousIdOptions?: AnonymousIdOptions;
303
287
  setCookieDomain?: string;
304
- sameSiteCookie: CookieSameSite;
288
+ sameSiteCookie?: CookieSameSite;
305
289
  lockIntegrationsVersion?: boolean;
306
- polyfillIfRequired: boolean;
290
+ polyfillIfRequired?: boolean;
307
291
  onLoaded?: OnLoadedCallback;
308
292
  uaChTrackLevel?: UaChTrackLevel;
309
293
  residencyServer?: ResidencyServerRegion;
@@ -317,38 +301,107 @@ type LoadOptions = {
317
301
  dataPlaneEventsBufferTimeout?: number;
318
302
  storage?: StorageOpts;
319
303
  preConsent?: PreConsentOptions;
304
+ transportMode?: EventsTransportMode;
305
+ consentManagement?: ConsentManagementOptions;
306
+ sameDomainCookiesOnly?: boolean;
307
+ externalAnonymousIdCookieName?: string;
308
+ };
309
+ type ConsentOptions = {
310
+ storage?: StorageOpts;
311
+ consentManagement?: ConsentManagementOptions;
312
+ integrations?: IntegrationOpts;
313
+ discardPreConsentEvents?: boolean;
314
+ sendPageEvent?: boolean;
315
+ trackConsent?: boolean;
320
316
  };
321
317
 
322
- type LoggerProvider = Record<Exclude<Lowercase<LogLevel>, Lowercase<LogLevel.None>>, (...data: any[]) => void>;
323
-
318
+ type Address = {
319
+ city?: string;
320
+ City?: string;
321
+ country?: string;
322
+ Country?: string;
323
+ postalCode?: string;
324
+ state?: string;
325
+ State?: string;
326
+ street?: string;
327
+ };
328
+ type Company = {
329
+ name?: string;
330
+ id?: string;
331
+ industry?: string;
332
+ employee_count?: string;
333
+ plan?: string;
334
+ };
324
335
  /**
325
- * Service to log messages/data to output provider, default is console
336
+ * Represents a traits object in the Identify API
326
337
  */
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
338
+ type IdentifyTraits = {
339
+ id?: string;
340
+ userId?: string;
341
+ firstName?: string;
342
+ firstname?: string;
343
+ first_name?: string;
344
+ lastName?: string;
345
+ lastname?: string;
346
+ last_name?: string;
347
+ name?: string;
348
+ Name?: string;
349
+ age?: number;
350
+ email?: string;
351
+ Email?: string;
352
+ 'E-mail'?: string;
353
+ phone?: string;
354
+ address?: string | Address;
355
+ birthday?: string;
356
+ company?: Company;
357
+ createdAt?: string;
358
+ description?: string;
359
+ gender?: string;
360
+ title?: string;
361
+ username?: string;
362
+ website?: string;
363
+ avatar?: string;
364
+ zip?: string | number;
365
+ state?: string;
366
+ State?: string;
367
+ dob?: string;
368
+ employed?: string | boolean;
369
+ education?: string;
370
+ married?: string | boolean;
371
+ customerType?: string | number;
372
+ euConsent?: string;
373
+ euConsentMessage?: string;
374
+ newEmail?: string;
375
+ tags?: string | string[];
376
+ removeTags?: string | string[];
377
+ prospect?: string | boolean;
378
+ doubleOptin?: string | boolean;
379
+ event_id?: string;
380
+ constructor?: Record<string, string>;
381
+ organization?: string;
382
+ region?: string;
383
+ anonymous?: string | boolean;
384
+ country?: string;
385
+ custom?: string;
386
+ ip?: string;
387
+ privateAttributeNames?: any;
388
+ secondary?: any;
389
+ customPageId?: string;
390
+ isRudderEvents?: boolean;
391
+ optOutType?: boolean | string | number;
392
+ groupType?: string | number;
393
+ anonymousId?: string | number;
394
+ ip_address?: string;
395
+ number?: string | number;
396
+ [index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | null | ApiObject)[] | undefined;
397
+ };
345
398
 
346
399
  type AnalyticsIdentifyMethod = {
347
- (userId?: string, traits?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
348
- (userId: string, traits: Nullable<ApiObject>, callback: ApiCallback): void;
400
+ (userId?: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
401
+ (userId: string, traits: Nullable<IdentifyTraits>, callback: ApiCallback): void;
349
402
  (userId: string, callback: ApiCallback): void;
350
- (traits: Nullable<ApiObject>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
351
- (traits: Nullable<ApiObject>, callback?: ApiCallback): void;
403
+ (traits: Nullable<IdentifyTraits>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
404
+ (traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
352
405
  };
353
406
  type AnalyticsPageMethod = {
354
407
  (category?: string, name?: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
@@ -467,10 +520,20 @@ interface IRudderAnalytics<T = any> {
467
520
  * To manually end user session in the SDK
468
521
  */
469
522
  endSession(): void;
523
+ /**
524
+ * To set authorization token
525
+ * @param token token value
526
+ */
527
+ setAuthToken(token: string): void;
470
528
  /**
471
529
  * To fetch the current sessionId
472
530
  */
473
531
  getSessionId(): Nullable<number>;
532
+ /**
533
+ * To provide consent
534
+ * @param options Consent API options
535
+ */
536
+ consent(options?: ConsentOptions): void;
474
537
  }
475
538
 
476
539
  interface IExternalSourceLoadConfig {
@@ -492,15 +555,42 @@ interface IExternalSrcLoader {
492
555
  loadJSFile(config: IExternalSourceLoadConfig): void;
493
556
  }
494
557
 
495
- type SDKError = unknown;
558
+ /**
559
+ * A buffer queue to serve as a store for any type of data
560
+ */
561
+ declare class BufferQueue<T = any> {
562
+ items: T[];
563
+ constructor();
564
+ enqueue(item: T): void;
565
+ dequeue(): Nullable<T> | undefined;
566
+ isEmpty(): boolean;
567
+ size(): number;
568
+ clear(): void;
569
+ }
570
+ //# sourceMappingURL=BufferQueue.d.ts.map
571
+
572
+ type SDKError = unknown | Error | ErrorEvent | Event | PromiseRejectionEvent;
496
573
  interface IErrorHandler {
497
574
  logger?: ILogger;
498
575
  pluginEngine?: IPluginEngine;
576
+ errorBuffer: BufferQueue<PreLoadErrorData>;
499
577
  init(externalSrcLoader: IExternalSrcLoader): void;
500
- onError(error: SDKError, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean): void;
578
+ onError(error: SDKError, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean, errorType?: string): void;
501
579
  leaveBreadcrumb(breadcrumb: string): void;
502
580
  notifyError(error: Error): void;
581
+ attachErrorListeners(): void;
503
582
  }
583
+ type ErrorState = {
584
+ severity: string;
585
+ unhandled: boolean;
586
+ severityReason: {
587
+ type: string;
588
+ };
589
+ };
590
+ type PreLoadErrorData = {
591
+ error: SDKError;
592
+ errorState: ErrorState;
593
+ };
504
594
 
505
595
  interface IRequestConfig {
506
596
  url: string;
@@ -539,19 +629,6 @@ interface IHttpClient {
539
629
  resetAuthHeader(): void;
540
630
  }
541
631
 
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
632
  type StoreId = string;
556
633
  interface IStoreConfig {
557
634
  name: string;
@@ -569,7 +646,7 @@ interface IStoreManager {
569
646
  errorHandler?: IErrorHandler;
570
647
  logger?: ILogger;
571
648
  init(): void;
572
- initClientDataStore(): void;
649
+ initializeStorageState(): void;
573
650
  setStore(storeConfig: IStoreConfig): IStore;
574
651
  getStore(id: StoreId): IStore | undefined;
575
652
  }
@@ -598,6 +675,7 @@ interface IStore {
598
675
  }
599
676
  interface IStorage extends Storage {
600
677
  configure?(options: StorageOptions): void;
678
+ keys(): string[];
601
679
  isEnabled?: boolean;
602
680
  }
603
681
  type StorageOptions = Partial<ICookieStorageOptions | ILocalStorageOptions | IInMemoryStorageOptions>;
@@ -606,6 +684,7 @@ interface ICookieStorageOptions extends CookieOptions {
606
684
  domain?: string;
607
685
  secure?: boolean;
608
686
  enabled?: boolean;
687
+ sameDomainCookiesOnly?: boolean;
609
688
  }
610
689
  interface ILocalStorageOptions {
611
690
  enabled?: boolean;
@@ -629,7 +708,7 @@ type TrackCallOptions = {
629
708
  };
630
709
  type IdentifyCallOptions = {
631
710
  userId?: string | null;
632
- traits?: Nullable<ApiObject>;
711
+ traits?: Nullable<IdentifyTraits>;
633
712
  options?: Nullable<ApiOptions>;
634
713
  callback?: ApiCallback;
635
714
  };
@@ -724,13 +803,11 @@ interface IUserSessionManager {
724
803
  reset(resetAnonymousId?: boolean, noNewSessionStart?: boolean): void;
725
804
  start(sessionId?: number): void;
726
805
  end(): void;
806
+ syncStorageDataToState(): void;
807
+ setAuthToken(token: Nullable<string>): void;
727
808
  }
728
809
 
729
- declare enum DestinationConnectionMode {
730
- Hybrid = "hybrid",
731
- Cloud = "cloud",
732
- Device = "device"
733
- }
810
+ type DestinationConnectionMode = 'hybrid' | 'cloud' | 'device';
734
811
  type DestinationEvent = {
735
812
  eventName: string;
736
813
  };
@@ -744,11 +821,20 @@ type DeviceModeDestination = {
744
821
  isLoaded: () => boolean;
745
822
  isReady?: () => boolean;
746
823
  };
824
+ type ConsentsConfig = {
825
+ consent: string;
826
+ };
827
+ type ConsentManagementProviderConfig = {
828
+ provider: ConsentManagementProvider;
829
+ consents: ConsentsConfig[];
830
+ resolutionStrategy: string | undefined;
831
+ };
747
832
  type DestinationConfig = {
748
833
  blacklistedEvents: DestinationEvent[];
749
834
  whitelistedEvents: DestinationEvent[];
750
- oneTrustCookieCategories: OneTrustCookieCategory[];
751
- ketchConsentPurposes: KetchConsentPurpose[];
835
+ oneTrustCookieCategories?: OneTrustCookieCategory[];
836
+ ketchConsentPurposes?: KetchConsentPurpose[];
837
+ consentManagement?: ConsentManagementProviderConfig[];
752
838
  eventFilteringOption: EventFilteringOption;
753
839
  clickEventConversions?: Conversion[];
754
840
  pageLoadConversions?: Conversion[];
@@ -824,6 +910,7 @@ interface IConfigManager {
824
910
  interface IEventManager {
825
911
  init(): void;
826
912
  addEvent(event: APIEvent): void;
913
+ resume(): void;
827
914
  }
828
915
 
829
916
  interface ICapabilitiesManager {
@@ -838,25 +925,13 @@ interface ICapabilitiesManager {
838
925
  }
839
926
 
840
927
  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
928
+ type RudderAnalyticsPreloader = {
929
+ [index: string]: (...args: any[]) => any;
930
+ };
855
931
 
856
932
  interface IAnalytics {
857
933
  preloadBuffer: BufferQueue<PreloadedEventCall>;
858
934
  initialized: boolean;
859
- status?: LifecycleStatus;
860
935
  httpClient: IHttpClient;
861
936
  logger: ILogger;
862
937
  errorHandler: IErrorHandler;
@@ -879,7 +954,11 @@ interface IAnalytics {
879
954
  /**
880
955
  * Load browser polyfill if required
881
956
  */
882
- prepareBrowserCapabilities(): void;
957
+ onMounted(): void;
958
+ /**
959
+ * Prepare internal services and load configuration
960
+ */
961
+ onBrowserCapabilitiesReady(): void;
883
962
  /**
884
963
  * Enqueue in buffer the events that were triggered pre SDK initialization
885
964
  */
@@ -899,11 +978,11 @@ interface IAnalytics {
899
978
  /**
900
979
  * Initialize the storage and event queue
901
980
  */
902
- init(): void;
981
+ onPluginsReady(): void;
903
982
  /**
904
983
  * Load plugins
905
984
  */
906
- loadPlugins(): void;
985
+ onConfigured(): void;
907
986
  /**
908
987
  * Trigger onLoaded callback if any is provided in config & emit initialised event
909
988
  */
@@ -927,27 +1006,27 @@ interface IAnalytics {
927
1006
  /**
928
1007
  * To register a callback for SDK ready state
929
1008
  */
930
- ready(callback: ApiCallback): void;
1009
+ ready(callback: ApiCallback, isBufferedInvocation?: boolean): void;
931
1010
  /**
932
1011
  * To record a page view event
933
1012
  */
934
- page(pageOptions: PageCallOptions): void;
1013
+ page(pageOptions: PageCallOptions, isBufferedInvocation?: boolean): void;
935
1014
  /**
936
1015
  * To record a user track event
937
1016
  */
938
- track(trackCallOptions: TrackCallOptions): void;
1017
+ track(trackCallOptions: TrackCallOptions, isBufferedInvocation?: boolean): void;
939
1018
  /**
940
1019
  * To record a user identification event
941
1020
  */
942
- identify(identifyCallOptions: IdentifyCallOptions): void;
1021
+ identify(identifyCallOptions: IdentifyCallOptions, isBufferedInvocation?: boolean): void;
943
1022
  /**
944
1023
  * To record a user alias event
945
1024
  */
946
- alias(aliasCallOptions: AliasCallOptions): void;
1025
+ alias(aliasCallOptions: AliasCallOptions, isBufferedInvocation?: boolean): void;
947
1026
  /**
948
1027
  * To record a user group event
949
1028
  */
950
- group(groupCallOptions: GroupCallOptions): void;
1029
+ group(groupCallOptions: GroupCallOptions, isBufferedInvocation?: boolean): void;
951
1030
  /**
952
1031
  * To get anonymousId set in the SDK
953
1032
  */
@@ -955,11 +1034,11 @@ interface IAnalytics {
955
1034
  /**
956
1035
  * To set anonymousId
957
1036
  */
958
- setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
1037
+ setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string, isBufferedInvocation?: boolean): void;
959
1038
  /**
960
1039
  * Clear user information, optionally anonymousId as well
961
1040
  */
962
- reset(resetAnonymousId?: boolean): void;
1041
+ reset(resetAnonymousId?: boolean, isBufferedInvocation?: boolean): void;
963
1042
  /**
964
1043
  * To get userId set in the SDK
965
1044
  */
@@ -979,15 +1058,24 @@ interface IAnalytics {
979
1058
  /**
980
1059
  * To manually start user session in the SDK
981
1060
  */
982
- startSession(sessionId?: number): void;
1061
+ startSession(sessionId?: number, isBufferedInvocation?: boolean): void;
983
1062
  /**
984
1063
  * To manually end user session in the SDK
985
1064
  */
986
- endSession(): void;
1065
+ endSession(isBufferedInvocation?: boolean): void;
987
1066
  /**
988
1067
  * To fetch the current sessionId
989
1068
  */
990
1069
  getSessionId(): Nullable<number>;
1070
+ /**
1071
+ * To record consent
1072
+ * @param options Consent API options
1073
+ */
1074
+ consent(options?: ConsentOptions, isBufferedInvocation?: boolean): void;
1075
+ /**
1076
+ * To set auth token
1077
+ */
1078
+ setAuthToken(token: string): void;
991
1079
  }
992
1080
 
993
1081
  declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
@@ -1011,11 +1099,8 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
1011
1099
  */
1012
1100
  load(writeKey: string, dataPlaneUrl: string, loadOptions?: Partial<LoadOptions>): void;
1013
1101
  /**
1014
- * Get preloaded events in buffer queue if exists
1015
- */
1016
- getPreloadBuffer(): void;
1017
- /**
1018
- * Trigger load event in buffer queue if exists
1102
+ * Trigger load event in buffer queue if exists and stores the
1103
+ * remaining preloaded events array in global object
1019
1104
  */
1020
1105
  triggerBufferedLoadEvent(): void;
1021
1106
  /**
@@ -1033,7 +1118,7 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
1033
1118
  /**
1034
1119
  * Process identify arguments and forward to page call
1035
1120
  */
1036
- identify(userId?: string | number | Nullable<ApiObject>, traits?: Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
1121
+ identify(userId?: string | number | Nullable<IdentifyTraits>, traits?: Nullable<IdentifyTraits> | Nullable<ApiOptions> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
1037
1122
  /**
1038
1123
  * Process alias arguments and forward to page call
1039
1124
  */
@@ -1052,6 +1137,8 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
1052
1137
  startSession(sessionId?: number): void;
1053
1138
  endSession(): void;
1054
1139
  getSessionId(): Nullable<number>;
1140
+ setAuthToken(token: string): void;
1141
+ consent(options?: ConsentOptions): void;
1055
1142
  }
1056
1143
  //# sourceMappingURL=RudderAnalytics.d.ts.map
1057
1144
 
@@ -1063,6 +1150,7 @@ type AppInfo = {
1063
1150
  type LibraryInfo = {
1064
1151
  readonly name: string;
1065
1152
  readonly version: string;
1153
+ readonly snippetVersion?: string;
1066
1154
  };
1067
1155
  type OSInfo = {
1068
1156
  readonly name: string;
@@ -1078,6 +1166,8 @@ type ScreenInfo = {
1078
1166
 
1079
1167
  type BufferedEvent = any[];
1080
1168
 
1169
+ type LifecycleStatus = 'mounted' | 'browserCapabilitiesReady' | 'configured' | 'pluginsLoading' | 'pluginsReady' | 'initialized' | 'loaded' | 'destinationsLoading' | 'destinationsReady' | 'ready' | 'readyExecuted';
1170
+
1081
1171
  type SessionInfo = {
1082
1172
  autoTrack?: boolean;
1083
1173
  manualTrack?: boolean;
@@ -1102,9 +1192,15 @@ type CapabilitiesState = {
1102
1192
  isAdBlocked: Signal<boolean>;
1103
1193
  };
1104
1194
  type ConsentsState = {
1105
- data: Signal<ConsentInfo>;
1195
+ enabled: Signal<boolean>;
1196
+ data: Signal<ConsentsInfo>;
1197
+ initialized: Signal<boolean>;
1106
1198
  activeConsentManagerPluginName: Signal<PluginName | undefined>;
1107
- preConsentOptions: Signal<PreConsentOptions>;
1199
+ preConsent: Signal<PreConsentOptions>;
1200
+ postConsent: Signal<ConsentOptions>;
1201
+ resolutionStrategy: Signal<ConsentResolutionStrategy | undefined>;
1202
+ provider: Signal<ConsentManagementProvider | undefined>;
1203
+ metadata: Signal<ConsentManagementMetadata | undefined>;
1108
1204
  };
1109
1205
  type ContextState = {
1110
1206
  app: Signal<AppInfo>;
@@ -1117,6 +1213,7 @@ type ContextState = {
1117
1213
  locale: Signal<Nullable<string>>;
1118
1214
  screen: Signal<ScreenInfo>;
1119
1215
  'ua-ch': Signal<UADataValues | undefined>;
1216
+ timezone: Signal<string | undefined>;
1120
1217
  };
1121
1218
  type EventBufferState = {
1122
1219
  toBeProcessedArray: Signal<BufferedEvent[]>;
@@ -1165,6 +1262,7 @@ type ReportingState = {
1165
1262
  isErrorReportingEnabled: Signal<boolean>;
1166
1263
  isMetricsReportingEnabled: Signal<boolean>;
1167
1264
  errorReportingProviderPluginName: Signal<PluginName | undefined>;
1265
+ isErrorReportingPluginLoaded: Signal<boolean>;
1168
1266
  };
1169
1267
  type SessionState = {
1170
1268
  readonly userId: Signal<Nullable<string> | undefined>;
@@ -1175,6 +1273,7 @@ type SessionState = {
1175
1273
  readonly initialReferrer: Signal<string | undefined>;
1176
1274
  readonly initialReferringDomain: Signal<string | undefined>;
1177
1275
  readonly sessionInfo: Signal<SessionInfo>;
1276
+ readonly authToken: Signal<Nullable<string>>;
1178
1277
  };
1179
1278
  type SourceConfigState = Signal<Source | undefined>;
1180
1279
  type StorageEntry = {
@@ -1182,7 +1281,7 @@ type StorageEntry = {
1182
1281
  key: string;
1183
1282
  };
1184
1283
  type StorageEntries = {
1185
- [key in UserSessionKeys]?: StorageEntry;
1284
+ [key in UserSessionKey]?: StorageEntry;
1186
1285
  };
1187
1286
  type StorageState = {
1188
1287
  encryptionPluginName: Signal<PluginName | undefined>;
@@ -1226,4 +1325,14 @@ interface IRudderStackGlobals {
1226
1325
  [key: string]: ExposedGlobals;
1227
1326
  }
1228
1327
 
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 };
1328
+ declare global {
1329
+ interface Window {
1330
+ rudderanalytics: RudderAnalytics | RudderAnalyticsPreloader | undefined;
1331
+ RudderStackGlobals: IRudderStackGlobals;
1332
+ rudderAnalyticsMount: () => void;
1333
+ rudderAnalyticsBuildType: 'legacy' | 'modern';
1334
+ }
1335
+ }
1336
+ //# sourceMappingURL=index.d.ts.map
1337
+
1338
+ export { type AnonymousIdOptions, type ApiCallback, type ApiObject, type ApiOptions, type BeaconQueueOpts, type ConsentOptions, type CookieSameSite, type DestinationsQueueOpts, type IRudderStackGlobals, type IdentifyTraits, type IntegrationOpts, type LoadOptions, type LogLevel, type PluginName, type PreloadedEventCall, type QueueOpts, type ResidencyServerRegion, RudderAnalytics, type RudderAnalyticsPreloader, type SessionOpts, type UaChTrackLevel };