@rudderstack/analytics-js 3.0.0-beta.14 → 3.0.0-beta.15

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [3.0.0-beta.15](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.0.0-beta.14...@rudderstack/analytics-js@3.0.0-beta.15) (2023-11-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * add beacon polyfill ([#1487](https://github.com/rudderlabs/rudder-sdk-js/issues/1487)) ([8053ae2](https://github.com/rudderlabs/rudder-sdk-js/commit/8053ae2ec7c5757bb65a1881ca1b79fe08c30fc7))
11
+ * buffer consent method invocations ([#1501](https://github.com/rudderlabs/rudder-sdk-js/issues/1501)) ([70f6f64](https://github.com/rudderlabs/rudder-sdk-js/commit/70f6f64500b6b08bbb657498ec0e1fdecf72b82c))
12
+ * consent api wrap up ([#1477](https://github.com/rudderlabs/rudder-sdk-js/issues/1477)) ([edc78ac](https://github.com/rudderlabs/rudder-sdk-js/commit/edc78ac54235aabfc8d1d78f961fbd650a3b7c73))
13
+ * reinitialize persistent data from consent options ([#1465](https://github.com/rudderlabs/rudder-sdk-js/issues/1465)) ([43f30b7](https://github.com/rudderlabs/rudder-sdk-js/commit/43f30b7296ae9a0862810fd0b3c520e8bddf614c))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * gcm post consent issues ([#1507](https://github.com/rudderlabs/rudder-sdk-js/issues/1507)) ([6241d3d](https://github.com/rudderlabs/rudder-sdk-js/commit/6241d3da28edc9b5f478774a763226d9d72f7dcc))
19
+ * gcm qa fixes ([#1499](https://github.com/rudderlabs/rudder-sdk-js/issues/1499)) ([84ca784](https://github.com/rudderlabs/rudder-sdk-js/commit/84ca784e6848e7fd8988c4a93db46d4636f2f89c))
20
+ * storage migration to allow empty string values ([#1488](https://github.com/rudderlabs/rudder-sdk-js/issues/1488)) ([b639fa1](https://github.com/rudderlabs/rudder-sdk-js/commit/b639fa17f22d1bbad951b293c9edba36f164163e))
21
+
5
22
  ## [3.0.0-beta.14](https://github.com/rudderlabs/rudder-sdk-js/compare/@rudderstack/analytics-js@3.0.0-beta.13...@rudderstack/analytics-js@3.0.0-beta.14) (2023-10-27)
6
23
 
7
24
 
@@ -144,11 +144,19 @@ type PluginName = 'BeaconQueue' | 'Bugsnag' | 'CustomConsentManager' | 'DeviceMo
144
144
  type OneTrustCookieCategory = {
145
145
  oneTrustCookieCategory: string;
146
146
  };
147
- type ConsentProvider = 'oneTrust' | 'ketch' | 'custom';
147
+ type ConsentManagementMetadata = {
148
+ providers: ConsentManagementProviderMetadata[];
149
+ };
150
+ type ConsentManagementProviderMetadata = {
151
+ provider: ConsentManagementProvider;
152
+ resolutionStrategy: ConsentResolutionStrategy;
153
+ };
154
+ type ConsentManagementProvider = 'oneTrust' | 'ketch' | 'custom';
155
+ type ConsentResolutionStrategy = 'and' | 'or';
148
156
  type Consents = Record<string, string> | string[];
149
157
  type ConsentManagementOptions = {
150
158
  enabled: boolean;
151
- provider: ConsentProvider;
159
+ provider: ConsentManagementProvider;
152
160
  allowedConsentIds?: Consents;
153
161
  deniedConsentIds?: Consents;
154
162
  };
@@ -160,7 +168,7 @@ type KetchConsentPurpose = {
160
168
  purpose: string;
161
169
  };
162
170
 
163
- type UserSessionKeys = 'userId' | 'userTraits' | 'anonymousId' | 'groupId' | 'groupTraits' | 'initialReferrer' | 'initialReferringDomain' | 'sessionInfo' | 'authToken';
171
+ type UserSessionKey = 'userId' | 'userTraits' | 'anonymousId' | 'groupId' | 'groupTraits' | 'initialReferrer' | 'initialReferringDomain' | 'sessionInfo' | 'authToken';
164
172
 
165
173
  type StorageEncryptionVersion = 'legacy' | 'v3';
166
174
  type StorageType = 'cookieStorage' | 'localStorage' | 'memoryStorage' | 'sessionStorage' | 'none';
@@ -176,7 +184,7 @@ type StorageOpts = {
176
184
  type?: StorageType;
177
185
  cookie?: CookieOptions;
178
186
  entries?: {
179
- [key in UserSessionKeys]?: LoadOptionStorageEntry;
187
+ [key in UserSessionKey]?: LoadOptionStorageEntry;
180
188
  };
181
189
  };
182
190
  type CookieOptions = {
@@ -264,10 +272,10 @@ type PreConsentOptions = {
264
272
  type LoadOptions = {
265
273
  logLevel?: LogLevel;
266
274
  integrations?: IntegrationOpts;
267
- configUrl: string;
275
+ configUrl?: string;
268
276
  queueOptions?: QueueOpts;
269
277
  loadIntegration?: boolean;
270
- sessions: SessionOpts;
278
+ sessions?: SessionOpts;
271
279
  secureCookie?: boolean;
272
280
  destSDKBaseURL?: string;
273
281
  pluginsSDKBaseURL?: string;
@@ -276,9 +284,9 @@ type LoadOptions = {
276
284
  destinationsQueueOptions?: DestinationsQueueOpts;
277
285
  anonymousIdOptions?: AnonymousIdOptions;
278
286
  setCookieDomain?: string;
279
- sameSiteCookie: CookieSameSite;
287
+ sameSiteCookie?: CookieSameSite;
280
288
  lockIntegrationsVersion?: boolean;
281
- polyfillIfRequired: boolean;
289
+ polyfillIfRequired?: boolean;
282
290
  onLoaded?: OnLoadedCallback;
283
291
  uaChTrackLevel?: UaChTrackLevel;
284
292
  residencyServer?: ResidencyServerRegion;
@@ -592,8 +600,6 @@ interface IHttpClient {
592
600
  resetAuthHeader(): void;
593
601
  }
594
602
 
595
- type LifecycleStatus = 'mounted' | 'browserCapabilitiesReady' | 'configured' | 'pluginsLoading' | 'pluginsReady' | 'initialized' | 'loaded' | 'destinationsLoading' | 'destinationsReady' | 'ready';
596
-
597
603
  type StoreId = string;
598
604
  interface IStoreConfig {
599
605
  name: string;
@@ -611,7 +617,7 @@ interface IStoreManager {
611
617
  errorHandler?: IErrorHandler;
612
618
  logger?: ILogger;
613
619
  init(): void;
614
- initClientDataStores(): void;
620
+ initializeStorageState(): void;
615
621
  setStore(storeConfig: IStoreConfig): IStore;
616
622
  getStore(id: StoreId): IStore | undefined;
617
623
  }
@@ -768,7 +774,7 @@ interface IUserSessionManager {
768
774
  start(sessionId?: number): void;
769
775
  end(): void;
770
776
  syncStorageDataToState(): void;
771
- setAuthToken(token: string): void;
777
+ setAuthToken(token: Nullable<string>): void;
772
778
  }
773
779
 
774
780
  type DestinationConnectionMode = 'hybrid' | 'cloud' | 'device';
@@ -785,11 +791,20 @@ type DeviceModeDestination = {
785
791
  isLoaded: () => boolean;
786
792
  isReady?: () => boolean;
787
793
  };
794
+ type ConsentsConfig = {
795
+ consent: string;
796
+ };
797
+ type ConsentManagementProviderConfig = {
798
+ provider: ConsentManagementProvider;
799
+ consents: ConsentsConfig[];
800
+ resolutionStrategy: string | undefined;
801
+ };
788
802
  type DestinationConfig = {
789
803
  blacklistedEvents: DestinationEvent[];
790
804
  whitelistedEvents: DestinationEvent[];
791
- oneTrustCookieCategories: OneTrustCookieCategory[];
792
- ketchConsentPurposes: KetchConsentPurpose[];
805
+ oneTrustCookieCategories?: OneTrustCookieCategory[];
806
+ ketchConsentPurposes?: KetchConsentPurpose[];
807
+ consentManagement?: ConsentManagementProviderConfig[];
793
808
  eventFilteringOption: EventFilteringOption;
794
809
  clickEventConversions?: Conversion[];
795
810
  pageLoadConversions?: Conversion[];
@@ -901,7 +916,6 @@ declare class BufferQueue<T = any> {
901
916
  interface IAnalytics {
902
917
  preloadBuffer: BufferQueue<PreloadedEventCall>;
903
918
  initialized: boolean;
904
- status?: LifecycleStatus;
905
919
  httpClient: IHttpClient;
906
920
  logger: ILogger;
907
921
  errorHandler: IErrorHandler;
@@ -924,7 +938,11 @@ interface IAnalytics {
924
938
  /**
925
939
  * Load browser polyfill if required
926
940
  */
927
- prepareBrowserCapabilities(): void;
941
+ onMounted(): void;
942
+ /**
943
+ * Prepare internal services and load configuration
944
+ */
945
+ onBrowserCapabilitiesReady(): void;
928
946
  /**
929
947
  * Enqueue in buffer the events that were triggered pre SDK initialization
930
948
  */
@@ -944,11 +962,11 @@ interface IAnalytics {
944
962
  /**
945
963
  * Initialize the storage and event queue
946
964
  */
947
- init(): void;
965
+ onPluginsReady(): void;
948
966
  /**
949
967
  * Load plugins
950
968
  */
951
- loadPlugins(): void;
969
+ onConfigured(): void;
952
970
  /**
953
971
  * Trigger onLoaded callback if any is provided in config & emit initialised event
954
972
  */
@@ -972,27 +990,27 @@ interface IAnalytics {
972
990
  /**
973
991
  * To register a callback for SDK ready state
974
992
  */
975
- ready(callback: ApiCallback): void;
993
+ ready(callback: ApiCallback, isBufferedInvocation?: boolean): void;
976
994
  /**
977
995
  * To record a page view event
978
996
  */
979
- page(pageOptions: PageCallOptions): void;
997
+ page(pageOptions: PageCallOptions, isBufferedInvocation?: boolean): void;
980
998
  /**
981
999
  * To record a user track event
982
1000
  */
983
- track(trackCallOptions: TrackCallOptions): void;
1001
+ track(trackCallOptions: TrackCallOptions, isBufferedInvocation?: boolean): void;
984
1002
  /**
985
1003
  * To record a user identification event
986
1004
  */
987
- identify(identifyCallOptions: IdentifyCallOptions): void;
1005
+ identify(identifyCallOptions: IdentifyCallOptions, isBufferedInvocation?: boolean): void;
988
1006
  /**
989
1007
  * To record a user alias event
990
1008
  */
991
- alias(aliasCallOptions: AliasCallOptions): void;
1009
+ alias(aliasCallOptions: AliasCallOptions, isBufferedInvocation?: boolean): void;
992
1010
  /**
993
1011
  * To record a user group event
994
1012
  */
995
- group(groupCallOptions: GroupCallOptions): void;
1013
+ group(groupCallOptions: GroupCallOptions, isBufferedInvocation?: boolean): void;
996
1014
  /**
997
1015
  * To get anonymousId set in the SDK
998
1016
  */
@@ -1000,11 +1018,11 @@ interface IAnalytics {
1000
1018
  /**
1001
1019
  * To set anonymousId
1002
1020
  */
1003
- setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string): void;
1021
+ setAnonymousId(anonymousId?: string, rudderAmpLinkerParam?: string, isBufferedInvocation?: boolean): void;
1004
1022
  /**
1005
1023
  * Clear user information, optionally anonymousId as well
1006
1024
  */
1007
- reset(resetAnonymousId?: boolean): void;
1025
+ reset(resetAnonymousId?: boolean, isBufferedInvocation?: boolean): void;
1008
1026
  /**
1009
1027
  * To get userId set in the SDK
1010
1028
  */
@@ -1024,11 +1042,11 @@ interface IAnalytics {
1024
1042
  /**
1025
1043
  * To manually start user session in the SDK
1026
1044
  */
1027
- startSession(sessionId?: number): void;
1045
+ startSession(sessionId?: number, isBufferedInvocation?: boolean): void;
1028
1046
  /**
1029
1047
  * To manually end user session in the SDK
1030
1048
  */
1031
- endSession(): void;
1049
+ endSession(isBufferedInvocation?: boolean): void;
1032
1050
  /**
1033
1051
  * To fetch the current sessionId
1034
1052
  */
@@ -1037,7 +1055,7 @@ interface IAnalytics {
1037
1055
  * To record consent
1038
1056
  * @param options Consent API options
1039
1057
  */
1040
- consent(options?: ConsentOptions): void;
1058
+ consent(options?: ConsentOptions, isBufferedInvocation?: boolean): void;
1041
1059
  /**
1042
1060
  * To set auth token
1043
1061
  */
@@ -1065,11 +1083,8 @@ declare class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
1065
1083
  */
1066
1084
  load(writeKey: string, dataPlaneUrl: string, loadOptions?: Partial<LoadOptions>): void;
1067
1085
  /**
1068
- * Get preloaded events in buffer queue if exists
1069
- */
1070
- getPreloadBuffer(): void;
1071
- /**
1072
- * Trigger load event in buffer queue if exists
1086
+ * Trigger load event in buffer queue if exists and stores the
1087
+ * remaining preloaded events array in global object
1073
1088
  */
1074
1089
  triggerBufferedLoadEvent(): void;
1075
1090
  /**
@@ -1134,6 +1149,8 @@ type ScreenInfo = {
1134
1149
 
1135
1150
  type BufferedEvent = any[];
1136
1151
 
1152
+ type LifecycleStatus = 'mounted' | 'browserCapabilitiesReady' | 'configured' | 'pluginsLoading' | 'pluginsReady' | 'initialized' | 'loaded' | 'destinationsLoading' | 'destinationsReady' | 'ready';
1153
+
1137
1154
  type SessionInfo = {
1138
1155
  autoTrack?: boolean;
1139
1156
  manualTrack?: boolean;
@@ -1164,6 +1181,9 @@ type ConsentsState = {
1164
1181
  activeConsentManagerPluginName: Signal<PluginName | undefined>;
1165
1182
  preConsent: Signal<PreConsentOptions>;
1166
1183
  postConsent: Signal<ConsentOptions>;
1184
+ resolutionStrategy: Signal<ConsentResolutionStrategy | undefined>;
1185
+ provider: Signal<ConsentManagementProvider | undefined>;
1186
+ metadata: Signal<ConsentManagementMetadata | undefined>;
1167
1187
  };
1168
1188
  type ContextState = {
1169
1189
  app: Signal<AppInfo>;
@@ -1243,7 +1263,7 @@ type StorageEntry = {
1243
1263
  key: string;
1244
1264
  };
1245
1265
  type StorageEntries = {
1246
- [key in UserSessionKeys]?: StorageEntry;
1266
+ [key in UserSessionKey]?: StorageEntry;
1247
1267
  };
1248
1268
  type StorageState = {
1249
1269
  encryptionPluginName: Signal<PluginName | undefined>;