@mparticle/web-sdk 2.44.0 → 2.46.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.
package/dist/mparticle.js CHANGED
@@ -203,7 +203,7 @@ var mParticle = (function () {
203
203
  Base64: Base64$1
204
204
  };
205
205
 
206
- var version = "2.44.0";
206
+ var version = "2.46.0";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -373,7 +373,15 @@ var mParticle = (function () {
373
373
  DirectUrlRouting: 'directURLRouting',
374
374
  CacheIdentity: 'cacheIdentity',
375
375
  AudienceAPI: 'audienceAPI',
376
+ // CaptureIntegrationSpecificIds (legacy): boolean flag from server/UI
377
+ // - 'True' → capture all integration-specific IDs
378
+ // - 'False' → capture none
376
379
  CaptureIntegrationSpecificIds: 'captureIntegrationSpecificIds',
380
+ // CaptureIntegrationSpecificIdsV2 (new): string mode from server
381
+ // - 'all' → capture all IDs
382
+ // - 'none' → capture none
383
+ // - 'roktonly' → capture only Rokt-related IDs
384
+ CaptureIntegrationSpecificIdsV2: 'captureIntegrationSpecificIdsV2',
377
385
  AstBackgroundEvents: 'astBackgroundEvents'
378
386
  },
379
387
  DefaultInstance: 'default_instance',
@@ -387,6 +395,11 @@ var mParticle = (function () {
387
395
  Environment: {
388
396
  Development: 'development',
389
397
  Production: 'production'
398
+ },
399
+ CaptureIntegrationSpecificIdsV2Modes: {
400
+ All: 'all',
401
+ None: 'none',
402
+ RoktOnly: 'roktonly'
390
403
  }
391
404
  };
392
405
  // https://go.mparticle.com/work/SQDSDKS-6080
@@ -1480,7 +1493,8 @@ var mParticle = (function () {
1480
1493
  })(SDKIdentityTypeEnum || (SDKIdentityTypeEnum = {}));
1481
1494
 
1482
1495
  var FeatureFlags$2 = Constants.FeatureFlags;
1483
- var CaptureIntegrationSpecificIds$1 = FeatureFlags$2.CaptureIntegrationSpecificIds;
1496
+ var CaptureIntegrationSpecificIds$1 = FeatureFlags$2.CaptureIntegrationSpecificIds,
1497
+ CaptureIntegrationSpecificIdsV2$1 = FeatureFlags$2.CaptureIntegrationSpecificIdsV2;
1484
1498
  function convertEvents(mpid, sdkEvents, mpInstance) {
1485
1499
  if (!mpid) {
1486
1500
  return null;
@@ -1547,7 +1561,10 @@ var mParticle = (function () {
1547
1561
  }
1548
1562
  };
1549
1563
  }
1550
- var isIntegrationCaptureEnabled = getFeatureFlag && Boolean(getFeatureFlag(CaptureIntegrationSpecificIds$1));
1564
+ // https://go.mparticle.com/work/SQDSDKS-7639
1565
+ var integrationSpecificIds = getFeatureFlag && Boolean(getFeatureFlag(CaptureIntegrationSpecificIds$1));
1566
+ var integrationSpecificIdsV2 = getFeatureFlag && getFeatureFlag(CaptureIntegrationSpecificIdsV2$1);
1567
+ var isIntegrationCaptureEnabled = integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None || integrationSpecificIds === true;
1551
1568
  if (isIntegrationCaptureEnabled) {
1552
1569
  var capturedPartnerIdentities = _IntegrationCapture === null || _IntegrationCapture === void 0 ? void 0 : _IntegrationCapture.getClickIdsAsPartnerIdentities();
1553
1570
  if (!isEmpty(capturedPartnerIdentities)) {
@@ -2418,8 +2435,11 @@ var mParticle = (function () {
2418
2435
  };
2419
2436
  var customFlags = __assign({}, event.CustomFlags);
2420
2437
  var integrationAttributes = _Store.integrationAttributes;
2438
+ var integrationSpecificIds = getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds);
2439
+ var integrationSpecificIdsV2 = getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2) || '';
2440
+ var isIntegrationCaptureEnabled = integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None || integrationSpecificIds === true;
2421
2441
  // https://go.mparticle.com/work/SQDSDKS-5053
2422
- if (getFeatureFlag && getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)) {
2442
+ if (isIntegrationCaptureEnabled) {
2423
2443
  // Attempt to recapture click IDs in case a third party integration
2424
2444
  // has added or updated new click IDs since the last event was sent.
2425
2445
  this.mpInstance._IntegrationCapture.capture();
@@ -4354,6 +4374,8 @@ var mParticle = (function () {
4354
4374
  var isWebviewEnabled = mpInstance._NativeSdkHelpers.isWebviewEnabled;
4355
4375
  var defaultStore = {
4356
4376
  isEnabled: true,
4377
+ noFunctional: false,
4378
+ noTargeting: false,
4357
4379
  sessionAttributes: {},
4358
4380
  localSessionAttributes: {},
4359
4381
  currentSessionMPIDs: [],
@@ -4592,6 +4614,18 @@ var mParticle = (function () {
4592
4614
  _this._setPersistence(mpid, 'con', toMinifiedJsonObject(consentState));
4593
4615
  }
4594
4616
  };
4617
+ this.getNoFunctional = function () {
4618
+ return _this.noFunctional;
4619
+ };
4620
+ this.setNoFunctional = function (noFunctional) {
4621
+ _this.noFunctional = noFunctional;
4622
+ };
4623
+ this.getNoTargeting = function () {
4624
+ return _this.noTargeting;
4625
+ };
4626
+ this.setNoTargeting = function (noTargeting) {
4627
+ _this.noTargeting = noTargeting;
4628
+ };
4595
4629
  this.getDeviceId = function () {
4596
4630
  return _this.deviceId;
4597
4631
  };
@@ -4691,6 +4725,13 @@ var mParticle = (function () {
4691
4725
  // add a new function to apply items to the store that require config to be returned
4692
4726
  _this.storageName = createMainStorageName(workspaceToken);
4693
4727
  _this.prodStorageName = createProductStorageName(workspaceToken);
4728
+ // Extract privacy flags directly from config into Store
4729
+ if (config.hasOwnProperty('noFunctional')) {
4730
+ _this.setNoFunctional(config.noFunctional);
4731
+ }
4732
+ if (config.hasOwnProperty('noTargeting')) {
4733
+ _this.setNoTargeting(config.noTargeting);
4734
+ }
4694
4735
  _this.SDKConfig.requiredWebviewBridgeName = requiredWebviewBridgeName || workspaceToken;
4695
4736
  _this.webviewBridgeEnabled = isWebviewEnabled(_this.SDKConfig.requiredWebviewBridgeName, _this.SDKConfig.minWebviewBridgeVersion);
4696
4737
  _this.configurationLoaded = true;
@@ -4707,6 +4748,7 @@ var mParticle = (function () {
4707
4748
  CacheIdentity = _a.CacheIdentity,
4708
4749
  AudienceAPI = _a.AudienceAPI,
4709
4750
  CaptureIntegrationSpecificIds = _a.CaptureIntegrationSpecificIds,
4751
+ CaptureIntegrationSpecificIdsV2 = _a.CaptureIntegrationSpecificIdsV2,
4710
4752
  AstBackgroundEvents = _a.AstBackgroundEvents;
4711
4753
  if (!config.flags) {
4712
4754
  return {};
@@ -4721,6 +4763,7 @@ var mParticle = (function () {
4721
4763
  flags[CacheIdentity] = config.flags[CacheIdentity] === 'True';
4722
4764
  flags[AudienceAPI] = config.flags[AudienceAPI] === 'True';
4723
4765
  flags[CaptureIntegrationSpecificIds] = config.flags[CaptureIntegrationSpecificIds] === 'True';
4766
+ flags[CaptureIntegrationSpecificIdsV2] = config.flags[CaptureIntegrationSpecificIdsV2] || 'none';
4724
4767
  flags[AstBackgroundEvents] = config.flags[AstBackgroundEvents] === 'True';
4725
4768
  return flags;
4726
4769
  }
@@ -6990,8 +7033,13 @@ var mParticle = (function () {
6990
7033
  if (mpInstance._Store.sessionId || event.messageType === Types.MessageType.OptOut || mpInstance._Store.webviewBridgeEnabled) {
6991
7034
  var customFlags = __assign({}, event.customFlags);
6992
7035
  var integrationAttributes = mpInstance._Store.integrationAttributes;
7036
+ var getFeatureFlag = mpInstance._Helpers.getFeatureFlag;
6993
7037
  // https://go.mparticle.com/work/SQDSDKS-5053
6994
- if (mpInstance._Helpers.getFeatureFlag && mpInstance._Helpers.getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)) {
7038
+ // https://go.mparticle.com/work/SQDSDKS-7639
7039
+ var integrationSpecificIds = getFeatureFlag && getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds);
7040
+ var integrationSpecificIdsV2 = getFeatureFlag && (getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2) || '');
7041
+ var isIntegrationCaptureEnabled = integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None || integrationSpecificIds === true;
7042
+ if (isIntegrationCaptureEnabled) {
6995
7043
  // Attempt to recapture click IDs in case a third party integration
6996
7044
  // has added or updated new click IDs since the last event was sent.
6997
7045
  mpInstance._IntegrationCapture.capture();
@@ -9513,7 +9561,7 @@ var mParticle = (function () {
9513
9561
  PARTNER_IDENTITIES: 'partner_identities',
9514
9562
  INTEGRATION_ATTRIBUTES: 'integration_attributes'
9515
9563
  };
9516
- var integrationMapping = {
9564
+ var integrationMappingExternal = {
9517
9565
  // Facebook / Meta
9518
9566
  fbclid: {
9519
9567
  mappedKey: 'Facebook.ClickId',
@@ -9541,6 +9589,23 @@ var mParticle = (function () {
9541
9589
  mappedKey: 'GoogleEnhancedConversions.Wbraid',
9542
9590
  output: IntegrationOutputs.CUSTOM_FLAGS
9543
9591
  },
9592
+ // TIKTOK
9593
+ ttclid: {
9594
+ mappedKey: 'TikTok.Callback',
9595
+ output: IntegrationOutputs.CUSTOM_FLAGS
9596
+ },
9597
+ _ttp: {
9598
+ mappedKey: 'tiktok_cookie_id',
9599
+ output: IntegrationOutputs.PARTNER_IDENTITIES
9600
+ },
9601
+ // Snapchat
9602
+ // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
9603
+ ScCid: {
9604
+ mappedKey: 'SnapchatConversions.ClickId',
9605
+ output: IntegrationOutputs.CUSTOM_FLAGS
9606
+ }
9607
+ };
9608
+ var integrationMappingRokt = {
9544
9609
  // Rokt
9545
9610
  // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
9546
9611
  // https://go.mparticle.com/work/SQDSDKS-7167
@@ -9558,26 +9623,12 @@ var mParticle = (function () {
9558
9623
  mappedKey: 'passbackconversiontrackingid',
9559
9624
  output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
9560
9625
  moduleId: 1277
9561
- },
9562
- // TIKTOK
9563
- ttclid: {
9564
- mappedKey: 'TikTok.Callback',
9565
- output: IntegrationOutputs.CUSTOM_FLAGS
9566
- },
9567
- _ttp: {
9568
- mappedKey: 'tiktok_cookie_id',
9569
- output: IntegrationOutputs.PARTNER_IDENTITIES
9570
- },
9571
- // Snapchat
9572
- // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
9573
- ScCid: {
9574
- mappedKey: 'SnapchatConversions.ClickId',
9575
- output: IntegrationOutputs.CUSTOM_FLAGS
9576
9626
  }
9577
9627
  };
9578
9628
  var IntegrationCapture = /** @class */function () {
9579
- function IntegrationCapture() {
9629
+ function IntegrationCapture(captureMode) {
9580
9630
  this.initialTimestamp = Date.now();
9631
+ this.captureMode = captureMode;
9581
9632
  // Cache filtered mappings for faster access
9582
9633
  this.filteredPartnerIdentityMappings = this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES);
9583
9634
  this.filteredCustomFlagMappings = this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS);
@@ -9622,7 +9673,8 @@ var mParticle = (function () {
9622
9673
  * Captures cookies based on the integration ID mapping.
9623
9674
  */
9624
9675
  IntegrationCapture.prototype.captureCookies = function () {
9625
- var cookies = getCookies(Object.keys(integrationMapping));
9676
+ var integrationKeys = this.getAllowedKeysForMode();
9677
+ var cookies = getCookies(integrationKeys);
9626
9678
  return this.applyProcessors(cookies, getHref(), this.initialTimestamp);
9627
9679
  };
9628
9680
  /**
@@ -9636,8 +9688,10 @@ var mParticle = (function () {
9636
9688
  * Captures local storage based on the integration ID mapping.
9637
9689
  */
9638
9690
  IntegrationCapture.prototype.captureLocalStorage = function () {
9691
+ var integrationKeys = this.getAllowedKeysForMode();
9639
9692
  var localStorageItems = {};
9640
- for (var key in integrationMapping) {
9693
+ for (var _i = 0, integrationKeys_1 = integrationKeys; _i < integrationKeys_1.length; _i++) {
9694
+ var key = integrationKeys_1[_i];
9641
9695
  var localStorageItem = localStorage.getItem(key);
9642
9696
  if (localStorageItem) {
9643
9697
  localStorageItems[key] = localStorageItem;
@@ -9650,7 +9704,8 @@ var mParticle = (function () {
9650
9704
  * @returns {Dictionary<string>} The query parameters.
9651
9705
  */
9652
9706
  IntegrationCapture.prototype.getQueryParams = function () {
9653
- return queryStringParser(getHref(), Object.keys(integrationMapping));
9707
+ var integrationKeys = this.getAllowedKeysForMode();
9708
+ return queryStringParser(getHref(), integrationKeys);
9654
9709
  };
9655
9710
  /**
9656
9711
  * Converts captured click IDs to custom flags for SDK events.
@@ -9716,10 +9771,11 @@ var mParticle = (function () {
9716
9771
  IntegrationCapture.prototype.applyProcessors = function (clickIds, url, timestamp) {
9717
9772
  var _a;
9718
9773
  var processedClickIds = {};
9774
+ var integrationKeys = this.getActiveIntegrationMapping();
9719
9775
  for (var key in clickIds) {
9720
9776
  if (clickIds.hasOwnProperty(key)) {
9721
9777
  var value = clickIds[key];
9722
- var processor = (_a = integrationMapping[key]) === null || _a === void 0 ? void 0 : _a.processor;
9778
+ var processor = (_a = integrationKeys[key]) === null || _a === void 0 ? void 0 : _a.processor;
9723
9779
  processedClickIds[key] = processor ? processor(value, url, timestamp) : value;
9724
9780
  }
9725
9781
  }
@@ -9727,13 +9783,36 @@ var mParticle = (function () {
9727
9783
  };
9728
9784
  IntegrationCapture.prototype.filterMappings = function (outputType) {
9729
9785
  var filteredMappings = {};
9730
- for (var key in integrationMapping) {
9731
- if (integrationMapping[key].output === outputType) {
9732
- filteredMappings[key] = integrationMapping[key];
9786
+ var integrationKeys = this.getActiveIntegrationMapping();
9787
+ for (var key in integrationKeys) {
9788
+ if (integrationKeys[key].output === outputType) {
9789
+ filteredMappings[key] = integrationKeys[key];
9733
9790
  }
9734
9791
  }
9735
9792
  return filteredMappings;
9736
9793
  };
9794
+ /**
9795
+ * Returns the allowed keys to capture based on the current mode.
9796
+ * For RoktOnly, limit capture to Rokt keys; for All, capture all mapped keys.
9797
+ */
9798
+ IntegrationCapture.prototype.getAllowedKeysForMode = function () {
9799
+ return Object.keys(this.getActiveIntegrationMapping());
9800
+ };
9801
+ /**
9802
+ * Selects the active integration mapping for the current captureMode.
9803
+ * - 'roktonly': only Rokt IDs are considered
9804
+ * - 'all': both External and Rokt IDs are considered
9805
+ * - else: returns an empty mapping and nothing will be captured
9806
+ */
9807
+ IntegrationCapture.prototype.getActiveIntegrationMapping = function () {
9808
+ if (this.captureMode === Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly) {
9809
+ return integrationMappingRokt;
9810
+ }
9811
+ if (this.captureMode === Constants.CaptureIntegrationSpecificIdsV2Modes.All) {
9812
+ return __assign(__assign({}, integrationMappingExternal), integrationMappingRokt);
9813
+ }
9814
+ return {};
9815
+ };
9737
9816
  return IntegrationCapture;
9738
9817
  }();
9739
9818
 
@@ -9903,6 +9982,16 @@ var mParticle = (function () {
9903
9982
  throw new Error('Error setting extension data: ' + errorMessage);
9904
9983
  }
9905
9984
  };
9985
+ RoktManager.prototype.use = function (name) {
9986
+ if (!this.isReady()) {
9987
+ return this.deferredCall('use', name);
9988
+ }
9989
+ try {
9990
+ return this.kit.use(name);
9991
+ } catch (error) {
9992
+ return Promise.reject(error instanceof Error ? error : new Error('Error using extension: ' + name));
9993
+ }
9994
+ };
9906
9995
  RoktManager.prototype.getLocalSessionAttributes = function () {
9907
9996
  return this.store.getLocalSessionAttributes();
9908
9997
  };
@@ -10001,9 +10090,11 @@ var mParticle = (function () {
10001
10090
 
10002
10091
  var Messages = Constants.Messages,
10003
10092
  HTTPCodes = Constants.HTTPCodes,
10004
- FeatureFlags = Constants.FeatureFlags;
10093
+ FeatureFlags = Constants.FeatureFlags,
10094
+ CaptureIntegrationSpecificIdsV2Modes = Constants.CaptureIntegrationSpecificIdsV2Modes;
10005
10095
  var ReportBatching = FeatureFlags.ReportBatching,
10006
- CaptureIntegrationSpecificIds = FeatureFlags.CaptureIntegrationSpecificIds;
10096
+ CaptureIntegrationSpecificIds = FeatureFlags.CaptureIntegrationSpecificIds,
10097
+ CaptureIntegrationSpecificIdsV2 = FeatureFlags.CaptureIntegrationSpecificIdsV2;
10007
10098
  var StartingInitialization = Messages.InformationMessages.StartingInitialization;
10008
10099
  /**
10009
10100
  * <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
@@ -10037,7 +10128,6 @@ var mParticle = (function () {
10037
10128
  integrationDelays: {},
10038
10129
  forwarderConstructors: []
10039
10130
  };
10040
- this._IntegrationCapture = new IntegrationCapture();
10041
10131
  this._RoktManager = new RoktManager();
10042
10132
  // required for forwarders once they reference the mparticle instance
10043
10133
  this.IdentityType = IdentityType;
@@ -10940,6 +11030,7 @@ var mParticle = (function () {
10940
11030
  // Some (server) config settings need to be returned before they are set on SDKConfig in a self hosted environment
10941
11031
  function completeSDKInitialization(apiKey, config, mpInstance) {
10942
11032
  var kitBlocker = createKitBlocker(config, mpInstance);
11033
+ var getFeatureFlag = mpInstance._Helpers.getFeatureFlag;
10943
11034
  mpInstance._APIClient = new APIClient(mpInstance, kitBlocker);
10944
11035
  mpInstance._Forwarders = new Forwarders(mpInstance, kitBlocker);
10945
11036
  mpInstance._Store.processConfig(config);
@@ -10963,10 +11054,21 @@ var mParticle = (function () {
10963
11054
  mpInstance._Store.SDKConfig.identifyRequest = mpInstance._Store.hasInvalidIdentifyRequest() ? {
10964
11055
  userIdentities: currentUserIdentities
10965
11056
  } : mpInstance._Store.SDKConfig.identifyRequest;
10966
- if (mpInstance._Helpers.getFeatureFlag(ReportBatching)) {
11057
+ if (getFeatureFlag(ReportBatching)) {
10967
11058
  mpInstance._ForwardingStatsUploader.startForwardingStatsTimer();
10968
11059
  }
10969
- if (mpInstance._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)) {
11060
+ // https://go.mparticle.com/work/SQDSDKS-7639
11061
+ var integrationSpecificIds = getFeatureFlag(CaptureIntegrationSpecificIds);
11062
+ var integrationSpecificIdsV2 = getFeatureFlag(CaptureIntegrationSpecificIdsV2);
11063
+ var isIntegrationCaptureEnabled = integrationSpecificIdsV2 && integrationSpecificIdsV2 !== CaptureIntegrationSpecificIdsV2Modes.None || integrationSpecificIds === true;
11064
+ if (isIntegrationCaptureEnabled) {
11065
+ var captureMode = void 0;
11066
+ if (integrationSpecificIds || integrationSpecificIdsV2 === CaptureIntegrationSpecificIdsV2Modes.All) {
11067
+ captureMode = 'all';
11068
+ } else if (integrationSpecificIdsV2 === CaptureIntegrationSpecificIdsV2Modes.RoktOnly) {
11069
+ captureMode = 'roktonly';
11070
+ }
11071
+ mpInstance._IntegrationCapture = new IntegrationCapture(captureMode);
10970
11072
  mpInstance._IntegrationCapture.capture();
10971
11073
  }
10972
11074
  // Configure Rokt Manager with user and filtered user
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.44.0",
3
+ "version": "2.46.0",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -173,9 +173,12 @@ export class BatchUploader {
173
173
 
174
174
  let customFlags: SDKEventCustomFlags = {...event.CustomFlags};
175
175
  let integrationAttributes: IntegrationAttributes = _Store.integrationAttributes;
176
+ const integrationSpecificIds = getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds) as boolean;
177
+ const integrationSpecificIdsV2 = getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2) as string || '';
178
+ const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
176
179
 
177
180
  // https://go.mparticle.com/work/SQDSDKS-5053
178
- if (getFeatureFlag && getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)) {
181
+ if (isIntegrationCaptureEnabled) {
179
182
 
180
183
  // Attempt to recapture click IDs in case a third party integration
181
184
  // has added or updated new click IDs since the last event was sent.
package/src/constants.ts CHANGED
@@ -184,7 +184,15 @@ const Constants = {
184
184
  DirectUrlRouting: 'directURLRouting',
185
185
  CacheIdentity: 'cacheIdentity',
186
186
  AudienceAPI: 'audienceAPI',
187
+ // CaptureIntegrationSpecificIds (legacy): boolean flag from server/UI
188
+ // - 'True' → capture all integration-specific IDs
189
+ // - 'False' → capture none
187
190
  CaptureIntegrationSpecificIds: 'captureIntegrationSpecificIds',
191
+ // CaptureIntegrationSpecificIdsV2 (new): string mode from server
192
+ // - 'all' → capture all IDs
193
+ // - 'none' → capture none
194
+ // - 'roktonly' → capture only Rokt-related IDs
195
+ CaptureIntegrationSpecificIdsV2: 'captureIntegrationSpecificIdsV2',
188
196
  AstBackgroundEvents: 'astBackgroundEvents',
189
197
  },
190
198
  DefaultInstance: 'default_instance',
@@ -200,6 +208,11 @@ const Constants = {
200
208
  Development: 'development',
201
209
  Production: 'production',
202
210
  },
211
+ CaptureIntegrationSpecificIdsV2Modes: {
212
+ All: 'all',
213
+ None: 'none',
214
+ RoktOnly: 'roktonly',
215
+ },
203
216
  } as const;
204
217
 
205
218
  export default Constants;
@@ -1,4 +1,5 @@
1
1
  import { SDKEventCustomFlags } from './sdkRuntimeModels';
2
+ import Constants from './constants';
2
3
  import { IntegrationAttributes } from './store';
3
4
  import {
4
5
  Dictionary,
@@ -73,7 +74,7 @@ interface IntegrationIdMapping {
73
74
  [key: string]: IntegrationMappingItem;
74
75
  }
75
76
 
76
- const integrationMapping: IntegrationIdMapping = {
77
+ const integrationMappingExternal: IntegrationIdMapping = {
77
78
  // Facebook / Meta
78
79
  fbclid: {
79
80
  mappedKey: 'Facebook.ClickId',
@@ -103,6 +104,25 @@ const integrationMapping: IntegrationIdMapping = {
103
104
  output: IntegrationOutputs.CUSTOM_FLAGS,
104
105
  },
105
106
 
107
+ // TIKTOK
108
+ ttclid: {
109
+ mappedKey: 'TikTok.Callback',
110
+ output: IntegrationOutputs.CUSTOM_FLAGS,
111
+ },
112
+ _ttp: {
113
+ mappedKey: 'tiktok_cookie_id',
114
+ output: IntegrationOutputs.PARTNER_IDENTITIES,
115
+ },
116
+
117
+ // Snapchat
118
+ // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
119
+ ScCid: {
120
+ mappedKey: 'SnapchatConversions.ClickId',
121
+ output: IntegrationOutputs.CUSTOM_FLAGS,
122
+ },
123
+ };
124
+
125
+ const integrationMappingRokt: IntegrationIdMapping = {
106
126
  // Rokt
107
127
  // https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
108
128
  // https://go.mparticle.com/work/SQDSDKS-7167
@@ -121,23 +141,6 @@ const integrationMapping: IntegrationIdMapping = {
121
141
  output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
122
142
  moduleId: 1277,
123
143
  },
124
-
125
- // TIKTOK
126
- ttclid: {
127
- mappedKey: 'TikTok.Callback',
128
- output: IntegrationOutputs.CUSTOM_FLAGS,
129
- },
130
- _ttp: {
131
- mappedKey: 'tiktok_cookie_id',
132
- output: IntegrationOutputs.PARTNER_IDENTITIES,
133
- },
134
-
135
- // Snapchat
136
- // https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
137
- ScCid: {
138
- mappedKey: 'SnapchatConversions.ClickId',
139
- output: IntegrationOutputs.CUSTOM_FLAGS,
140
- },
141
144
  };
142
145
 
143
146
  export default class IntegrationCapture {
@@ -146,9 +149,11 @@ export default class IntegrationCapture {
146
149
  public readonly filteredPartnerIdentityMappings: IntegrationIdMapping;
147
150
  public readonly filteredCustomFlagMappings: IntegrationIdMapping;
148
151
  public readonly filteredIntegrationAttributeMappings: IntegrationIdMapping;
152
+ public captureMode?: valueof<typeof Constants.CaptureIntegrationSpecificIdsV2Modes>;
149
153
 
150
- constructor() {
154
+ constructor(captureMode: valueof<typeof Constants.CaptureIntegrationSpecificIdsV2Modes>) {
151
155
  this.initialTimestamp = Date.now();
156
+ this.captureMode = captureMode;
152
157
 
153
158
  // Cache filtered mappings for faster access
154
159
  this.filteredPartnerIdentityMappings = this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES);
@@ -205,7 +210,8 @@ export default class IntegrationCapture {
205
210
  * Captures cookies based on the integration ID mapping.
206
211
  */
207
212
  public captureCookies(): Dictionary<string> {
208
- const cookies = getCookies(Object.keys(integrationMapping));
213
+ const integrationKeys = this.getAllowedKeysForMode();
214
+ const cookies = getCookies(integrationKeys);
209
215
  return this.applyProcessors(cookies, getHref(), this.initialTimestamp);
210
216
  }
211
217
 
@@ -221,8 +227,9 @@ export default class IntegrationCapture {
221
227
  * Captures local storage based on the integration ID mapping.
222
228
  */
223
229
  public captureLocalStorage(): Dictionary<string> {
230
+ const integrationKeys = this.getAllowedKeysForMode();
224
231
  let localStorageItems: Dictionary<string> = {};
225
- for (const key in integrationMapping) {
232
+ for (const key of integrationKeys) {
226
233
  const localStorageItem = localStorage.getItem(key);
227
234
  if (localStorageItem) {
228
235
  localStorageItems[key] = localStorageItem;
@@ -237,7 +244,8 @@ export default class IntegrationCapture {
237
244
  * @returns {Dictionary<string>} The query parameters.
238
245
  */
239
246
  public getQueryParams(): Dictionary<string> {
240
- return queryStringParser(getHref(), Object.keys(integrationMapping));
247
+ const integrationKeys = this.getAllowedKeysForMode();
248
+ return queryStringParser(getHref(), integrationKeys);
241
249
  }
242
250
 
243
251
  /**
@@ -316,15 +324,15 @@ export default class IntegrationCapture {
316
324
  timestamp?: number
317
325
  ): Dictionary<string> {
318
326
  const processedClickIds: Dictionary<string> = {};
319
-
327
+ const integrationKeys = this.getActiveIntegrationMapping();
328
+
320
329
  for (const key in clickIds) {
321
330
  if (clickIds.hasOwnProperty(key)) {
322
331
  const value = clickIds[key];
323
- const processor = integrationMapping[key]?.processor;
332
+ const processor = integrationKeys[key]?.processor;
324
333
  processedClickIds[key] = processor ? processor(value, url, timestamp) : value;
325
334
  }
326
335
  }
327
-
328
336
  return processedClickIds;
329
337
  }
330
338
 
@@ -332,11 +340,36 @@ export default class IntegrationCapture {
332
340
  outputType: valueof<typeof IntegrationOutputs>
333
341
  ): IntegrationIdMapping {
334
342
  const filteredMappings: IntegrationIdMapping = {};
335
- for (const key in integrationMapping) {
336
- if (integrationMapping[key].output === outputType) {
337
- filteredMappings[key] = integrationMapping[key];
343
+ const integrationKeys = this.getActiveIntegrationMapping();
344
+ for (const key in integrationKeys) {
345
+ if (integrationKeys[key].output === outputType) {
346
+ filteredMappings[key] = integrationKeys[key];
338
347
  }
339
348
  }
340
349
  return filteredMappings;
341
350
  }
351
+
352
+ /**
353
+ * Returns the allowed keys to capture based on the current mode.
354
+ * For RoktOnly, limit capture to Rokt keys; for All, capture all mapped keys.
355
+ */
356
+ private getAllowedKeysForMode(): string[] {
357
+ return Object.keys(this.getActiveIntegrationMapping());
358
+ }
359
+
360
+ /**
361
+ * Selects the active integration mapping for the current captureMode.
362
+ * - 'roktonly': only Rokt IDs are considered
363
+ * - 'all': both External and Rokt IDs are considered
364
+ * - else: returns an empty mapping and nothing will be captured
365
+ */
366
+ private getActiveIntegrationMapping(): IntegrationIdMapping {
367
+ if (this.captureMode === Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly) {
368
+ return integrationMappingRokt;
369
+ }
370
+ if (this.captureMode === Constants.CaptureIntegrationSpecificIdsV2Modes.All) {
371
+ return { ...integrationMappingExternal, ...integrationMappingRokt };
372
+ }
373
+ return {};
374
+ }
342
375
  }
@@ -36,7 +36,7 @@ import Consent, { IConsent } from './consent';
36
36
  import KitBlocker from './kitBlocking';
37
37
  import ConfigAPIClient, { IKitConfigs } from './configAPIClient';
38
38
  import IdentityAPIClient from './identityApiClient';
39
- import { isFunction, parseConfig } from './utils';
39
+ import { isFunction, parseConfig, valueof } from './utils';
40
40
  import { LocalStorageVault } from './vault';
41
41
  import { removeExpiredIdentityCacheDates } from './identity-utils';
42
42
  import IntegrationCapture from './integrationCapture';
@@ -91,8 +91,8 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
91
91
  _timeOnSiteTimer: ForegroundTimer;
92
92
  }
93
93
 
94
- const { Messages, HTTPCodes, FeatureFlags } = Constants;
95
- const { ReportBatching, CaptureIntegrationSpecificIds } = FeatureFlags;
94
+ const { Messages, HTTPCodes, FeatureFlags, CaptureIntegrationSpecificIdsV2Modes } = Constants;
95
+ const { ReportBatching, CaptureIntegrationSpecificIds, CaptureIntegrationSpecificIdsV2 } = FeatureFlags;
96
96
  const { StartingInitialization } = Messages.InformationMessages;
97
97
 
98
98
  /**
@@ -128,7 +128,6 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
128
128
  integrationDelays: {},
129
129
  forwarderConstructors: [],
130
130
  };
131
- this._IntegrationCapture = new IntegrationCapture();
132
131
  this._RoktManager = new RoktManager();
133
132
 
134
133
  // required for forwarders once they reference the mparticle instance
@@ -1354,6 +1353,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
1354
1353
  // Some (server) config settings need to be returned before they are set on SDKConfig in a self hosted environment
1355
1354
  function completeSDKInitialization(apiKey, config, mpInstance) {
1356
1355
  const kitBlocker = createKitBlocker(config, mpInstance);
1356
+ const { getFeatureFlag } = mpInstance._Helpers;
1357
1357
 
1358
1358
  mpInstance._APIClient = new APIClient(mpInstance, kitBlocker);
1359
1359
  mpInstance._Forwarders = new Forwarders(mpInstance, kitBlocker);
@@ -1386,11 +1386,22 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
1386
1386
  ? { userIdentities: currentUserIdentities }
1387
1387
  : mpInstance._Store.SDKConfig.identifyRequest;
1388
1388
 
1389
- if (mpInstance._Helpers.getFeatureFlag(ReportBatching)) {
1389
+ if (getFeatureFlag(ReportBatching)) {
1390
1390
  mpInstance._ForwardingStatsUploader.startForwardingStatsTimer();
1391
1391
  }
1392
-
1393
- if (mpInstance._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)) {
1392
+ // https://go.mparticle.com/work/SQDSDKS-7639
1393
+ const integrationSpecificIds = getFeatureFlag(CaptureIntegrationSpecificIds) as boolean;
1394
+ const integrationSpecificIdsV2 = getFeatureFlag(CaptureIntegrationSpecificIdsV2) as string;
1395
+
1396
+ const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
1397
+ if (isIntegrationCaptureEnabled) {
1398
+ let captureMode: valueof<typeof CaptureIntegrationSpecificIdsV2Modes> | undefined;
1399
+ if (integrationSpecificIds || integrationSpecificIdsV2 === CaptureIntegrationSpecificIdsV2Modes.All) {
1400
+ captureMode = 'all';
1401
+ } else if (integrationSpecificIdsV2 === CaptureIntegrationSpecificIdsV2Modes.RoktOnly) {
1402
+ captureMode = 'roktonly';
1403
+ }
1404
+ mpInstance._IntegrationCapture = new IntegrationCapture(captureMode);
1394
1405
  mpInstance._IntegrationCapture.capture();
1395
1406
  }
1396
1407
 
@@ -38,6 +38,7 @@ export interface IRoktSelection {
38
38
  export interface IRoktLauncher {
39
39
  selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
40
40
  hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
41
+ use: <T>(name: string) => Promise<T>;
41
42
  }
42
43
 
43
44
  export interface IRoktMessage {
@@ -62,6 +63,7 @@ export interface IRoktKit {
62
63
  hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
63
64
  selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
64
65
  setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
66
+ use: <T>(name: string) => Promise<T>;
65
67
  launcherOptions?: Dictionary<any>;
66
68
  }
67
69
 
@@ -251,6 +253,18 @@ export default class RoktManager {
251
253
  }
252
254
  }
253
255
 
256
+ public use<T>(name: string): Promise<T> {
257
+ if (!this.isReady()) {
258
+ return this.deferredCall<T>('use', name);
259
+ }
260
+
261
+ try {
262
+ return this.kit.use<T>(name);
263
+ } catch (error) {
264
+ return Promise.reject(error instanceof Error ? error : new Error('Error using extension: ' + name));
265
+ }
266
+ }
267
+
254
268
  public getLocalSessionAttributes(): LocalSessionAttributes {
255
269
  return this.store.getLocalSessionAttributes();
256
270
  }