@kameleoon/javascript-sdk-core 5.17.3 → 5.18.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.
@@ -3364,6 +3364,7 @@ class Parser {
3364
3364
  }
3365
3365
  }
3366
3366
 
3367
+ var _a;
3367
3368
  class ClientSettings {
3368
3369
  constructor(siteCode, configuration) {
3369
3370
  KameleoonLogger.debug `CALL: new ClientSettings(siteCode: ${siteCode}, configuration: ${configuration})`;
@@ -3378,18 +3379,19 @@ class ClientSettings {
3378
3379
  KameleoonLogger.debug `RETURN: new ClientSettings(siteCode: ${siteCode}, configuration: ${configuration})`;
3379
3380
  }
3380
3381
  getTrackingInterval(configuration) {
3382
+ const { MIN_TRACKING_INTERVAL_MS, MAX_TRACKING_INTERVAL_MS, DEFAULT_TRACKING_INTERVAL_MS, } = ClientSettings;
3381
3383
  if (typeof (configuration === null || configuration === void 0 ? void 0 : configuration.trackingInterval) === 'number') {
3382
- if (configuration.trackingInterval < 100) {
3383
- KameleoonLogger.warning('Tracking interval must not be shorter than 100 ms. Minimum possible interval was applied.');
3384
- return 100;
3384
+ if (configuration.trackingInterval < MIN_TRACKING_INTERVAL_MS) {
3385
+ KameleoonLogger.warning(`Tracking interval must not be shorter than ${MIN_TRACKING_INTERVAL_MS} ms. Minimum possible interval was applied.`);
3386
+ return MIN_TRACKING_INTERVAL_MS;
3385
3387
  }
3386
- if (configuration.trackingInterval > 1000) {
3387
- KameleoonLogger.warning('Tracking interval must not be longer than 1000 ms. Maximum possible interval was applied.');
3388
- return 1000;
3388
+ if (configuration.trackingInterval > MAX_TRACKING_INTERVAL_MS) {
3389
+ KameleoonLogger.warning(`Tracking interval must not be longer than ${MAX_TRACKING_INTERVAL_MS} ms. Maximum possible interval was applied.`);
3390
+ return MAX_TRACKING_INTERVAL_MS;
3389
3391
  }
3390
3392
  return configuration.trackingInterval;
3391
3393
  }
3392
- return 1000;
3394
+ return DEFAULT_TRACKING_INTERVAL_MS;
3393
3395
  }
3394
3396
  getEnvironment(configuration) {
3395
3397
  if (configuration === null || configuration === void 0 ? void 0 : configuration.environment) {
@@ -3443,6 +3445,10 @@ class ClientSettings {
3443
3445
  };
3444
3446
  }
3445
3447
  }
3448
+ _a = ClientSettings;
3449
+ ClientSettings.DEFAULT_TRACKING_INTERVAL_MS = 1000;
3450
+ ClientSettings.MIN_TRACKING_INTERVAL_MS = _a.DEFAULT_TRACKING_INTERVAL_MS;
3451
+ ClientSettings.MAX_TRACKING_INTERVAL_MS = 5000;
3446
3452
 
3447
3453
  /**
3448
3454
  * @class
@@ -5437,7 +5443,6 @@ class StorageCleanupManager {
5437
5443
  break;
5438
5444
  default:
5439
5445
  // check if all cases are handled
5440
- const exhaustiveCheck = storageKey;
5441
5446
  KameleoonLogger.error `Unknown storage key: ${storageKey} for initCleanupInterval.`;
5442
5447
  }
5443
5448
  }
@@ -5732,7 +5737,7 @@ class DataManager {
5732
5737
  return resultData;
5733
5738
  }
5734
5739
  storeTrackedData(data) {
5735
- this.storeData(data, false);
5740
+ this.storeDataForVisitors(data, false);
5736
5741
  const infoResult = this.infoStorage.read();
5737
5742
  if (!infoResult.ok) {
5738
5743
  return;
@@ -5766,30 +5771,31 @@ class DataManager {
5766
5771
  }
5767
5772
  this.infoStorage.write(infoResult.data);
5768
5773
  }
5769
- storeData(firstParameter, ...secondParameter) {
5770
- KameleoonLogger.debug `CALL: DataManager.storeData(visitorCode: ${firstParameter}, data: ${secondParameter})`;
5771
- const result = this.dataStorage.read();
5772
- const infoResult = this.infoStorage.read();
5773
- if (!result.ok) {
5774
- return result;
5775
- }
5776
- if (!infoResult.ok) {
5777
- return infoResult;
5778
- }
5779
- const targetingData = result.data;
5780
- const infoData = infoResult.data;
5781
- if (typeof firstParameter === 'string') {
5774
+ /**
5775
+ * Store data for a single visitor
5776
+ */
5777
+ storeData({ visitorCode, data, track, }) {
5778
+ KameleoonLogger.debug `CALL: DataManager.storeDataForVisitor(vc: ${visitorCode}, track: ${track}, data: ${data})`;
5779
+ const result = this.storeDataInternal((infoData, targetingData) => {
5782
5780
  this.mutUpdateTargetingData({
5783
5781
  infoData,
5784
5782
  targetingData,
5785
- visitorCode: firstParameter,
5786
- kameleoonData: secondParameter,
5783
+ visitorCode,
5784
+ kameleoonData: data,
5787
5785
  extendTtl: true,
5786
+ track,
5788
5787
  });
5789
- }
5790
- else {
5791
- for (const [visitorCode, kameleoonData] of Object.entries(firstParameter)) {
5792
- const extendTtl = typeof secondParameter[0] === 'boolean' ? secondParameter[0] : true;
5788
+ });
5789
+ KameleoonLogger.debug `RETURN: DataManager.storeDataForVisitor(vc: ${visitorCode}, track: ${track}, data: ${data}) -> ${result}`;
5790
+ return result;
5791
+ }
5792
+ /**
5793
+ * Store data for multiple visitors
5794
+ */
5795
+ storeDataForVisitors(data, extendTtl) {
5796
+ KameleoonLogger.debug `CALL: DataManager.storeDataForVisitors(data: ${data}, extendTtl: ${extendTtl})`;
5797
+ const result = this.storeDataInternal((infoData, targetingData) => {
5798
+ for (const [visitorCode, kameleoonData] of Object.entries(data)) {
5793
5799
  this.mutUpdateTargetingData({
5794
5800
  infoData,
5795
5801
  targetingData,
@@ -5798,12 +5804,26 @@ class DataManager {
5798
5804
  extendTtl,
5799
5805
  });
5800
5806
  }
5807
+ });
5808
+ KameleoonLogger.debug `RETURN: DataManager.storeDataForVisitors(data: ${data}, extendTtl: ${extendTtl}) -> ${result}`;
5809
+ return result;
5810
+ }
5811
+ // ========= Internal shared logic =========
5812
+ storeDataInternal(updater) {
5813
+ const dataResult = this.dataStorage.read();
5814
+ if (!dataResult.ok) {
5815
+ return dataResult;
5801
5816
  }
5817
+ const infoResult = this.infoStorage.read();
5818
+ if (!infoResult.ok) {
5819
+ return infoResult;
5820
+ }
5821
+ const targetingData = dataResult.data;
5822
+ const infoData = infoResult.data;
5823
+ updater(infoData, targetingData);
5802
5824
  this.cleanupData();
5803
- this.infoStorage.write(infoResult.data);
5804
- const writeResult = this.dataStorage.write(targetingData);
5805
- KameleoonLogger.debug `RETURN: DataManager.storeData(visitorCode: ${firstParameter}, data: ${secondParameter}) -> (writeResult: ${writeResult})`;
5806
- return writeResult;
5825
+ this.infoStorage.write(infoData);
5826
+ return this.dataStorage.write(targetingData);
5807
5827
  }
5808
5828
  getTree(segment) {
5809
5829
  if (this.targetingTrees.has(segment.id)) {
@@ -5892,29 +5912,31 @@ class DataManager {
5892
5912
  return new Set(Object.keys(targetingData));
5893
5913
  }
5894
5914
  getLinkedVisitor(visitorCode) {
5915
+ var _a, _b, _c;
5895
5916
  const storageData = this.dataStorage.read();
5896
5917
  if (!storageData.ok) {
5897
5918
  return null;
5898
5919
  }
5899
- if (typeof storageData.data[visitorCode] === 'string') {
5900
- return storageData.data[visitorCode];
5920
+ const visitorDataOrRef = storageData.data[visitorCode];
5921
+ // Direct reference case
5922
+ if (typeof visitorDataOrRef === 'string') {
5923
+ return visitorDataOrRef;
5901
5924
  }
5902
- if (this.mappingIdentifierCustomDataIndex === null) {
5925
+ // No mapping index or no visitor data
5926
+ if (visitorDataOrRef == null ||
5927
+ this.mappingIdentifierCustomDataIndex == null) {
5903
5928
  return null;
5904
5929
  }
5905
- const visitorData = storageData.data[visitorCode];
5906
- if (!visitorData) {
5907
- return null;
5908
- }
5909
- const customData = visitorData[KameleoonData.CustomData];
5910
- if (customData && customData[this.mappingIdentifierCustomDataIndex]) {
5911
- return customData[this.mappingIdentifierCustomDataIndex].value[0];
5912
- }
5913
- return null;
5930
+ const value = (_c = (_b = (_a = visitorDataOrRef[KameleoonData.CustomData]) === null || _a === void 0 ? void 0 : _a[this.mappingIdentifierCustomDataIndex]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c[0];
5931
+ return value !== null && value !== void 0 ? value : null;
5914
5932
  }
5915
- mutUpdateTargetingData({ infoData, visitorCode, kameleoonData, targetingData, extendTtl, }) {
5933
+ mutUpdateTargetingData({ infoData, visitorCode, kameleoonData, targetingData, extendTtl, track, }) {
5916
5934
  var _a, _b, _c;
5917
5935
  for (const dataItem of kameleoonData) {
5936
+ // prcoess track status
5937
+ if (track === false) {
5938
+ dataItem.status = TrackingStatus.Sent;
5939
+ }
5918
5940
  // process custom data
5919
5941
  if (dataItem.data.type === KameleoonData.CustomData) {
5920
5942
  const customDataIsValid = this.processCustomData({
@@ -6072,6 +6094,135 @@ class DataManager {
6072
6094
  }
6073
6095
  }
6074
6096
 
6097
+ const VISITOR_CODE_LENGTH = 16;
6098
+ const VISITOR_CODE_MAX_LENGTH = 255;
6099
+ const DEFAULT_MAX_AGE = 60 * 60 * 24 * 365;
6100
+ const PATH = '/';
6101
+
6102
+ /**
6103
+ * VisitorCodeManager - a class which manages visitor codes using cookies, offering functions to generate, retrieve,
6104
+ * and handle these codes while considering user consent.
6105
+ **/
6106
+ class VisitorCodeManager {
6107
+ constructor() {
6108
+ this.isConsentRequired = false;
6109
+ }
6110
+ set consentRequired(isRequired) {
6111
+ this.isConsentRequired = isRequired;
6112
+ }
6113
+ get consentRequired() {
6114
+ return this.isConsentRequired;
6115
+ }
6116
+ set getData(callback) {
6117
+ this.getDataCallback = callback;
6118
+ }
6119
+ set setData(callback) {
6120
+ this.setDataCallback = callback;
6121
+ }
6122
+ get setData() {
6123
+ if (this.setDataCallback) {
6124
+ return this.setDataCallback;
6125
+ }
6126
+ throw new Error('Missing setDataCallback!');
6127
+ }
6128
+ validateVisitorCode(visitorCode) {
6129
+ if (visitorCode.length === 0) {
6130
+ return buildExports.Err(new KameleoonError(KameleoonException.VisitorCodeEmpty));
6131
+ }
6132
+ if (visitorCode.length > VISITOR_CODE_MAX_LENGTH) {
6133
+ return buildExports.Err(new KameleoonError(KameleoonException.VisitorCodeMaxLength));
6134
+ }
6135
+ return buildExports.Ok();
6136
+ }
6137
+ getVisitorCode(defaultVisitorCode) {
6138
+ KameleoonLogger.debug `CALL: VisitorCodeManager.getVisitorCode(defaultVisitorCode: ${defaultVisitorCode})`;
6139
+ if (!this.getDataCallback || !this.setDataCallback) {
6140
+ throw new Error('Missing getDataCallback or setDataCallback methods in getVisitorCode!');
6141
+ }
6142
+ let visitorCode;
6143
+ const existingVisitorCode = this.getDataCallback(KameleoonStorageKey.VisitorCode);
6144
+ if (existingVisitorCode) {
6145
+ visitorCode = existingVisitorCode;
6146
+ }
6147
+ if (!visitorCode) {
6148
+ if (defaultVisitorCode) {
6149
+ this.validateVisitorCode(defaultVisitorCode).throw();
6150
+ visitorCode = defaultVisitorCode;
6151
+ KameleoonLogger.debug `Used default visitor code: ${visitorCode}`;
6152
+ }
6153
+ else {
6154
+ visitorCode = this.generateVisitorCode();
6155
+ KameleoonLogger.debug `Generated new visitor code: ${visitorCode}`;
6156
+ }
6157
+ }
6158
+ this.processSimulatedVariations(visitorCode);
6159
+ if (!this.isConsentRequired) {
6160
+ this.setDataCallback({
6161
+ visitorCode,
6162
+ key: KameleoonStorageKey.VisitorCode,
6163
+ maxAge: DEFAULT_MAX_AGE,
6164
+ path: PATH,
6165
+ });
6166
+ }
6167
+ KameleoonLogger.debug `RETURN: VisitorCodeManager.getVisitorCode(defaultVisitorCode: ${defaultVisitorCode}) -> (visitorCode: ${visitorCode})`;
6168
+ return visitorCode;
6169
+ }
6170
+ processSimulatedVariations(visitorCode) {
6171
+ if (this.variationConfiguration) {
6172
+ const simulatedVariationsData = this.getSimulatedVariations(visitorCode);
6173
+ try {
6174
+ this.variationConfiguration.clearSimulatedVariations(visitorCode).throw();
6175
+ if (simulatedVariationsData !== null && simulatedVariationsData.length > 0) {
6176
+ this.variationConfiguration.updateForcedFeatureVariations(visitorCode, simulatedVariationsData).throw();
6177
+ }
6178
+ }
6179
+ catch (error) {
6180
+ if (error instanceof Error) {
6181
+ KameleoonLogger.error `Failed to process simulated variations: ${error.message}`;
6182
+ }
6183
+ }
6184
+ }
6185
+ }
6186
+ getSimulatedVariations(visitorCode) {
6187
+ KameleoonLogger.debug `CALL: VisitorCodeManager.getSimulatedVariations(visitorCode: ${visitorCode})`;
6188
+ const simulatedVariationsData = this.getDataCallback(KameleoonStorageKey.KameleoonSimulationFFData);
6189
+ let variations = null;
6190
+ if (typeof simulatedVariationsData === 'string' &&
6191
+ simulatedVariationsData.length > 0) {
6192
+ try {
6193
+ const parsed = JSON.parse(decodeURIComponent(simulatedVariationsData));
6194
+ if (parsed && typeof parsed === 'object') {
6195
+ variations = Object.entries(parsed)
6196
+ .map(([key, value]) => {
6197
+ return this.variationConfiguration.simulatedVariationFromJson(key, value);
6198
+ })
6199
+ .filter((variation) => variation !== null);
6200
+ }
6201
+ }
6202
+ catch (error) {
6203
+ if (error instanceof Error) {
6204
+ KameleoonLogger.error `Failed to parse simulated variations: ${error.message}`;
6205
+ }
6206
+ }
6207
+ }
6208
+ KameleoonLogger.debug `RETURN: VisitorCodeManager.getSimulatedVariations(visitorCode: ${visitorCode}) -> (variations: ${variations})`;
6209
+ return variations;
6210
+ }
6211
+ generateVisitorCode() {
6212
+ const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
6213
+ const randomCharacterArray = [];
6214
+ for (let i = 0; i < VISITOR_CODE_LENGTH; i++) {
6215
+ randomCharacterArray.push(characters[Math.floor(Math.random() * characters.length)]);
6216
+ }
6217
+ return randomCharacterArray.join('');
6218
+ }
6219
+ setVariationConfiguration(variationConfiguration) {
6220
+ if (!this.variationConfiguration) {
6221
+ this.variationConfiguration = variationConfiguration;
6222
+ }
6223
+ }
6224
+ }
6225
+
6075
6226
  var sha256$2 = {exports: {}};
6076
6227
 
6077
6228
  function commonjsRequire(path) {
@@ -7597,135 +7748,6 @@ class KameleoonEventSource {
7597
7748
  }
7598
7749
  }
7599
7750
 
7600
- const VISITOR_CODE_LENGTH = 16;
7601
- const VISITOR_CODE_MAX_LENGTH = 255;
7602
- const DEFAULT_MAX_AGE = 60 * 60 * 24 * 365;
7603
- const PATH = '/';
7604
-
7605
- /**
7606
- * VisitorCodeManager - a class which manages visitor codes using cookies, offering functions to generate, retrieve,
7607
- * and handle these codes while considering user consent.
7608
- **/
7609
- class VisitorCodeManager {
7610
- constructor() {
7611
- this.isConsentRequired = false;
7612
- }
7613
- set consentRequired(isRequired) {
7614
- this.isConsentRequired = isRequired;
7615
- }
7616
- get consentRequired() {
7617
- return this.isConsentRequired;
7618
- }
7619
- set getData(callback) {
7620
- this.getDataCallback = callback;
7621
- }
7622
- set setData(callback) {
7623
- this.setDataCallback = callback;
7624
- }
7625
- get setData() {
7626
- if (this.setDataCallback) {
7627
- return this.setDataCallback;
7628
- }
7629
- throw new Error('Missing setDataCallback!');
7630
- }
7631
- validateVisitorCode(visitorCode) {
7632
- if (visitorCode.length === 0) {
7633
- return buildExports.Err(new KameleoonError(KameleoonException.VisitorCodeEmpty));
7634
- }
7635
- if (visitorCode.length > VISITOR_CODE_MAX_LENGTH) {
7636
- return buildExports.Err(new KameleoonError(KameleoonException.VisitorCodeMaxLength));
7637
- }
7638
- return buildExports.Ok();
7639
- }
7640
- getVisitorCode(defaultVisitorCode) {
7641
- KameleoonLogger.debug `CALL: VisitorCodeManager.getVisitorCode(defaultVisitorCode: ${defaultVisitorCode})`;
7642
- if (!this.getDataCallback || !this.setDataCallback) {
7643
- throw new Error('Missing getDataCallback or setDataCallback methods in getVisitorCode!');
7644
- }
7645
- let visitorCode;
7646
- const existingVisitorCode = this.getDataCallback(KameleoonStorageKey.VisitorCode);
7647
- if (existingVisitorCode) {
7648
- visitorCode = existingVisitorCode;
7649
- }
7650
- if (!visitorCode) {
7651
- if (defaultVisitorCode) {
7652
- this.validateVisitorCode(defaultVisitorCode).throw();
7653
- visitorCode = defaultVisitorCode;
7654
- KameleoonLogger.debug `Used default visitor code: ${visitorCode}`;
7655
- }
7656
- else {
7657
- visitorCode = this.generateVisitorCode();
7658
- KameleoonLogger.debug `Generated new visitor code: ${visitorCode}`;
7659
- }
7660
- }
7661
- this.processSimulatedVariations(visitorCode);
7662
- if (!this.isConsentRequired) {
7663
- this.setDataCallback({
7664
- visitorCode,
7665
- key: KameleoonStorageKey.VisitorCode,
7666
- maxAge: DEFAULT_MAX_AGE,
7667
- path: PATH,
7668
- });
7669
- }
7670
- KameleoonLogger.debug `RETURN: VisitorCodeManager.getVisitorCode(defaultVisitorCode: ${defaultVisitorCode}) -> (visitorCode: ${visitorCode})`;
7671
- return visitorCode;
7672
- }
7673
- processSimulatedVariations(visitorCode) {
7674
- if (this.variationConfiguration) {
7675
- const simulatedVariationsData = this.getSimulatedVariations(visitorCode);
7676
- try {
7677
- this.variationConfiguration.clearSimulatedVariations(visitorCode).throw();
7678
- if (simulatedVariationsData !== null && simulatedVariationsData.length > 0) {
7679
- this.variationConfiguration.updateForcedFeatureVariations(visitorCode, simulatedVariationsData).throw();
7680
- }
7681
- }
7682
- catch (error) {
7683
- if (error instanceof Error) {
7684
- KameleoonLogger.error `Failed to process simulated variations: ${error.message}`;
7685
- }
7686
- }
7687
- }
7688
- }
7689
- getSimulatedVariations(visitorCode) {
7690
- KameleoonLogger.debug `CALL: VisitorCodeManager.getSimulatedVariations(visitorCode: ${visitorCode})`;
7691
- const simulatedVariationsData = this.getDataCallback(KameleoonStorageKey.KameleoonSimulationFFData);
7692
- let variations = null;
7693
- if (typeof simulatedVariationsData === 'string' &&
7694
- simulatedVariationsData.length > 0) {
7695
- try {
7696
- const parsed = JSON.parse(decodeURIComponent(simulatedVariationsData));
7697
- if (parsed && typeof parsed === 'object') {
7698
- variations = Object.entries(parsed)
7699
- .map(([key, value]) => {
7700
- return this.variationConfiguration.simulatedVariationFromJson(key, value);
7701
- })
7702
- .filter((variation) => variation !== null);
7703
- }
7704
- }
7705
- catch (error) {
7706
- if (error instanceof Error) {
7707
- KameleoonLogger.error `Failed to parse simulated variations: ${error.message}`;
7708
- }
7709
- }
7710
- }
7711
- KameleoonLogger.debug `RETURN: VisitorCodeManager.getSimulatedVariations(visitorCode: ${visitorCode}) -> (variations: ${variations})`;
7712
- return variations;
7713
- }
7714
- generateVisitorCode() {
7715
- const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
7716
- const randomCharacterArray = [];
7717
- for (let i = 0; i < VISITOR_CODE_LENGTH; i++) {
7718
- randomCharacterArray.push(characters[Math.floor(Math.random() * characters.length)]);
7719
- }
7720
- return randomCharacterArray.join('');
7721
- }
7722
- setVariationConfiguration(variationConfiguration) {
7723
- if (!this.variationConfiguration) {
7724
- this.variationConfiguration = variationConfiguration;
7725
- }
7726
- }
7727
- }
7728
-
7729
7751
  var Byte;
7730
7752
  (function (Byte) {
7731
7753
  Byte[Byte["Kb"] = 1000] = "Kb";
@@ -7918,7 +7940,10 @@ class Tracker {
7918
7940
  const linkedVisitor = this.dataManager.getLinkedVisitor(visitorCode);
7919
7941
  const index = this.dataManager.identifierCustomDataIndex;
7920
7942
  if (!linkedVisitor && typeof index === 'number') {
7921
- this.dataManager.storeData(visitorCode, new CustomData$1(index, visitorCode));
7943
+ this.dataManager.storeData({
7944
+ visitorCode,
7945
+ data: [new CustomData$1(index, visitorCode)],
7946
+ });
7922
7947
  }
7923
7948
  else {
7924
7949
  isMappingIdentifier = true;
@@ -8067,7 +8092,7 @@ class Tracker {
8067
8092
  this.dataManager.storeTrackedData(updatedData);
8068
8093
  }
8069
8094
  else {
8070
- this.dataManager.storeData(updatedData, false);
8095
+ this.dataManager.storeDataForVisitors(updatedData, false);
8071
8096
  }
8072
8097
  }
8073
8098
  getUnsentVisitorData(visitorCode, isConsentProvided) {
@@ -8250,16 +8275,21 @@ class KameleoonClient {
8250
8275
  return result.ok;
8251
8276
  });
8252
8277
  }
8253
- addData(visitorCode, ...data) {
8278
+ addData(visitorCodeOrParams, ...dataRest) {
8254
8279
  if (this.stubMode) {
8255
8280
  throw new KameleoonError(KameleoonException.Initialization);
8256
8281
  }
8282
+ const params = typeof visitorCodeOrParams === 'string'
8283
+ ? { visitorCode: visitorCodeOrParams, data: dataRest }
8284
+ : visitorCodeOrParams;
8285
+ const { visitorCode, data, track = true } = params;
8257
8286
  KameleoonLogger.info `CALL: KameleoonClient.addData(visitorCode: ${visitorCode}, data: ${data})`;
8258
8287
  this.visitorCodeManager.validateVisitorCode(visitorCode).throw();
8259
8288
  if (!this.initialized) {
8260
8289
  throw new KameleoonError(KameleoonException.Initialization);
8261
8290
  }
8262
- this.dataManager.storeData(visitorCode, ...data).throw();
8291
+ // assuming DataManager.storeData supports `track` (boolean) as discussed
8292
+ this.dataManager.storeData({ visitorCode, track, data }).throw();
8263
8293
  KameleoonLogger.info `RETURN: KameleoonClient.addData(visitorCode: ${visitorCode}, data: ${data})`;
8264
8294
  }
8265
8295
  getRemoteVisitorData({ visitorCode, shouldAddData = true, filters = DEFAULT_VISITOR_DATA_FILTERS, }) {
@@ -8603,7 +8633,11 @@ class KameleoonClient {
8603
8633
  return null;
8604
8634
  }
8605
8635
  const customData = new CustomData$1(customDataIndex, ...Object.keys(data[WAREHOUSE_AUDIENCE_KEY]));
8606
- this.dataManager.storeData(visitorCode, customData);
8636
+ this.dataManager.storeData({
8637
+ visitorCode,
8638
+ track: true,
8639
+ data: [customData],
8640
+ });
8607
8641
  KameleoonLogger.info `RETURN: KameleoonClient.getVisitorWarehouseAudience(visitorCode: ${visitorCode}, customDataIndex: ${customDataIndex}, warehouseKey: ${warehouseKey}) -> (customData: ${customData})`;
8608
8642
  return customData;
8609
8643
  });
@@ -8679,7 +8713,7 @@ class KameleoonClient {
8679
8713
  }
8680
8714
  }
8681
8715
  if (targetedSegments.length !== 0) {
8682
- this.dataManager.storeData(visitorCode, ...targetedSegments);
8716
+ this.dataManager.storeData({ visitorCode, data: targetedSegments });
8683
8717
  }
8684
8718
  this.flush(visitorCode);
8685
8719
  KameleoonLogger.info `RETURN: KameleoonClient.evaluateAudiences(visitorCode: ${visitorCode})`;