@rudderstack/analytics-js 3.13.0 → 3.15.0

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,3 +1,5 @@
1
+ import { Event } from '@bugsnag/js';
2
+
1
3
  type LoggerProvider$1 = Record<Exclude<Lowercase<LogLevel>, Lowercase<'NONE'>>, (...data: any[]) => void>;
2
4
  interface ILogger {
3
5
  minLogLevel: number;
@@ -125,9 +127,20 @@ interface IPluginsManager {
125
127
  invokeSingle<T = any>(extPoint?: string, ...args: any[]): Nullable<T>;
126
128
  register(plugins: ExtensionPlugin[]): void;
127
129
  }
128
- type PluginName = 'BeaconQueue' | 'Bugsnag' | 'CustomConsentManager' | 'DeviceModeDestinations' | 'DeviceModeTransformation' | 'ErrorReporting' | 'ExternalAnonymousId' | 'GoogleLinker' | 'IubendaConsentManager' | 'KetchConsentManager' | 'NativeDestinationQueue' | 'OneTrustConsentManager' | 'StorageEncryption' | 'StorageEncryptionLegacy' | 'StorageMigrator' | 'XhrQueue';
130
+ type PluginName = 'BeaconQueue' | 'CustomConsentManager' | 'DeviceModeDestinations' | 'DeviceModeTransformation' | 'ExternalAnonymousId' | 'GoogleLinker' | 'IubendaConsentManager' | 'KetchConsentManager' | 'NativeDestinationQueue' | 'OneTrustConsentManager' | 'StorageEncryption' | 'StorageEncryptionLegacy' | 'StorageMigrator' | 'XhrQueue';
129
131
 
132
+ type OneTrustCookieCategory = {
133
+ oneTrustCookieCategory: string;
134
+ };
135
+ type ConsentManagementMetadata = {
136
+ providers: ConsentManagementProviderMetadata[];
137
+ };
138
+ type ConsentManagementProviderMetadata = {
139
+ provider: ConsentManagementProvider;
140
+ resolutionStrategy: ConsentResolutionStrategy;
141
+ };
130
142
  type ConsentManagementProvider = 'iubenda' | 'oneTrust' | 'ketch' | 'custom';
143
+ type ConsentResolutionStrategy = 'and' | 'or';
131
144
  type Consents = string[];
132
145
  type ConsentManagementOptions = {
133
146
  enabled?: boolean;
@@ -135,6 +148,12 @@ type ConsentManagementOptions = {
135
148
  allowedConsentIds?: Consents;
136
149
  deniedConsentIds?: Consents;
137
150
  };
151
+ type KetchConsentPurpose = {
152
+ purpose: string;
153
+ };
154
+ type IubendaConsentPurpose = {
155
+ purpose: string;
156
+ };
138
157
 
139
158
  type UserSessionKey = 'userId' | 'userTraits' | 'anonymousId' | 'groupId' | 'groupTraits' | 'initialReferrer' | 'initialReferringDomain' | 'sessionInfo' | 'authToken';
140
159
 
@@ -179,6 +198,15 @@ type SessionOpts = {
179
198
  autoTrack?: boolean;
180
199
  timeout?: number;
181
200
  };
201
+ type EventMapping = {
202
+ from: string;
203
+ to: string;
204
+ };
205
+ type Conversion = {
206
+ conversionLabel: string;
207
+ name: string;
208
+ };
209
+ type EventFilteringOption = 'disable' | 'whitelistedEvents' | 'blacklistedEvents';
182
210
  /**
183
211
  * Represents the beacon queue options parameter in loadOptions type
184
212
  */
@@ -521,61 +549,13 @@ type RudderAnalyticsPreloader = {
521
549
  [index: string]: (...args: any[]) => any;
522
550
  };
523
551
 
524
- /**
525
- * A buffer queue to serve as a store for any type of data
526
- */
527
- declare class BufferQueue<T = any> {
528
- items: T[];
529
- constructor();
530
- enqueue(item: T): void;
531
- dequeue(): Nullable<T> | undefined;
532
- isEmpty(): boolean;
533
- size(): number;
534
- clear(): void;
535
- }
536
- //# sourceMappingURL=BufferQueue.d.ts.map
537
-
538
- interface IExternalSourceLoadConfig {
539
- url: string;
540
- id: string;
541
- callback?(id?: string): unknown;
542
- async?: boolean;
543
- timeout?: number;
544
- extraAttributes?: Record<string, string>;
545
- }
546
- interface IExternalSrcLoader {
547
- errorHandler?: {
548
- onError(error: unknown, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean): void;
549
- leaveBreadcrumb(breadcrumb: string): void;
550
- notifyError(error: Error, errorState: ErrorState): void;
551
- };
552
- logger?: ILogger;
553
- timeout: number;
554
- loadJSFile(config: IExternalSourceLoadConfig): void;
555
- }
556
-
557
552
  type SDKError = unknown | Error | ErrorEvent | Event | PromiseRejectionEvent;
558
553
  interface IErrorHandler {
559
- logger?: ILogger;
560
- pluginEngine?: IPluginEngine;
561
- errorBuffer: BufferQueue<PreLoadErrorData>;
562
- init(httpClient: IHttpClient, externalSrcLoader: IExternalSrcLoader): void;
563
- onError(error: SDKError, context?: string, customMessage?: string, shouldAlwaysThrow?: boolean, errorType?: string): void;
554
+ httpClient: IHttpClient;
555
+ logger: ILogger;
556
+ onError(error: SDKError, context?: string, customMessage?: string, errorType?: string): void;
564
557
  leaveBreadcrumb(breadcrumb: string): void;
565
- notifyError(error: Error, errorState: ErrorState): void;
566
- attachErrorListeners(): void;
567
558
  }
568
- type ErrorState = {
569
- severity: string;
570
- unhandled: boolean;
571
- severityReason: {
572
- type: string;
573
- };
574
- };
575
- type PreLoadErrorData = {
576
- error: SDKError;
577
- errorState: ErrorState;
578
- };
579
559
 
580
560
  interface IRequestConfig {
581
561
  url: string;
@@ -604,9 +584,8 @@ interface IXHRRequestOptions {
604
584
  type HTTPClientMethod = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH' | 'purge' | 'PURGE' | 'link' | 'LINK' | 'unlink' | 'UNLINK';
605
585
  interface IHttpClient {
606
586
  errorHandler?: IErrorHandler;
607
- logger?: ILogger;
587
+ logger: ILogger;
608
588
  basicAuthHeader?: string;
609
- hasErrorHandler: boolean;
610
589
  getData<T = any>(config: IRequestConfig): Promise<{
611
590
  data: T | string | undefined;
612
591
  details?: ResponseDetails;
@@ -614,6 +593,22 @@ interface IHttpClient {
614
593
  getAsyncData<T = any>(config: IAsyncRequestConfig<T>): void;
615
594
  setAuthHeader(value: string, noBto?: boolean): void;
616
595
  resetAuthHeader(): void;
596
+ init(errorHandler: IErrorHandler): void;
597
+ }
598
+
599
+ interface IExternalSourceLoadConfig {
600
+ url: string;
601
+ id: string;
602
+ callback?(id?: string): unknown;
603
+ async?: boolean;
604
+ timeout?: number;
605
+ extraAttributes?: Record<string, string>;
606
+ }
607
+ interface IExternalSrcLoader {
608
+ errorHandler: IErrorHandler;
609
+ logger: ILogger;
610
+ timeout: number;
611
+ loadJSFile(config: IExternalSourceLoadConfig): void;
617
612
  }
618
613
 
619
614
  type StoreId = string;
@@ -623,15 +618,15 @@ interface IStoreConfig {
623
618
  isEncrypted?: boolean;
624
619
  validKeys?: Record<string, string>;
625
620
  noCompoundKey?: boolean;
626
- errorHandler?: IErrorHandler;
627
- logger?: ILogger;
621
+ errorHandler: IErrorHandler;
622
+ logger: ILogger;
628
623
  type?: StorageType;
629
624
  }
630
625
  interface IStoreManager {
631
626
  stores?: Record<StoreId, IStore>;
632
627
  isInitialized?: boolean;
633
- errorHandler?: IErrorHandler;
634
- logger?: ILogger;
628
+ errorHandler: IErrorHandler;
629
+ logger: ILogger;
635
630
  init(): void;
636
631
  initializeStorageState(): void;
637
632
  setStore(storeConfig: IStoreConfig): IStore;
@@ -646,9 +641,9 @@ interface IStore {
646
641
  originalEngine: IStorage;
647
642
  noKeyValidation?: boolean;
648
643
  noCompoundKey?: boolean;
649
- errorHandler?: IErrorHandler;
650
- logger?: ILogger;
651
- pluginsManager?: IPluginsManager;
644
+ errorHandler: IErrorHandler;
645
+ logger: ILogger;
646
+ pluginsManager: IPluginsManager;
652
647
  createValidKey(key: string): string | undefined;
653
648
  swapQueueStoreToInMemoryEngine(): void;
654
649
  set(key: string, value: any): void;
@@ -712,6 +707,20 @@ type GroupCallOptions = {
712
707
  callback?: ApiCallback;
713
708
  };
714
709
 
710
+ /**
711
+ * A buffer queue to serve as a store for any type of data
712
+ */
713
+ declare class BufferQueue<T = any> {
714
+ items: T[];
715
+ constructor();
716
+ enqueue(item: T): void;
717
+ dequeue(): Nullable<T> | undefined;
718
+ isEmpty(): boolean;
719
+ size(): number;
720
+ clear(): void;
721
+ }
722
+ //# sourceMappingURL=BufferQueue.d.ts.map
723
+
715
724
  /**
716
725
  * Store Implementation with dedicated storage
717
726
  */
@@ -724,11 +733,10 @@ declare class Store implements IStore {
724
733
  originalEngine: IStorage;
725
734
  noKeyValidation?: boolean;
726
735
  noCompoundKey?: boolean;
727
- errorHandler?: IErrorHandler;
728
- hasErrorHandler: boolean;
729
- logger?: ILogger;
730
- pluginsManager?: IPluginsManager;
731
- constructor(config: IStoreConfig, engine?: IStorage, pluginsManager?: IPluginsManager);
736
+ errorHandler: IErrorHandler;
737
+ logger: ILogger;
738
+ pluginsManager: IPluginsManager;
739
+ constructor(config: IStoreConfig, engine: IStorage, pluginsManager: IPluginsManager);
732
740
  /**
733
741
  * Ensure the key is valid and with correct format
734
742
  */
@@ -794,13 +802,142 @@ interface IUserSessionManager {
794
802
  setAuthToken(token: Nullable<string>): void;
795
803
  }
796
804
 
805
+ type DestinationConnectionMode = 'hybrid' | 'cloud' | 'device';
806
+ type DestinationEvent = {
807
+ eventName: string;
808
+ };
809
+ type ConsentsConfig = {
810
+ consent: string;
811
+ };
812
+ type ConsentManagementProviderConfig = {
813
+ provider: ConsentManagementProvider;
814
+ consents: ConsentsConfig[];
815
+ resolutionStrategy: string | undefined;
816
+ };
817
+ type DestinationConfig = {
818
+ blacklistedEvents: DestinationEvent[];
819
+ whitelistedEvents: DestinationEvent[];
820
+ iubendaConsentPurposes?: IubendaConsentPurpose[];
821
+ oneTrustCookieCategories?: OneTrustCookieCategory[];
822
+ ketchConsentPurposes?: KetchConsentPurpose[];
823
+ consentManagement?: ConsentManagementProviderConfig[];
824
+ eventFilteringOption: EventFilteringOption;
825
+ clickEventConversions?: Conversion[];
826
+ pageLoadConversions?: Conversion[];
827
+ conversionID?: string;
828
+ conversionLinker?: boolean;
829
+ disableAdPersonalization?: boolean;
830
+ dynamicRemarketing?: boolean;
831
+ sendPageView?: boolean;
832
+ defaultPageConversion?: string;
833
+ enableConversionEventsFiltering?: boolean;
834
+ trackConversions?: boolean;
835
+ trackDynamicRemarketing?: boolean;
836
+ tagID?: string;
837
+ advertiserId?: string;
838
+ partnerId?: string;
839
+ measurementId?: string;
840
+ capturePageView?: string;
841
+ useNativeSDKToSend?: boolean;
842
+ connectionMode?: DestinationConnectionMode;
843
+ extendPageViewParams?: boolean;
844
+ eventMappingFromConfig?: EventMapping[];
845
+ appKey?: string;
846
+ dataCenter?: string;
847
+ enableBrazeLogging?: boolean;
848
+ enableNestedArrayOperations?: boolean;
849
+ enableSubscriptionGroupInGroupCall?: boolean;
850
+ supportDedup?: boolean;
851
+ trackAnonymousUser?: boolean;
852
+ serverUrl?: string;
853
+ containerID?: string;
854
+ fs_debug_mode?: boolean;
855
+ fs_org?: boolean;
856
+ siteID?: string;
857
+ [key: string]: any;
858
+ };
859
+
860
+ type StatsCollection = {
861
+ errors: {
862
+ enabled: boolean;
863
+ provider?: string;
864
+ };
865
+ metrics: {
866
+ enabled: boolean;
867
+ };
868
+ };
869
+
870
+ type DestinationDefinition = {
871
+ name: string;
872
+ displayName: string;
873
+ updatedAt: string;
874
+ };
875
+ type ConfigResponseDestinationItem = {
876
+ shouldApplyDeviceModeTransformation: boolean;
877
+ propagateEventsUntransformedOnError: boolean;
878
+ config: DestinationConfig;
879
+ updatedAt: string;
880
+ deleted: boolean;
881
+ destinationDefinition: DestinationDefinition;
882
+ enabled: boolean;
883
+ id: string;
884
+ name: string;
885
+ };
886
+ type Connection = {
887
+ createdAt: string;
888
+ deleted: boolean;
889
+ destinationId: string;
890
+ enabled: boolean;
891
+ id: string;
892
+ sourceId: string;
893
+ updatedAt: string;
894
+ };
895
+ type SourceDefinition = {
896
+ category: Nullable<any>;
897
+ config: Nullable<any>;
898
+ configSchema: Nullable<any>;
899
+ createdAt: string;
900
+ displayName: string;
901
+ id: string;
902
+ name: string;
903
+ options: Nullable<any>;
904
+ uiConfig: Nullable<any>;
905
+ updatedAt: string;
906
+ };
907
+ type SourceConfigResponse = {
908
+ consentManagementMetadata?: ConsentManagementMetadata;
909
+ source: {
910
+ destinations: ConfigResponseDestinationItem[];
911
+ sourceDefinitionId: string;
912
+ transient: boolean;
913
+ updatedAt: string;
914
+ workspaceId: string;
915
+ writeKey: string;
916
+ enabled: boolean;
917
+ id: string;
918
+ liveEventsConfig: {
919
+ eventUpload: boolean;
920
+ eventUploadTS: number;
921
+ };
922
+ name: string;
923
+ secretVersion: Nullable<string>;
924
+ sourceDefinition: SourceDefinition;
925
+ config: {
926
+ statsCollection: StatsCollection;
927
+ };
928
+ connections: Connection[];
929
+ createdAt: string;
930
+ createdBy: string;
931
+ deleted: boolean;
932
+ };
933
+ };
797
934
  interface IConfigManager {
798
935
  httpClient: IHttpClient;
799
- errorHandler?: IErrorHandler;
800
- logger?: ILogger;
936
+ errorHandler: IErrorHandler;
937
+ logger: ILogger;
801
938
  init: () => void;
802
939
  getConfig: () => void;
803
- processConfig: () => void;
940
+ processConfig: (response: SourceConfigResponse | string | undefined, details?: ResponseDetails) => void;
804
941
  }
805
942
 
806
943
  interface IEventManager {
@@ -810,8 +947,9 @@ interface IEventManager {
810
947
  }
811
948
 
812
949
  interface ICapabilitiesManager {
813
- logger?: ILogger;
814
- errorHandler?: IErrorHandler;
950
+ httpClient: IHttpClient;
951
+ errorHandler: IErrorHandler;
952
+ logger: ILogger;
815
953
  externalSrcLoader: IExternalSrcLoader;
816
954
  init(): void;
817
955
  detectBrowserCapabilities(): void;