@kameleoon/javascript-sdk-core 5.17.0 → 5.17.2

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/CHANGELOG.md CHANGED
@@ -1,13 +1,25 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.17.2 (2026-01-21)
4
+
5
+ ### Patch Changes
6
+
7
+ - Stability and performance improvements
8
+
9
+ ## 5.17.1 (2025-12-24)
10
+
11
+ ### Patch Changes
12
+
13
+ - Stability and performance improvements
14
+
3
15
  ## 5.17.0 (2025-12-17)
4
16
 
5
17
  ### Features
6
18
 
7
19
  - Fixed an issue where **[Kameleoon Data](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#data-types)** was retained beyond the configured **[`targetingDataCleanupInterval`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk/#configuration-parameters)** if the **[Data API](https://developers.kameleoon.com/apis/data-api-rest/all-endpoints/post-visit-events/)** encountered internal errors. Expired data is now reliably removed in accordance with the cleanup interval.
8
20
  - Updated evaluation and tracking logic to comply with GDPR requirements when consent is not given:
9
- - If behavior is **partially blocked**, the default variation will be returned.
10
- - If behavior is **completely blocked**, an exception will be thrown.
21
+ - If behavior is **partially blocked**, the default variation will be returned.
22
+ - If behavior is **completely blocked**, an exception will be thrown.
11
23
 
12
24
  ## 5.16.1 (2025-10-23)
13
25
 
@@ -30,9 +42,6 @@
30
42
 
31
43
  ## 5.15.0 (2025-09-01)
32
44
 
33
- > [!WARNING]
34
- > If you're upgrading from a version earlier than 5.14.0 and run into any unexpected build or SDK-related issues, please reach out to the Kameleoon Support Team. We're here to ensure your transition is smooth and will promptly address any concerns.
35
-
36
45
  ### Features
37
46
 
38
47
  - Added an `overwrite` flag to [`CustomData`](CustomData), used as the `overwrite` parameter during tracking.
@@ -40,45 +49,30 @@
40
49
 
41
50
  ## 5.14.5 (2025-08-20)
42
51
 
43
- > [!WARNING]
44
- > If you're upgrading from a version earlier than 5.14.0 and run into any unexpected build or SDK-related issues, please reach out to the Kameleoon Support Team. We're here to ensure your transition is smooth and will promptly address any concerns.
45
-
46
52
  ### Patch Changes
47
53
 
48
54
  - Corrected the logic for sending tracking data to comply with GDPR requirements.
49
55
 
50
56
  ## 5.14.4 (2025-08-13)
51
57
 
52
- > [!WARNING]
53
- > If you're upgrading from a version earlier than 5.14.0 and run into any unexpected build or SDK-related issues, please reach out to the Kameleoon Support Team. We're here to ensure your transition is smooth and will promptly address any concerns.
54
-
55
58
  ### Patch Changes
56
59
 
57
60
  - Fixed an issue where using [`getRemoteVisitorData`][getRemoteVisitorData] with `personalization=true` or [`evaluateAudiences`][evaluateAudiences] could cause a visitor’s targeting data to be unexpectedly removed from storage.
58
61
 
59
62
  ## 5.14.3 (2025-08-12)
60
63
 
61
- > [!WARNING]
62
- > If you're upgrading from a version earlier than 5.14.0 and run into any unexpected build or SDK-related issues, please reach out to the Kameleoon Support Team. We're here to ensure your transition is smooth and will promptly address any concerns.
63
-
64
64
  ### Patch Changes
65
65
 
66
66
  - Fixed an issue where [`Cookie`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#cookie) would throw an exception when parsing from a string if the cookie value was empty.
67
67
 
68
68
  ## 5.14.2 (2025-08-01)
69
69
 
70
- > [!WARNING]
71
- > If you're upgrading from a version earlier than 5.14.0 and run into any unexpected build or SDK-related issues, please reach out to the Kameleoon Support Team. We're here to ensure your transition is smooth and will promptly address any concerns.
72
-
73
70
  ### Patch Changes
74
71
 
75
72
  - Fixed an issue where [`setLegalConsent()`][setLegalConsent] automatically triggered [`flush()`][flush], which could cause extra latency in serverless or edge environments (e.g., **Lambda@Edge**). It now requires an explicit `flush()`, giving developers full control over data submission.
76
73
 
77
74
  ## 5.14.1 (2025-07-30)
78
75
 
79
- > [!WARNING]
80
- > If you're upgrading from a version earlier than 5.14.0 and run into any unexpected build or SDK-related issues, please reach out to the Kameleoon Support Team. We're here to ensure your transition is smooth and will promptly address any concerns.
81
-
82
76
  ### Patch Changes
83
77
 
84
78
  - Improved error logging when parsing [`defaultDataFile`](defaultDataFile) - now provides more informative messages for easier debugging.
@@ -89,9 +83,6 @@
89
83
 
90
84
  ## 5.14.0 (2025-07-24)
91
85
 
92
- > [!WARNING]
93
- > If you're upgrading from a version earlier than 5.14.0 and run into any unexpected build or SDK-related issues, please reach out to the Kameleoon Support Team. We're here to ensure your transition is smooth and will promptly address any concerns.
94
-
95
86
  ### Features
96
87
 
97
88
  - Migrated the build system for the NPM package from Babel (which previously generated multiple minified JS files) to Rollup, producing a single, optimized bundle.
package/dist/browser.d.ts CHANGED
@@ -18,7 +18,7 @@ export { IExternalEventSource, EventSourceOpenParametersType, } from './eventSou
18
18
  export { Header, HeadersType, HttpMethod, IExternalRequester, RequestParametersType, RequestType, RetryCountType, KameleoonResponseType, SendRequestParametersType, NUMBER_OF_RETRIES, } from './requester';
19
19
  export { ITracker } from './tracking';
20
20
  export { SegmentType, TargetingDataType, Tree } from './targeting';
21
- export { DataInfoType, IStorage, VISIT_DURATION, DataStorage } from './storage';
21
+ export { DataInfoType, IStorage, VISIT_DURATION, DataStorage, LegalConsent, } from './storage';
22
22
  export { MappingIdentifierType } from './storage/types';
23
23
  export { CustomDataConfigurationType, CustomDataScope, } from './clientConfiguration';
24
24
  export { ListUtilities, Utilities } from './utilities';
package/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ export { IExternalEventSource, EventSourceOpenParametersType, } from './eventSou
18
18
  export { Header, HeadersType, HttpMethod, IExternalRequester, RequestParametersType, RequestType, RetryCountType, KameleoonResponseType, SendRequestParametersType, NUMBER_OF_RETRIES, } from './requester';
19
19
  export { ITracker } from './tracking';
20
20
  export { SegmentType, TargetingDataType, Tree } from './targeting';
21
- export { DataInfoType, IStorage, VISIT_DURATION, DataStorage } from './storage';
21
+ export { DataInfoType, IStorage, VISIT_DURATION, DataStorage, LegalConsent, } from './storage';
22
22
  export { MappingIdentifierType } from './storage/types';
23
23
  export { CustomDataConfigurationType, CustomDataScope, } from './clientConfiguration';
24
24
  export { ListUtilities, Utilities } from './utilities';
@@ -2936,7 +2936,10 @@ class VisitsData {
2936
2936
  constructor(visits) {
2937
2937
  this.status = exports.TrackingStatus.Sent;
2938
2938
  this.visits = visits;
2939
- this.visitNumber = visits.length ? visits.length - 1 : 0;
2939
+ this._visitNumber = visits.length ? visits.length - 1 : 0;
2940
+ }
2941
+ get visitNumber() {
2942
+ return this._visitNumber;
2940
2943
  }
2941
2944
  get url() {
2942
2945
  return '';
@@ -2944,7 +2947,7 @@ class VisitsData {
2944
2947
  get data() {
2945
2948
  return {
2946
2949
  visits: this.visits,
2947
- visitNumber: this.visitNumber,
2950
+ visitNumber: this._visitNumber,
2948
2951
  type: exports.KameleoonData.VisitsData,
2949
2952
  status: this.status,
2950
2953
  };
@@ -2961,11 +2964,11 @@ class VisitsData {
2961
2964
  list: this.visits,
2962
2965
  visit,
2963
2966
  });
2964
- this.visitNumber = this.visits.length ? this.visits.length - 1 : 0;
2967
+ this._visitNumber = this.visits.length ? this.visits.length - 1 : 0;
2965
2968
  }
2966
2969
  updateVisitNumber(visitNumber) {
2967
- if (visitNumber > this.visitNumber) {
2968
- this.visitNumber = visitNumber;
2970
+ if (visitNumber > this._visitNumber) {
2971
+ this._visitNumber = visitNumber;
2969
2972
  }
2970
2973
  }
2971
2974
  }
@@ -3172,10 +3175,12 @@ class VisitProcessor {
3172
3175
  timeLastActivity: (_a = visit.timeLastEvent) !== null && _a !== void 0 ? _a : visit.timeStarted,
3173
3176
  };
3174
3177
  }
3175
- processVisitNumber(visit, isCurrentVisit) {
3176
- if (visit.staticDataEvent) {
3177
- const visitNumber = visit.staticDataEvent.data.visitNumber + (isCurrentVisit ? 0 : 1);
3178
- this.visitsData.updateVisitNumber(visitNumber);
3178
+ processVisitNumber(visit, visitOffset) {
3179
+ var _a, _b, _c;
3180
+ if (this.visitsData.visitNumber <= visitOffset &&
3181
+ ((_a = visit.staticDataEvent) === null || _a === void 0 ? void 0 : _a.data.visitNumber)) {
3182
+ const visitNumber = (_c = (_b = visit.staticDataEvent) === null || _b === void 0 ? void 0 : _b.data.visitNumber) !== null && _c !== void 0 ? _c : 0;
3183
+ this.visitsData.updateVisitNumber(visitNumber + visitOffset);
3179
3184
  }
3180
3185
  }
3181
3186
  processCbs(cbsData) {
@@ -3349,12 +3354,12 @@ class Parser {
3349
3354
  }
3350
3355
  if (currentVisit) {
3351
3356
  visitProcessor.processVisit(currentVisit);
3352
- visitProcessor.processVisitNumber(currentVisit, true);
3357
+ visitProcessor.processVisitNumber(currentVisit, 0);
3353
3358
  }
3354
- previousVisits === null || previousVisits === void 0 ? void 0 : previousVisits.forEach((visit) => {
3359
+ previousVisits === null || previousVisits === void 0 ? void 0 : previousVisits.forEach((visit, index) => {
3355
3360
  visitProcessor.processVisit(visit);
3356
3361
  visitProcessor.processVisitsData(visit);
3357
- visitProcessor.processVisitNumber(visit, false);
3362
+ visitProcessor.processVisitNumber(visit, index + 1);
3358
3363
  });
3359
3364
  visitProcessor.processKcs(kcs);
3360
3365
  visitProcessor.processCbs(cbs);
@@ -3721,11 +3726,9 @@ class DataProcessor {
3721
3726
  delete infoData.mappingIdentifiers[visitorCode];
3722
3727
  }
3723
3728
  }
3724
- else {
3725
- if (!nextCleanupTime ||
3726
- (closestCleanupTime && closestCleanupTime < nextCleanupTime)) {
3727
- nextCleanupTime = closestCleanupTime;
3728
- }
3729
+ else if (!nextCleanupTime ||
3730
+ (closestCleanupTime && closestCleanupTime < nextCleanupTime)) {
3731
+ nextCleanupTime = closestCleanupTime;
3729
3732
  }
3730
3733
  }
3731
3734
  return nextCleanupTime;
@@ -3954,10 +3957,9 @@ class DataProcessor {
3954
3957
  if (isExpired) {
3955
3958
  delete existingData[nestedKey];
3956
3959
  }
3957
- else {
3958
- if (!closestCleanupTime || value.expirationTime < closestCleanupTime) {
3959
- closestCleanupTime = value.expirationTime;
3960
- }
3960
+ else if (!closestCleanupTime ||
3961
+ value.expirationTime < closestCleanupTime) {
3962
+ closestCleanupTime = value.expirationTime;
3961
3963
  }
3962
3964
  }
3963
3965
  if (!Object.keys(existingData).length) {
@@ -5570,6 +5572,13 @@ class StorageCleanupManager {
5570
5572
  }
5571
5573
  }
5572
5574
 
5575
+ exports.LegalConsent = void 0;
5576
+ (function (LegalConsent) {
5577
+ LegalConsent[LegalConsent["Unknown"] = 0] = "Unknown";
5578
+ LegalConsent[LegalConsent["Given"] = 1] = "Given";
5579
+ LegalConsent[LegalConsent["NotGiven"] = 2] = "NotGiven";
5580
+ })(exports.LegalConsent || (exports.LegalConsent = {}));
5581
+
5573
5582
  class TargetedSegment {
5574
5583
  constructor(id) {
5575
5584
  this.id = id;
@@ -7150,13 +7159,6 @@ class Hasher {
7150
7159
  }
7151
7160
  }
7152
7161
 
7153
- var LegalConsent;
7154
- (function (LegalConsent) {
7155
- LegalConsent[LegalConsent["Unknown"] = 0] = "Unknown";
7156
- LegalConsent[LegalConsent["Given"] = 1] = "Given";
7157
- LegalConsent[LegalConsent["NotGiven"] = 2] = "NotGiven";
7158
- })(LegalConsent || (LegalConsent = {}));
7159
-
7160
7162
  class VariationConfiguration {
7161
7163
  constructor(externalStorage, externalStorageForcedExperimentVariations, externalStorageForcedFeatureVariations, visitorCodeManager, clientConfiguration) {
7162
7164
  this.storage = externalStorage;
@@ -7220,7 +7222,7 @@ class VariationConfiguration {
7220
7222
  const { rules, featureKey, id: featureFlagId, defaultVariationKey, } = featureFlag;
7221
7223
  const consent = clientConfiguration.isConsentRequired
7222
7224
  ? legalConsent
7223
- : LegalConsent.Given;
7225
+ : exports.LegalConsent.Given;
7224
7226
  for (const rule of rules) {
7225
7227
  const { segment, experimentId, id, exposition, respoolTime, variationByExposition, } = rule;
7226
7228
  const forcedVariationData = this.getForcedExperimentVariation(visitorCode, rule.experimentId);
@@ -7268,7 +7270,7 @@ class VariationConfiguration {
7268
7270
  KameleoonLogger.debug `Calculated ruleHash: ${ruleHash} for code: ${visitorIdentifier}`;
7269
7271
  if (ruleHash <= exposition) {
7270
7272
  // Checking if the evaluation is blocked due to the consent policy
7271
- if (consent == LegalConsent.NotGiven &&
7273
+ if (consent == exports.LegalConsent.NotGiven &&
7272
7274
  rule.type == RuleType.EXPERIMENTATION) {
7273
7275
  const behaviour = clientConfiguration.consentBlockingBehaviour;
7274
7276
  if (behaviour == ConsentBlockingBehaviour.PartiallyBlocked) {
@@ -8797,7 +8799,7 @@ class KameleoonClient {
8797
8799
  }
8798
8800
  updateConsentData(visitorCode, consent) {
8799
8801
  const readResult = this.consentDataStorage.read();
8800
- const legalConsent = consent ? LegalConsent.Given : LegalConsent.NotGiven;
8802
+ const legalConsent = consent ? exports.LegalConsent.Given : exports.LegalConsent.NotGiven;
8801
8803
  if (!readResult.ok) {
8802
8804
  if (readResult.error.type === exports.KameleoonException.StorageEmpty) {
8803
8805
  this.consentDataStorage.write({
@@ -8820,26 +8822,26 @@ class KameleoonClient {
8820
8822
  const consentDataResult = this.consentDataStorage.read();
8821
8823
  legalConsent = consentDataResult.ok
8822
8824
  ? this.extractLegalConsent(consentDataResult.data[visitorCode])
8823
- : LegalConsent.Unknown;
8825
+ : exports.LegalConsent.Unknown;
8824
8826
  KameleoonLogger.debug `RETURN: KameleoonClient.getLegalConsent(visitorCode: ${visitorCode}) -> (legalConsent: ${legalConsent})`;
8825
8827
  return legalConsent;
8826
8828
  }
8827
8829
  extractLegalConsent(consentData) {
8828
8830
  if (consentData === undefined)
8829
- return LegalConsent.Unknown;
8831
+ return exports.LegalConsent.Unknown;
8830
8832
  if (typeof consentData === 'boolean') {
8831
- return consentData ? LegalConsent.Given : LegalConsent.NotGiven;
8833
+ return consentData ? exports.LegalConsent.Given : exports.LegalConsent.NotGiven;
8832
8834
  }
8833
8835
  const value = consentData.consent;
8834
8836
  if (typeof value === 'boolean')
8835
- return value ? LegalConsent.Given : LegalConsent.NotGiven;
8837
+ return value ? exports.LegalConsent.Given : exports.LegalConsent.NotGiven;
8836
8838
  return value;
8837
8839
  }
8838
8840
  _isConsentProvided(visitorCode) {
8839
8841
  KameleoonLogger.debug `CALL: KameleoonClient._isConsentProvided(visitorCode: ${visitorCode})`;
8840
8842
  const { isConsentRequired } = this.clientConfiguration;
8841
8843
  const isConsentProvided = !isConsentRequired ||
8842
- this.getLegalConsent(visitorCode) == LegalConsent.Given;
8844
+ this.getLegalConsent(visitorCode) == exports.LegalConsent.Given;
8843
8845
  KameleoonLogger.debug `RETURN: KameleoonClient._isConsentProvided(visitorCode: ${visitorCode}) -> (isConsentProvided: ${isConsentProvided})`;
8844
8846
  return isConsentProvided;
8845
8847
  }
@@ -9045,8 +9047,10 @@ class KameleoonClient {
9045
9047
  KameleoonLogger.debug `CALL: KameleoonClient._isVisitorNotInHoldout(visitorCode: ${visitorCode}, track: ${track}, save: ${save}, featureFlag: ${featureFlag}, visitorData: ${visitorData})`;
9046
9048
  let isNotInHoldout = true;
9047
9049
  // Checking if the evaluation is blocked due to the consent policy
9048
- const legalConsent = this.getLegalConsent(visitorCode);
9049
- if (legalConsent == LegalConsent.NotGiven) {
9050
+ const legalConsent = this.clientConfiguration.isConsentRequired
9051
+ ? this.getLegalConsent(visitorCode)
9052
+ : exports.LegalConsent.Given;
9053
+ if (legalConsent == exports.LegalConsent.NotGiven) {
9050
9054
  const behaviour = this.clientConfiguration.consentBlockingBehaviour;
9051
9055
  if (behaviour == ConsentBlockingBehaviour.CompletelyBlocked) {
9052
9056
  throw new KameleoonError(exports.KameleoonException.FeatureFlagEnvironmentDisabled, `Evaluation of holdout is blocked because consent is not provided for visitor '${visitorCode}'`);
@@ -9257,4 +9261,4 @@ exports.VISITOR_CODE_LENGTH = VISITOR_CODE_LENGTH;
9257
9261
  exports.VISIT_DURATION = VISIT_DURATION;
9258
9262
  exports.Validator = Validator;
9259
9263
  exports.VisitorCodeManager = VisitorCodeManager;
9260
- //# sourceMappingURL=javascript-sdk-core-browser.cjs.js.map
9264
+ //# sourceMappingURL=javascript-sdk-core.browser.cjs.js.map