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

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,85 +14,33 @@ 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
@@ -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,10 @@ 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;
256
248
  };
257
249
  /**
258
250
  * Represents the destinations queue options parameter in loadOptions type
@@ -261,15 +253,8 @@ type DestinationsQueueOpts = {
261
253
  maxItems?: number;
262
254
  };
263
255
  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
- }
256
+ type DeliveryType = 'immediate' | 'buffer';
257
+ type StorageStrategy = 'none' | 'session' | 'anonymousId';
273
258
  type PreConsentStorageOptions = {
274
259
  strategy: StorageStrategy;
275
260
  };
@@ -280,7 +265,6 @@ type PreConsentOptions = {
280
265
  enabled: boolean;
281
266
  storage?: PreConsentStorageOptions;
282
267
  events?: PreConsentEventsOptions;
283
- trackConsent?: boolean;
284
268
  };
285
269
  /**
286
270
  * Represents the options parameter in the load API
@@ -288,22 +272,21 @@ type PreConsentOptions = {
288
272
  type LoadOptions = {
289
273
  logLevel?: LogLevel;
290
274
  integrations?: IntegrationOpts;
291
- configUrl: string;
275
+ configUrl?: string;
292
276
  queueOptions?: QueueOpts;
293
277
  loadIntegration?: boolean;
294
- sessions: SessionOpts;
278
+ sessions?: SessionOpts;
295
279
  secureCookie?: boolean;
296
280
  destSDKBaseURL?: string;
297
281
  pluginsSDKBaseURL?: string;
298
282
  useBeacon?: boolean;
299
283
  beaconQueueOptions?: BeaconQueueOpts;
300
284
  destinationsQueueOptions?: DestinationsQueueOpts;
301
- cookieConsentManager?: CookieConsentOptions;
302
285
  anonymousIdOptions?: AnonymousIdOptions;
303
286
  setCookieDomain?: string;
304
- sameSiteCookie: CookieSameSite;
287
+ sameSiteCookie?: CookieSameSite;
305
288
  lockIntegrationsVersion?: boolean;
306
- polyfillIfRequired: boolean;
289
+ polyfillIfRequired?: boolean;
307
290
  onLoaded?: OnLoadedCallback;
308
291
  uaChTrackLevel?: UaChTrackLevel;
309
292
  residencyServer?: ResidencyServerRegion;
@@ -317,38 +300,107 @@ type LoadOptions = {
317
300
  dataPlaneEventsBufferTimeout?: number;
318
301
  storage?: StorageOpts;
319
302
  preConsent?: PreConsentOptions;
303
+ transportMode?: EventsTransportMode;
304
+ consentManagement?: ConsentManagementOptions;
305
+ sameDomainCookiesOnly?: boolean;
306
+ externalAnonymousIdCookieName?: string;
307
+ };
308
+ type ConsentOptions = {
309
+ storage?: StorageOpts;
310
+ consentManagement?: ConsentManagementOptions;
311
+ integrations?: IntegrationOpts;
312
+ discardPreConsentEvents?: boolean;
313
+ sendPageEvent?: boolean;
314
+ trackConsent?: boolean;
320
315
  };
321
316
 
322
- type LoggerProvider = Record<Exclude<Lowercase<LogLevel>, Lowercase<LogLevel.None>>, (...data: any[]) => void>;
323
-
317
+ type Address = {
318
+ city?: string;
319
+ City?: string;
320
+ country?: string;
321
+ Country?: string;
322
+ postalCode?: string;
323
+ state?: string;
324
+ State?: string;
325
+ street?: string;
326
+ };
327
+ type Company = {
328
+ name?: string;
329
+ id?: string;
330
+ industry?: string;
331
+ employee_count?: string;
332
+ plan?: string;
333
+ };
324
334
  /**
325
- * Service to log messages/data to output provider, default is console
335
+ * Represents a traits object in the Identify API
326
336
  */
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
337
+ type IdentifyTraits = {
338
+ id?: string;
339
+ userId?: string;
340
+ firstName?: string;
341
+ firstname?: string;
342
+ first_name?: string;
343
+ lastName?: string;
344
+ lastname?: string;
345
+ last_name?: string;
346
+ name?: string;
347
+ Name?: string;
348
+ age?: number;
349
+ email?: string;
350
+ Email?: string;
351
+ 'E-mail'?: string;
352
+ phone?: string;
353
+ address?: string | Address;
354
+ birthday?: string;
355
+ company?: Company;
356
+ createdAt?: string;
357
+ description?: string;
358
+ gender?: string;
359
+ title?: string;
360
+ username?: string;
361
+ website?: string;
362
+ avatar?: string;
363
+ zip?: string | number;
364
+ state?: string;
365
+ State?: string;
366
+ dob?: string;
367
+ employed?: string | boolean;
368
+ education?: string;
369
+ married?: string | boolean;
370
+ customerType?: string | number;
371
+ euConsent?: string;
372
+ euConsentMessage?: string;
373
+ newEmail?: string;
374
+ tags?: string | string[];
375
+ removeTags?: string | string[];
376
+ prospect?: string | boolean;
377
+ doubleOptin?: string | boolean;
378
+ event_id?: string;
379
+ constructor?: Record<string, string>;
380
+ organization?: string;
381
+ region?: string;
382
+ anonymous?: string | boolean;
383
+ country?: string;
384
+ custom?: string;
385
+ ip?: string;
386
+ privateAttributeNames?: any;
387
+ secondary?: any;
388
+ customPageId?: string;
389
+ isRudderEvents?: boolean;
390
+ optOutType?: boolean | string | number;
391
+ groupType?: string | number;
392
+ anonymousId?: string | number;
393
+ ip_address?: string;
394
+ number?: string | number;
395
+ [index: string]: string | number | boolean | ApiObject | null | (string | number | boolean | null | ApiObject)[] | undefined;
396
+ };
345
397
 
346
398
  type AnalyticsIdentifyMethod = {
347
- (userId?: string, traits?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
348
- (userId: string, traits: Nullable<ApiObject>, callback: ApiCallback): void;
399
+ (userId?: string, traits?: Nullable<IdentifyTraits>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
400
+ (userId: string, traits: Nullable<IdentifyTraits>, callback: ApiCallback): void;
349
401
  (userId: string, callback: ApiCallback): void;
350
- (traits: Nullable<ApiObject>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
351
- (traits: Nullable<ApiObject>, callback?: ApiCallback): void;
402
+ (traits: Nullable<IdentifyTraits>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
403
+ (traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
352
404
  };
353
405
  type AnalyticsPageMethod = {
354
406
  (category?: string, name?: string, properties?: Nullable<ApiObject>, options?: Nullable<ApiOptions>, callback?: ApiCallback): void;
@@ -467,10 +519,20 @@ interface IRudderAnalytics<T = any> {
467
519
  * To manually end user session in the SDK
468
520
  */
469
521
  endSession(): void;
522
+ /**
523
+ * To set authorization token
524
+ * @param token token value
525
+ */
526
+ setAuthToken(token: string): void;
470
527
  /**
471
528
  * To fetch the current sessionId
472
529
  */
473
530
  getSessionId(): Nullable<number>;
531
+ /**
532
+ * To provide consent
533
+ * @param options Consent API options
534
+ */
535
+ consent(options?: ConsentOptions): void;
474
536
  }
475
537
 
476
538
  interface IExternalSourceLoadConfig {
@@ -492,15 +554,42 @@ interface IExternalSrcLoader {
492
554
  loadJSFile(config: IExternalSourceLoadConfig): void;
493
555
  }
494
556
 
495
- type SDKError = unknown;
557
+ /**
558
+ * A buffer queue to serve as a store for any type of data
559
+ */
560
+ declare class BufferQueue<T = any> {
561
+ items: T[];
562
+ constructor();
563
+ enqueue(item: T): void;
564
+ dequeue(): Nullable<T> | undefined;
565
+ isEmpty(): boolean;
566
+ size(): number;
567
+ clear(): void;
568
+ }
569
+ //# sourceMappingURL=BufferQueue.d.ts.map
570
+
571
+ type SDKError = unknown | Error | ErrorEvent | Event | PromiseRejectionEvent;
496
572
  interface IErrorHandler {
497
573
  logger?: ILogger;
498
574
  pluginEngine?: IPluginEngine;
575
+ errorBuffer: BufferQueue<PreLoadErrorData>;
499
576
  init(externalSrcLoader: IExternalSrcLoader): void;
500
- onError(error: SDKError, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean): void;
577
+ onError(error: SDKError, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean, errorType?: string): void;
501
578
  leaveBreadcrumb(breadcrumb: string): void;
502
579
  notifyError(error: Error): void;
580
+ attachErrorListeners(): void;
503
581
  }
582
+ type ErrorState = {
583
+ severity: string;
584
+ unhandled: boolean;
585
+ severityReason: {
586
+ type: string;
587
+ };
588
+ };
589
+ type PreLoadErrorData = {
590
+ error: SDKError;
591
+ errorState: ErrorState;
592
+ };
504
593
 
505
594
  interface IRequestConfig {
506
595
  url: string;
@@ -539,19 +628,6 @@ interface IHttpClient {
539
628
  resetAuthHeader(): void;
540
629
  }
541
630
 
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
631
  type StoreId = string;
556
632
  interface IStoreConfig {
557
633
  name: string;
@@ -569,7 +645,7 @@ interface IStoreManager {
569
645
  errorHandler?: IErrorHandler;
570
646
  logger?: ILogger;
571
647
  init(): void;
572
- initClientDataStore(): void;
648
+ initializeStorageState(): void;
573
649
  setStore(storeConfig: IStoreConfig): IStore;
574
650
  getStore(id: StoreId): IStore | undefined;
575
651
  }
@@ -606,6 +682,7 @@ interface ICookieStorageOptions extends CookieOptions {
606
682
  domain?: string;
607
683
  secure?: boolean;
608
684
  enabled?: boolean;
685
+ sameDomainCookiesOnly?: boolean;
609
686
  }
610
687
  interface ILocalStorageOptions {
611
688
  enabled?: boolean;
@@ -629,7 +706,7 @@ type TrackCallOptions = {
629
706
  };
630
707
  type IdentifyCallOptions = {
631
708
  userId?: string | null;
632
- traits?: Nullable<ApiObject>;
709
+ traits?: Nullable<IdentifyTraits>;
633
710
  options?: Nullable<ApiOptions>;
634
711
  callback?: ApiCallback;
635
712
  };
@@ -724,13 +801,11 @@ interface IUserSessionManager {
724
801
  reset(resetAnonymousId?: boolean, noNewSessionStart?: boolean): void;
725
802
  start(sessionId?: number): void;
726
803
  end(): void;
804
+ syncStorageDataToState(): void;
805
+ setAuthToken(token: Nullable<string>): void;
727
806
  }
728
807
 
729
- declare enum DestinationConnectionMode {
730
- Hybrid = "hybrid",
731
- Cloud = "cloud",
732
- Device = "device"
733
- }
808
+ type DestinationConnectionMode = 'hybrid' | 'cloud' | 'device';
734
809
  type DestinationEvent = {
735
810
  eventName: string;
736
811
  };
@@ -744,11 +819,20 @@ type DeviceModeDestination = {
744
819
  isLoaded: () => boolean;
745
820
  isReady?: () => boolean;
746
821
  };
822
+ type ConsentsConfig = {
823
+ consent: string;
824
+ };
825
+ type ConsentManagementProviderConfig = {
826
+ provider: ConsentManagementProvider;
827
+ consents: ConsentsConfig[];
828
+ resolutionStrategy: string | undefined;
829
+ };
747
830
  type DestinationConfig = {
748
831
  blacklistedEvents: DestinationEvent[];
749
832
  whitelistedEvents: DestinationEvent[];
750
- oneTrustCookieCategories: OneTrustCookieCategory[];
751
- ketchConsentPurposes: KetchConsentPurpose[];
833
+ oneTrustCookieCategories?: OneTrustCookieCategory[];
834
+ ketchConsentPurposes?: KetchConsentPurpose[];
835
+ consentManagement?: ConsentManagementProviderConfig[];
752
836
  eventFilteringOption: EventFilteringOption;
753
837
  clickEventConversions?: Conversion[];
754
838
  pageLoadConversions?: Conversion[];
@@ -824,6 +908,7 @@ interface IConfigManager {
824
908
  interface IEventManager {
825
909
  init(): void;
826
910
  addEvent(event: APIEvent): void;
911
+ resume(): void;
827
912
  }
828
913
 
829
914
  interface ICapabilitiesManager {
@@ -838,25 +923,13 @@ interface ICapabilitiesManager {
838
923
  }
839
924
 
840
925
  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
926
+ type RudderAnalyticsPreloader = {
927
+ [index: string]: (...args: number[]) => any;
928
+ };
855
929
 
856
930
  interface IAnalytics {
857
931
  preloadBuffer: BufferQueue<PreloadedEventCall>;
858
932
  initialized: boolean;
859
- status?: LifecycleStatus;
860
933
  httpClient: IHttpClient;
861
934
  logger: ILogger;
862
935
  errorHandler: IErrorHandler;
@@ -879,7 +952,11 @@ interface IAnalytics {
879
952
  /**
880
953
  * Load browser polyfill if required
881
954
  */
882
- prepareBrowserCapabilities(): void;
955
+ onMounted(): void;
956
+ /**
957
+ * Prepare internal services and load configuration
958
+ */
959
+ onBrowserCapabilitiesReady(): void;
883
960
  /**
884
961
  * Enqueue in buffer the events that were triggered pre SDK initialization
885
962
  */
@@ -899,11 +976,11 @@ interface IAnalytics {
899
976
  /**
900
977
  * Initialize the storage and event queue
901
978
  */
902
- init(): void;
979
+ onPluginsReady(): void;
903
980
  /**
904
981
  * Load plugins
905
982
  */
906
- loadPlugins(): void;
983
+ onConfigured(): void;
907
984
  /**
908
985
  * Trigger onLoaded callback if any is provided in config & emit initialised event
909
986
  */
@@ -927,27 +1004,27 @@ interface IAnalytics {
927
1004
  /**
928
1005
  * To register a callback for SDK ready state
929
1006
  */
930
- ready(callback: ApiCallback): void;
1007
+ ready(callback: ApiCallback, isBufferedInvocation?: boolean): void;
931
1008
  /**
932
1009
  * To record a page view event
933
1010
  */
934
- page(pageOptions: PageCallOptions): void;
1011
+ page(pageOptions: PageCallOptions, isBufferedInvocation?: boolean): void;
935
1012
  /**
936
1013
  * To record a user track event
937
1014
  */
938
- track(trackCallOptions: TrackCallOptions): void;
1015
+ track(trackCallOptions: TrackCallOptions, isBufferedInvocation?: boolean): void;
939
1016
  /**
940
1017
  * To record a user identification event
941
1018
  */
942
- identify(identifyCallOptions: IdentifyCallOptions): void;
1019
+ identify(identifyCallOptions: IdentifyCallOptions, isBufferedInvocation?: boolean): void;
943
1020
  /**
944
1021
  * To record a user alias event
945
1022
  */
946
- alias(aliasCallOptions: AliasCallOptions): void;
1023
+ alias(aliasCallOptions: AliasCallOptions, isBufferedInvocation?: boolean): void;
947
1024
  /**
948
1025
  * To record a user group event
949
1026
  */
950
- group(groupCallOptions: GroupCallOptions): void;
1027
+ group(groupCallOptions: GroupCallOptions, isBufferedInvocation?: boolean): void;
951
1028
  /**
952
1029
  * To get anonymousId set in the SDK
953
1030
  */
@@ -955,11 +1032,11 @@ interface IAnalytics {
955
1032
  /**
956
1033
  * To set anonymousId
957
1034
  */
958
- setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
1035
+ setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string, isBufferedInvocation?: boolean): void;
959
1036
  /**
960
1037
  * Clear user information, optionally anonymousId as well
961
1038
  */
962
- reset(resetAnonymousId?: boolean): void;
1039
+ reset(resetAnonymousId?: boolean, isBufferedInvocation?: boolean): void;
963
1040
  /**
964
1041
  * To get userId set in the SDK
965
1042
  */
@@ -979,15 +1056,24 @@ interface IAnalytics {
979
1056
  /**
980
1057
  * To manually start user session in the SDK
981
1058
  */
982
- startSession(sessionId?: number): void;
1059
+ startSession(sessionId?: number, isBufferedInvocation?: boolean): void;
983
1060
  /**
984
1061
  * To manually end user session in the SDK
985
1062
  */
986
- endSession(): void;
1063
+ endSession(isBufferedInvocation?: boolean): void;
987
1064
  /**
988
1065
  * To fetch the current sessionId
989
1066
  */
990
1067
  getSessionId(): Nullable<number>;
1068
+ /**
1069
+ * To record consent
1070
+ * @param options Consent API options
1071
+ */
1072
+ consent(options?: ConsentOptions, isBufferedInvocation?: boolean): void;
1073
+ /**
1074
+ * To set auth token
1075
+ */
1076
+ setAuthToken(token: string): void;
991
1077
  }
992
1078
 
993
1079
  declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
@@ -1011,11 +1097,8 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
1011
1097
  */
1012
1098
  load(writeKey: string, dataPlaneUrl: string, loadOptions?: Partial<LoadOptions>): void;
1013
1099
  /**
1014
- * Get preloaded events in buffer queue if exists
1015
- */
1016
- getPreloadBuffer(): void;
1017
- /**
1018
- * Trigger load event in buffer queue if exists
1100
+ * Trigger load event in buffer queue if exists and stores the
1101
+ * remaining preloaded events array in global object
1019
1102
  */
1020
1103
  triggerBufferedLoadEvent(): void;
1021
1104
  /**
@@ -1033,7 +1116,7 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
1033
1116
  /**
1034
1117
  * Process identify arguments and forward to page call
1035
1118
  */
1036
- identify(userId?: string | number | Nullable<ApiObject>, traits?: Nullable<ApiObject> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
1119
+ identify(userId?: string | number | Nullable<IdentifyTraits>, traits?: Nullable<IdentifyTraits> | Nullable<ApiOptions> | ApiCallback, options?: Nullable<ApiOptions> | ApiCallback, callback?: ApiCallback): void;
1037
1120
  /**
1038
1121
  * Process alias arguments and forward to page call
1039
1122
  */
@@ -1052,6 +1135,8 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
1052
1135
  startSession(sessionId?: number): void;
1053
1136
  endSession(): void;
1054
1137
  getSessionId(): Nullable<number>;
1138
+ setAuthToken(token: string): void;
1139
+ consent(options?: ConsentOptions): void;
1055
1140
  }
1056
1141
  //# sourceMappingURL=RudderAnalytics.d.ts.map
1057
1142
 
@@ -1063,6 +1148,7 @@ type AppInfo = {
1063
1148
  type LibraryInfo = {
1064
1149
  readonly name: string;
1065
1150
  readonly version: string;
1151
+ readonly snippetVersion?: string;
1066
1152
  };
1067
1153
  type OSInfo = {
1068
1154
  readonly name: string;
@@ -1078,6 +1164,8 @@ type ScreenInfo = {
1078
1164
 
1079
1165
  type BufferedEvent = any[];
1080
1166
 
1167
+ type LifecycleStatus = 'mounted' | 'browserCapabilitiesReady' | 'configured' | 'pluginsLoading' | 'pluginsReady' | 'initialized' | 'loaded' | 'destinationsLoading' | 'destinationsReady' | 'ready' | 'readyExecuted';
1168
+
1081
1169
  type SessionInfo = {
1082
1170
  autoTrack?: boolean;
1083
1171
  manualTrack?: boolean;
@@ -1102,9 +1190,15 @@ type CapabilitiesState = {
1102
1190
  isAdBlocked: Signal<boolean>;
1103
1191
  };
1104
1192
  type ConsentsState = {
1105
- data: Signal<ConsentInfo>;
1193
+ enabled: Signal<boolean>;
1194
+ data: Signal<ConsentsInfo>;
1195
+ initialized: Signal<boolean>;
1106
1196
  activeConsentManagerPluginName: Signal<PluginName | undefined>;
1107
- preConsentOptions: Signal<PreConsentOptions>;
1197
+ preConsent: Signal<PreConsentOptions>;
1198
+ postConsent: Signal<ConsentOptions>;
1199
+ resolutionStrategy: Signal<ConsentResolutionStrategy | undefined>;
1200
+ provider: Signal<ConsentManagementProvider | undefined>;
1201
+ metadata: Signal<ConsentManagementMetadata | undefined>;
1108
1202
  };
1109
1203
  type ContextState = {
1110
1204
  app: Signal<AppInfo>;
@@ -1117,6 +1211,7 @@ type ContextState = {
1117
1211
  locale: Signal<Nullable<string>>;
1118
1212
  screen: Signal<ScreenInfo>;
1119
1213
  'ua-ch': Signal<UADataValues | undefined>;
1214
+ timezone: Signal<string | undefined>;
1120
1215
  };
1121
1216
  type EventBufferState = {
1122
1217
  toBeProcessedArray: Signal<BufferedEvent[]>;
@@ -1165,6 +1260,7 @@ type ReportingState = {
1165
1260
  isErrorReportingEnabled: Signal<boolean>;
1166
1261
  isMetricsReportingEnabled: Signal<boolean>;
1167
1262
  errorReportingProviderPluginName: Signal<PluginName | undefined>;
1263
+ isErrorReportingPluginLoaded: Signal<boolean>;
1168
1264
  };
1169
1265
  type SessionState = {
1170
1266
  readonly userId: Signal<Nullable<string> | undefined>;
@@ -1175,6 +1271,7 @@ type SessionState = {
1175
1271
  readonly initialReferrer: Signal<string | undefined>;
1176
1272
  readonly initialReferringDomain: Signal<string | undefined>;
1177
1273
  readonly sessionInfo: Signal<SessionInfo>;
1274
+ readonly authToken: Signal<Nullable<string>>;
1178
1275
  };
1179
1276
  type SourceConfigState = Signal<Source | undefined>;
1180
1277
  type StorageEntry = {
@@ -1182,7 +1279,7 @@ type StorageEntry = {
1182
1279
  key: string;
1183
1280
  };
1184
1281
  type StorageEntries = {
1185
- [key in UserSessionKeys]?: StorageEntry;
1282
+ [key in UserSessionKey]?: StorageEntry;
1186
1283
  };
1187
1284
  type StorageState = {
1188
1285
  encryptionPluginName: Signal<PluginName | undefined>;
@@ -1226,4 +1323,14 @@ interface IRudderStackGlobals {
1226
1323
  [key: string]: ExposedGlobals;
1227
1324
  }
1228
1325
 
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 };
1326
+ declare global {
1327
+ interface Window {
1328
+ rudderanalytics: RudderAnalytics | PreloadedEventCall[] | RudderAnalyticsPreloader;
1329
+ RudderStackGlobals: IRudderStackGlobals;
1330
+ rudderAnalyticsMount: () => void;
1331
+ rudderAnalyticsBuildType: 'legacy' | 'modern';
1332
+ }
1333
+ }
1334
+ //# sourceMappingURL=index.d.ts.map
1335
+
1336
+ 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 };