@mparticle/web-sdk 2.57.0 → 2.59.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.
@@ -37,8 +37,8 @@ import KitBlocker from './kitBlocking';
37
37
  import ConfigAPIClient, { IKitConfigs } from './configAPIClient';
38
38
  import IdentityAPIClient from './identityApiClient';
39
39
  import { isFunction, parseConfig, valueof, generateDeprecationMessage } from './utils';
40
- import { LocalStorageVault } from './vault';
41
- import { removeExpiredIdentityCacheDates } from './identity-utils';
40
+ import { DisabledVault, LocalStorageVault } from './vault';
41
+ import { removeExpiredIdentityCacheDates, hasExplicitIdentifier } from './identity-utils';
42
42
  import IntegrationCapture from './integrationCapture';
43
43
  import { IPreInit, processReadyQueue } from './pre-init-utils';
44
44
  import { BaseEvent, MParticleWebSDK, SDKHelpersApi } from './sdkRuntimeModels';
@@ -52,6 +52,7 @@ import ForegroundTimer from './foregroundTimeTracker';
52
52
  import RoktManager, { IRoktOptions } from './roktManager';
53
53
  import filteredMparticleUser from './filteredMparticleUser';
54
54
  import CookieConsentManager, { ICookieConsentManager } from './cookieConsentManager';
55
+ import { ReportingLogger } from './logging/reportingLogger';
55
56
 
56
57
  export interface IErrorLogMessage {
57
58
  message?: string;
@@ -84,16 +85,19 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
84
85
  _NativeSdkHelpers: INativeSdkHelpers;
85
86
  _Persistence: IPersistence;
86
87
  _CookieConsentManager: ICookieConsentManager;
88
+ _ReportingLogger: ReportingLogger;
87
89
  _RoktManager: RoktManager;
88
90
  _SessionManager: ISessionManager;
89
91
  _ServerModel: IServerModel;
90
92
  _Store: IStore;
91
93
  _instanceName: string;
92
94
  _preInit: IPreInit;
93
- _timeOnSiteTimer: ForegroundTimer;
95
+ _timeOnSiteTimer: ForegroundTimer;
94
96
  setLauncherInstanceGuid: () => void;
97
+ getLauncherInstanceGuid: () => string;
95
98
  captureTiming(metricName: string);
96
99
  processQueueOnIdentityFailure?: () => void;
100
+ processQueueOnNoFunctional?: () => void;
97
101
  }
98
102
 
99
103
  const { Messages, HTTPCodes, FeatureFlags, CaptureIntegrationSpecificIdsV2Modes } = Constants;
@@ -147,13 +151,30 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
147
151
  if (self._Store?.isInitialized) {
148
152
  return;
149
153
  }
150
-
154
+
151
155
  if (self._Store?.identityCallFailed && self._RoktManager?.isReady()) {
152
156
  self._RoktManager.processMessageQueue();
153
157
  self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
154
158
  }
155
159
  };
156
160
 
161
+ /**
162
+ * Drains the ready queue for noFunctional sessions with no explicit identity.
163
+ */
164
+ this.processQueueOnNoFunctional = function() {
165
+ if (self._Store?.isInitialized) {
166
+ return;
167
+ }
168
+
169
+ const noFunctionalWithoutId =
170
+ self._CookieConsentManager?.getNoFunctional() &&
171
+ !hasExplicitIdentifier(self._Store);
172
+
173
+ if (noFunctionalWithoutId) {
174
+ self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
175
+ }
176
+ };
177
+
157
178
  // required for forwarders once they reference the mparticle instance
158
179
  this.IdentityType = IdentityType;
159
180
  this.EventType = EventType;
@@ -245,12 +266,14 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
245
266
  }
246
267
  };
247
268
 
248
- this._resetForTests = function(config, keepPersistence, instance) {
269
+ this._resetForTests = function(config, keepPersistence, instance, reportingLogger?: ReportingLogger) {
249
270
  if (instance._Store) {
250
271
  delete instance._Store;
251
272
  }
252
- instance.Logger = new Logger(config);
273
+ instance.Logger = new Logger(config, reportingLogger);
253
274
  instance._Store = new Store(config, instance);
275
+ // Update ReportingLogger with the new Store reference to avoid stale data
276
+ reportingLogger?.setStore(instance._Store);
254
277
  instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(
255
278
  window.localStorage
256
279
  );
@@ -275,11 +298,16 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
275
298
  * @param {Function} f Callback to execute
276
299
  */
277
300
  this.ready = function(f) {
301
+ const noFunctionalWithoutId =
302
+ self._CookieConsentManager?.getNoFunctional() &&
303
+ !hasExplicitIdentifier(self._Store);
304
+
278
305
  const shouldExecute = isFunction(f) && (
279
- self._Store?.isInitialized ||
280
- (self._Store?.identityCallFailed && self._RoktManager.isReady())
306
+ self._Store?.isInitialized ||
307
+ (self._Store?.identityCallFailed && self._RoktManager.isReady()) ||
308
+ noFunctionalWithoutId
281
309
  );
282
-
310
+
283
311
  if (shouldExecute) {
284
312
  f();
285
313
  } else {
@@ -1130,11 +1158,16 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
1130
1158
  * @param {String or Number} value value for session attribute
1131
1159
  */
1132
1160
  this.setSessionAttribute = function(key, value) {
1133
- const queued = queueIfNotInitialized(function() {
1134
- self.setSessionAttribute(key, value);
1135
- }, self);
1161
+ const skipQueue =
1162
+ self._CookieConsentManager?.getNoFunctional() &&
1163
+ !hasExplicitIdentifier(self._Store);
1136
1164
 
1137
- if (queued) return;
1165
+ if (!skipQueue) {
1166
+ const queued = queueIfNotInitialized(function() {
1167
+ self.setSessionAttribute(key, value);
1168
+ }, self);
1169
+ if (queued) return;
1170
+ }
1138
1171
 
1139
1172
  // Logs to cookie
1140
1173
  // And logs to in-memory object
@@ -1372,7 +1405,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
1372
1405
  };
1373
1406
  }
1374
1407
  };
1375
-
1408
+
1376
1409
  const launcherInstanceGuidKey = Constants.Rokt.LauncherInstanceGuidKey;
1377
1410
  this.setLauncherInstanceGuid = function() {
1378
1411
  if (!window[launcherInstanceGuidKey]
@@ -1381,6 +1414,10 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
1381
1414
  }
1382
1415
  };
1383
1416
 
1417
+ this.getLauncherInstanceGuid = function() {
1418
+ return window[launcherInstanceGuidKey];
1419
+ };
1420
+
1384
1421
  this.captureTiming = function(metricsName) {
1385
1422
  if (typeof window !== 'undefined' && window.performance?.mark) {
1386
1423
  window.performance.mark(metricsName);
@@ -1446,6 +1483,8 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1446
1483
  // Configure Rokt Manager with user and filtered user
1447
1484
  const roktConfig: IKitConfigs = parseConfig(config, 'Rokt', 181);
1448
1485
  if (roktConfig) {
1486
+ const accountId = roktConfig.settings?.accountId;
1487
+ mpInstance._Store.setRoktAccountId(accountId);
1449
1488
  const { userAttributeFilters } = roktConfig;
1450
1489
  const roktFilteredUser = filteredMparticleUser(
1451
1490
  currentUserMPID,
@@ -1501,6 +1540,10 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1501
1540
  );
1502
1541
  }
1503
1542
 
1543
+ // For noFunctional sessions with no identity, drain any pre-init ready callbacks
1544
+ // that were queued before _CookieConsentManager was available to evaluate the condition.
1545
+ mpInstance.processQueueOnNoFunctional?.();
1546
+
1504
1547
  // https://go.mparticle.com/work/SQDSDKS-6040
1505
1548
  if (mpInstance._Store.isFirstRun) {
1506
1549
  mpInstance._Store.isFirstRun = false;
@@ -1573,15 +1616,30 @@ function createKitBlocker(config, mpInstance) {
1573
1616
  }
1574
1617
 
1575
1618
  function createIdentityCache(mpInstance) {
1619
+ // Identity expects mpInstance._Identity.idCache to always exist. DisabledVault
1620
+ // ensures no identity response data is written to localStorage when noFunctional is true
1621
+ if (mpInstance._CookieConsentManager?.getNoFunctional()) {
1622
+ return new DisabledVault(`${mpInstance._Store.storageName}-id-cache`, {
1623
+ logger: mpInstance.Logger,
1624
+ });
1625
+ }
1626
+
1576
1627
  return new LocalStorageVault(`${mpInstance._Store.storageName}-id-cache`, {
1577
1628
  logger: mpInstance.Logger,
1578
1629
  });
1579
1630
  }
1580
1631
 
1581
1632
  function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
1582
- mpInstance.Logger = new Logger(config);
1633
+ mpInstance._ReportingLogger = new ReportingLogger(
1634
+ config,
1635
+ Constants.sdkVersion,
1636
+ undefined,
1637
+ mpInstance.getLauncherInstanceGuid(),
1638
+ );
1639
+ mpInstance.Logger = new Logger(config, mpInstance._ReportingLogger);
1583
1640
  mpInstance._Store = new Store(config, mpInstance, apiKey);
1584
1641
  window.mParticle.Store = mpInstance._Store;
1642
+ mpInstance._ReportingLogger.setStore(mpInstance._Store);
1585
1643
  mpInstance.Logger.verbose(StartingInitialization);
1586
1644
 
1587
1645
  // Initialize CookieConsentManager with privacy flags from launcherOptions
@@ -1646,15 +1704,21 @@ function processIdentityCallback(
1646
1704
  }
1647
1705
 
1648
1706
  function queueIfNotInitialized(func, self) {
1649
- // Core SDK methods must wait for Store initialization
1650
- if (!self._Store?.isInitialized) {
1651
- self._preInit.readyQueue.push(function() {
1652
- if (self._Store?.isInitialized) {
1653
- func();
1654
- }
1655
- });
1656
- return true;
1707
+ // When noFunctional is true with no explicit identifier, the SDK will never
1708
+ // receive an MPID. Let these calls through so events can still reach forwarders immediately.
1709
+ // sendEventToServer handles queuing for the MP server upload path separately.
1710
+ const noFunctionalWithoutId =
1711
+ self._CookieConsentManager?.getNoFunctional() &&
1712
+ !hasExplicitIdentifier(self._Store);
1713
+
1714
+ if (self._Store?.isInitialized || noFunctionalWithoutId) {
1715
+ return false;
1657
1716
  }
1658
- return false;
1717
+ self._preInit.readyQueue.push(function() {
1718
+ if (self._Store?.isInitialized) {
1719
+ func();
1720
+ }
1721
+ });
1722
+ return true;
1659
1723
  }
1660
1724
 
@@ -230,6 +230,11 @@ export default function _Persistence(mpInstance) {
230
230
  return;
231
231
  }
232
232
 
233
+ // Block mprtcl-v4 localStorage when noFunctional is true
234
+ if (mpInstance._CookieConsentManager?.getNoFunctional()) {
235
+ return;
236
+ }
237
+
233
238
  var key = mpInstance._Store.storageName,
234
239
  localStorageData = self.getLocalStorage() || {},
235
240
  currentUser = mpInstance.Identity.getCurrentUser(),
@@ -398,6 +403,11 @@ export default function _Persistence(mpInstance) {
398
403
  // https://go.mparticle.com/work/SQDSDKS-5022
399
404
  // https://go.mparticle.com/work/SQDSDKS-6021
400
405
  this.setCookie = function() {
406
+ // Block mprtcl-v4 cookies when noFunctional is true
407
+ if (mpInstance._CookieConsentManager?.getNoFunctional()) {
408
+ return;
409
+ }
410
+
401
411
  var mpid,
402
412
  currentUser = mpInstance.Identity.getCurrentUser();
403
413
  if (currentUser) {
@@ -803,6 +813,11 @@ export default function _Persistence(mpInstance) {
803
813
 
804
814
  // https://go.mparticle.com/work/SQDSDKS-6021
805
815
  this.savePersistence = function(persistence) {
816
+ // Block mprtcl-v4 persistence when noFunctional is true
817
+ if (mpInstance._CookieConsentManager?.getNoFunctional()) {
818
+ return;
819
+ }
820
+
806
821
  var encodedPersistence = self.encodePersistence(
807
822
  JSON.stringify(persistence)
808
823
  ),
@@ -59,6 +59,12 @@ export interface RoktKitFilterSettings {
59
59
  filteredUser?: IMParticleUser | null;
60
60
  }
61
61
 
62
+ export interface IRoktKitSettings {
63
+ accountId?: string;
64
+ placementAttributesMapping?: string;
65
+ hashedEmailUserIdentityType?: string;
66
+ }
67
+
62
68
  export interface IRoktKit {
63
69
  filters: RoktKitFilterSettings;
64
70
  filteredUser: IMParticleUser | null;
@@ -69,6 +75,8 @@ export interface IRoktKit {
69
75
  setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
70
76
  use: <T>(name: string) => Promise<T>;
71
77
  launcherOptions?: Dictionary<any>;
78
+ settings?: IRoktKitSettings;
79
+ integrationName?: string;
72
80
  }
73
81
 
74
82
  export interface IRoktOptions {
@@ -181,6 +189,15 @@ export default class RoktManager {
181
189
 
182
190
  public attachKit(kit: IRoktKit): void {
183
191
  this.kit = kit;
192
+
193
+ if (kit.settings?.accountId) {
194
+ this.store.setRoktAccountId(kit.settings.accountId);
195
+ }
196
+
197
+ if (kit.integrationName) {
198
+ this.store?.setIntegrationName(kit.integrationName);
199
+ }
200
+
184
201
  this.processMessageQueue();
185
202
 
186
203
  try {
@@ -588,4 +605,4 @@ export default class RoktManager {
588
605
 
589
606
  return false; // Values are the same
590
607
  }
591
- }
608
+ }
@@ -7,18 +7,24 @@ import {
7
7
  SDKEventAttrs,
8
8
  Callback,
9
9
  } from '@mparticle/web-sdk';
10
- import { IntegrationAttribute, IntegrationAttributes, IStore, WrapperSDKTypes } from './store';
10
+ import {
11
+ IntegrationAttribute,
12
+ IntegrationAttributes,
13
+ IStore,
14
+ WrapperSDKTypes,
15
+ } from './store';
11
16
  import Validators from './validators';
12
17
  import { Dictionary, valueof } from './utils';
13
18
  import { IKitConfigs } from './configAPIClient';
14
19
  import { SDKConsentApi, SDKConsentState } from './consent';
15
20
  import MPSideloadedKit from './sideloadedKit';
16
21
  import { ISessionManager } from './sessionManager';
17
- import { ConfiguredKit, MPForwarder, UnregisteredKit } from './forwarders.interfaces';
18
22
  import {
19
- SDKIdentityApi,
20
- IAliasCallback,
21
- } from './identity.interfaces';
23
+ ConfiguredKit,
24
+ MPForwarder,
25
+ UnregisteredKit,
26
+ } from './forwarders.interfaces';
27
+ import { SDKIdentityApi, IAliasCallback } from './identity.interfaces';
22
28
  import {
23
29
  ISDKUserAttributeChangeData,
24
30
  ISDKUserIdentityChanges,
@@ -36,11 +42,16 @@ import {
36
42
  } from './types';
37
43
  import { IPixelConfiguration } from './cookieSyncManager';
38
44
  import _BatchValidator from './mockBatchCreator';
39
- import { SDKECommerceAPI } from './ecommerce.interfaces';
40
- import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
45
+ import { SDKECommerceAPI } from './ecommerce.interfaces';
46
+ import {
47
+ IErrorLogMessage,
48
+ IMParticleWebSDKInstance,
49
+ IntegrationDelays,
50
+ } from './mp-instance';
41
51
  import Constants from './constants';
42
52
  import RoktManager, { IRoktLauncherOptions } from './roktManager';
43
53
  import { IConsoleLogger } from './logger';
54
+ import { ErrorCodes } from './logging/types';
44
55
 
45
56
  // TODO: Resolve this with version in @mparticle/web-sdk
46
57
  export type SDKEventCustomFlags = Dictionary<any>;
@@ -83,6 +94,7 @@ export interface SDKEvent {
83
94
  ExpandedEventCount: number;
84
95
  ActiveTimeOnSite: number;
85
96
  IsBackgroundAST?: boolean;
97
+ AlreadySentToForwarders?: boolean;
86
98
  }
87
99
 
88
100
  export interface SDKGeoLocation {
@@ -178,7 +190,7 @@ export interface MParticleWebSDK {
178
190
  _resetForTests(
179
191
  MPConfig?: SDKInitConfig,
180
192
  keepPersistence?: boolean,
181
- instance?: IMParticleWebSDKInstance,
193
+ instance?: IMParticleWebSDKInstance
182
194
  ): void;
183
195
  configurePixel(config: IPixelConfiguration): void;
184
196
  endSession(): void;
@@ -207,9 +219,24 @@ export interface MParticleWebSDK {
207
219
  ): void;
208
220
  logBaseEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
209
221
  logError(error: IErrorLogMessage, attrs?: SDKEventAttrs): void;
210
- logLink(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
211
- logForm(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
212
- logPageView(eventName?: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
222
+ logLink(
223
+ selector: string,
224
+ eventName: string,
225
+ eventType: valueof<typeof EventType>,
226
+ eventInfo: SDKEventAttrs
227
+ ): void;
228
+ logForm(
229
+ selector: string,
230
+ eventName: string,
231
+ eventType: valueof<typeof EventType>,
232
+ eventInfo: SDKEventAttrs
233
+ ): void;
234
+ logPageView(
235
+ eventName?: string,
236
+ attrs?: SDKEventAttrs,
237
+ customFlags?: SDKEventCustomFlags,
238
+ eventOptions?: SDKEventOptions
239
+ ): void;
213
240
  setOptOut(isOptingOut: boolean): void;
214
241
  eCommerce: SDKECommerceAPI;
215
242
  isInitialized(): boolean;
@@ -227,7 +254,10 @@ export interface MParticleWebSDK {
227
254
 
228
255
  stopTrackingLocation(): void;
229
256
  generateHash(value: string): string;
230
- setIntegrationAttribute(integrationModuleId: number, attrs: IntegrationAttribute): void;
257
+ setIntegrationAttribute(
258
+ integrationModuleId: number,
259
+ attrs: IntegrationAttribute
260
+ ): void;
231
261
  getIntegrationAttributes(integrationModuleId: number): IntegrationAttribute;
232
262
  captureTiming(metricName: string): void;
233
263
  }
@@ -248,14 +278,13 @@ export interface IMParticleInstanceManager extends MParticleWebSDK {
248
278
  MPSideloadedKit: typeof MPSideloadedKit;
249
279
  Rokt: RoktManager;
250
280
  // https://go.mparticle.com/work/SQDSDKS-7060
251
- sessionManager: Pick<ISessionManager, 'getSession'>;
281
+ sessionManager: Pick<ISessionManager, 'getSession'>;
252
282
  Store: IStore;
253
283
 
254
284
  // Public Methods
255
285
  getInstance(instanceName?: string): IMParticleWebSDKInstance;
256
286
  }
257
287
 
258
-
259
288
  // Used in cases where server requires booleans as strings
260
289
  export type BooleanStringLowerCase = 'false' | 'true';
261
290
  export type BooleanStringTitleCase = 'False' | 'True';
@@ -311,6 +340,7 @@ export interface SDKInitConfig
311
340
  identityCallback?: IdentityCallback;
312
341
 
313
342
  launcherOptions?: IRoktLauncherOptions;
343
+ isLoggingEnabled?: boolean;
314
344
 
315
345
  rq?: Function[] | any[];
316
346
  logger?: IConsoleLogger;
@@ -361,9 +391,9 @@ export interface SDKHelpersApi {
361
391
  }
362
392
 
363
393
  export interface SDKLoggerApi {
364
- error(arg0: string): void;
365
- verbose(arg0: string): void;
366
- warning(arg0: string): void;
394
+ error(msg: string, code?: ErrorCodes): void;
395
+ verbose(msg: string): void;
396
+ warning(msg: string): void;
367
397
  setLogLevel(logLevel: LogLevelType): void;
368
398
  }
369
399
 
@@ -5,7 +5,7 @@ import Types from './types';
5
5
  import { generateDeprecationMessage } from './utils';
6
6
  import { IMParticleUser } from './identity-user-interfaces';
7
7
  import { IMParticleWebSDKInstance } from './mp-instance';
8
- import { hasIdentityRequestChanged } from './identity-utils';
8
+ import { hasIdentityRequestChanged, hasExplicitIdentifier } from './identity-utils';
9
9
 
10
10
  const { Messages } = Constants;
11
11
 
@@ -45,7 +45,12 @@ export default function SessionManager(
45
45
  const currentUser = mpInstance.Identity.getCurrentUser();
46
46
  const sdkIdentityRequest = SDKConfig.identifyRequest;
47
47
 
48
+ const shouldSuppressIdentify =
49
+ mpInstance._CookieConsentManager?.getNoFunctional() &&
50
+ !hasExplicitIdentifier(mpInstance._Store);
51
+
48
52
  if (
53
+ !shouldSuppressIdentify &&
49
54
  hasIdentityRequestChanged(currentUser, sdkIdentityRequest)
50
55
  ) {
51
56
  mpInstance.Identity.identify(
@@ -102,7 +107,11 @@ export default function SessionManager(
102
107
 
103
108
  self.setSessionTimer();
104
109
 
105
- if (!mpInstance._Store.identifyCalled) {
110
+ const shouldSuppressIdentify =
111
+ mpInstance._CookieConsentManager?.getNoFunctional() &&
112
+ !hasExplicitIdentifier(mpInstance._Store);
113
+
114
+ if (!mpInstance._Store.identifyCalled && !shouldSuppressIdentify) {
106
115
  mpInstance.Identity.identify(
107
116
  mpInstance._Store.SDKConfig.identifyRequest,
108
117
  mpInstance._Store.SDKConfig.identityCallback
package/src/store.ts CHANGED
@@ -96,6 +96,9 @@ export interface SDKConfig {
96
96
  webviewBridgeName?: string;
97
97
  workspaceToken?: string;
98
98
  requiredWebviewBridgeName?: string;
99
+ loggingUrl?: string;
100
+ errorUrl?: string;
101
+ isLoggingEnabled?: boolean;
99
102
  }
100
103
 
101
104
  function createSDKConfig(config: SDKInitConfig): SDKConfig {
@@ -120,6 +123,9 @@ function createSDKConfig(config: SDKInitConfig): SDKConfig {
120
123
  sdkConfig[prop] = Constants.DefaultBaseUrls[prop];
121
124
  }
122
125
 
126
+ // Always initialize flags to at least an empty object to prevent undefined access
127
+ sdkConfig.flags = sdkConfig.flags || {};
128
+
123
129
  return sdkConfig;
124
130
  }
125
131
 
@@ -202,6 +208,8 @@ export interface IStore {
202
208
  integrationDelayTimeoutStart: number; // UNIX Timestamp
203
209
  webviewBridgeEnabled?: boolean;
204
210
  wrapperSDKInfo: WrapperSDKInfo;
211
+ roktAccountId: string | null;
212
+ integrationName: string | null;
205
213
 
206
214
  persistenceData?: IPersistenceMinified;
207
215
 
@@ -223,6 +231,10 @@ export interface IStore {
223
231
  setUserAttributes?(mpid: MPID, attributes: UserAttributes): void;
224
232
  getUserIdentities?(mpid: MPID): UserIdentities;
225
233
  setUserIdentities?(mpid: MPID, userIdentities: UserIdentities): void;
234
+ getRoktAccountId?(): string;
235
+ setRoktAccountId?(accountId: string): void;
236
+ getIntegrationName?(): string;
237
+ setIntegrationName?(integrationName: string): void;
226
238
 
227
239
  addMpidToSessionHistory?(mpid: MPID, previousMpid?: MPID): void;
228
240
  hasInvalidIdentifyRequest?: () => boolean;
@@ -289,6 +301,8 @@ export default function Store(
289
301
  version: null,
290
302
  isInfoSet: false,
291
303
  },
304
+ roktAccountId: null,
305
+ integrationName: null,
292
306
 
293
307
  // Placeholder for in-memory persistence model
294
308
  persistenceData: {
@@ -311,10 +325,6 @@ export default function Store(
311
325
  this.SDKConfig.flags = {};
312
326
  }
313
327
 
314
- // We process the initial config that is passed via the SDK init
315
- // and then we will reprocess the config within the processConfig
316
- // function when the config is updated from the server
317
- // https://go.mparticle.com/work/SQDSDKS-6317
318
328
  this.SDKConfig.flags = processFlags(config);
319
329
 
320
330
  if (config.deviceId) {
@@ -338,10 +348,6 @@ export default function Store(
338
348
  this.SDKConfig[baseUrlKeys] = baseUrls[baseUrlKeys];
339
349
  }
340
350
 
341
- if (config.hasOwnProperty('logLevel')) {
342
- this.SDKConfig.logLevel = config.logLevel;
343
- }
344
-
345
351
  this.SDKConfig.useNativeSdk = !!config.useNativeSdk;
346
352
 
347
353
  this.SDKConfig.kits = config.kits || {};
@@ -667,6 +673,16 @@ export default function Store(
667
673
  this.setUserIdentities = (mpid: MPID, userIdentities: UserIdentities) => {
668
674
  this._setPersistence(mpid, 'ui', userIdentities);
669
675
  };
676
+
677
+ this.getRoktAccountId = () => this.roktAccountId;
678
+ this.setRoktAccountId = (accountId: string) => {
679
+ this.roktAccountId = accountId;
680
+ };
681
+
682
+ this.getIntegrationName = () => this.integrationName;
683
+ this.setIntegrationName = (integrationName: string) => {
684
+ this.integrationName = integrationName;
685
+ };
670
686
 
671
687
  this.addMpidToSessionHistory = (mpid: MPID, previousMPID?: MPID): void => {
672
688
  const indexOfMPID = this.currentSessionMPIDs.indexOf(mpid);
@@ -699,7 +715,10 @@ export default function Store(
699
715
  // We should reprocess the flags and baseUrls in case they have changed when we request an updated config
700
716
  // such as if the SDK is being self-hosted and the flags are different on the server config
701
717
  // https://go.mparticle.com/work/SQDSDKS-6317
702
- this.SDKConfig.flags = processFlags(config);
718
+ // Only update flags if the config actually has flags (don't overwrite with empty object)
719
+ if (config.flags) {
720
+ this.SDKConfig.flags = processFlags(config);
721
+ }
703
722
 
704
723
  const baseUrls: Dictionary<string> = processBaseUrls(
705
724
  config,
@@ -713,7 +732,8 @@ export default function Store(
713
732
 
714
733
  if (workspaceToken) {
715
734
  this.SDKConfig.workspaceToken = workspaceToken;
716
- mpInstance._timeOnSiteTimer = new ForegroundTimer(workspaceToken);
735
+ const noFunctional = config?.launcherOptions?.noFunctional === true;
736
+ mpInstance._timeOnSiteTimer = new ForegroundTimer(workspaceToken, noFunctional);
717
737
  } else {
718
738
  mpInstance.Logger.warning(
719
739
  'You should have a workspaceToken on your config object for security purposes.'
@@ -842,7 +862,7 @@ function processDirectBaseUrls(
842
862
  for (let baseUrlKey in defaultBaseUrls) {
843
863
  // Any custom endpoints passed to mpConfig will take priority over direct
844
864
  // mapping to the silo. The most common use case is a customer provided CNAME.
845
- if (baseUrlKey === 'configUrl') {
865
+ if (baseUrlKey === 'configUrl' || baseUrlKey === 'loggingUrl' || baseUrlKey === 'errorUrl') {
846
866
  directBaseUrls[baseUrlKey] =
847
867
  config[baseUrlKey] || defaultBaseUrls[baseUrlKey];
848
868
  continue;
package/src/uploaders.ts CHANGED
@@ -5,6 +5,7 @@ export interface IFetchPayload {
5
5
  headers: {
6
6
  Accept: string;
7
7
  'Content-Type'?: string;
8
+ 'rokt-account-id'?: string;
8
9
  };
9
10
  body?: string;
10
11
  }
package/src/vault.ts CHANGED
@@ -102,4 +102,25 @@ export class SessionStorageVault<StorableItem> extends BaseVault<StorableItem> {
102
102
  constructor(storageKey: string, options?: IVaultOptions) {
103
103
  super(storageKey, window.sessionStorage, options);
104
104
  }
105
+ }
106
+
107
+ // DisabledVault is used when persistence is disabled by privacy flags.
108
+ export class DisabledVault<StorableItem> extends BaseVault<StorableItem> {
109
+ constructor(storageKey: string, options?: IVaultOptions) {
110
+ super(storageKey, window.localStorage, options);
111
+ this.contents = null;
112
+ this.storageObject.removeItem(this._storageKey);
113
+ }
114
+
115
+ public store(_item: StorableItem): void {
116
+ this.contents = null;
117
+ }
118
+
119
+ public retrieve(): StorableItem | null {
120
+ return this.contents;
121
+ }
122
+
123
+ public purge(): void {
124
+ this.contents = null;
125
+ }
105
126
  }