@kameleoon/javascript-sdk-core 5.17.1 → 5.17.3

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.
@@ -3697,11 +3697,9 @@ class DataProcessor {
3697
3697
  delete infoData.mappingIdentifiers[visitorCode];
3698
3698
  }
3699
3699
  }
3700
- else {
3701
- if (!nextCleanupTime ||
3702
- (closestCleanupTime && closestCleanupTime < nextCleanupTime)) {
3703
- nextCleanupTime = closestCleanupTime;
3704
- }
3700
+ else if (!nextCleanupTime ||
3701
+ (closestCleanupTime && closestCleanupTime < nextCleanupTime)) {
3702
+ nextCleanupTime = closestCleanupTime;
3705
3703
  }
3706
3704
  }
3707
3705
  return nextCleanupTime;
@@ -3930,10 +3928,9 @@ class DataProcessor {
3930
3928
  if (isExpired) {
3931
3929
  delete existingData[nestedKey];
3932
3930
  }
3933
- else {
3934
- if (!closestCleanupTime || value.expirationTime < closestCleanupTime) {
3935
- closestCleanupTime = value.expirationTime;
3936
- }
3931
+ else if (!closestCleanupTime ||
3932
+ value.expirationTime < closestCleanupTime) {
3933
+ closestCleanupTime = value.expirationTime;
3937
3934
  }
3938
3935
  }
3939
3936
  if (!Object.keys(existingData).length) {
@@ -5546,6 +5543,13 @@ class StorageCleanupManager {
5546
5543
  }
5547
5544
  }
5548
5545
 
5546
+ exports.LegalConsent = void 0;
5547
+ (function (LegalConsent) {
5548
+ LegalConsent[LegalConsent["Unknown"] = 0] = "Unknown";
5549
+ LegalConsent[LegalConsent["Given"] = 1] = "Given";
5550
+ LegalConsent[LegalConsent["NotGiven"] = 2] = "NotGiven";
5551
+ })(exports.LegalConsent || (exports.LegalConsent = {}));
5552
+
5549
5553
  class TargetedSegment {
5550
5554
  constructor(id) {
5551
5555
  this.id = id;
@@ -7117,13 +7121,6 @@ class Hasher {
7117
7121
  }
7118
7122
  }
7119
7123
 
7120
- var LegalConsent;
7121
- (function (LegalConsent) {
7122
- LegalConsent[LegalConsent["Unknown"] = 0] = "Unknown";
7123
- LegalConsent[LegalConsent["Given"] = 1] = "Given";
7124
- LegalConsent[LegalConsent["NotGiven"] = 2] = "NotGiven";
7125
- })(LegalConsent || (LegalConsent = {}));
7126
-
7127
7124
  class VariationConfiguration {
7128
7125
  constructor(externalStorage, externalStorageForcedExperimentVariations, externalStorageForcedFeatureVariations, visitorCodeManager, clientConfiguration) {
7129
7126
  this.storage = externalStorage;
@@ -7187,7 +7184,7 @@ class VariationConfiguration {
7187
7184
  const { rules, featureKey, id: featureFlagId, defaultVariationKey, } = featureFlag;
7188
7185
  const consent = clientConfiguration.isConsentRequired
7189
7186
  ? legalConsent
7190
- : LegalConsent.Given;
7187
+ : exports.LegalConsent.Given;
7191
7188
  for (const rule of rules) {
7192
7189
  const { segment, experimentId, id, exposition, respoolTime, variationByExposition, } = rule;
7193
7190
  const forcedVariationData = this.getForcedExperimentVariation(visitorCode, rule.experimentId);
@@ -7235,7 +7232,7 @@ class VariationConfiguration {
7235
7232
  KameleoonLogger.debug `Calculated ruleHash: ${ruleHash} for code: ${visitorIdentifier}`;
7236
7233
  if (ruleHash <= exposition) {
7237
7234
  // Checking if the evaluation is blocked due to the consent policy
7238
- if (consent == LegalConsent.NotGiven &&
7235
+ if (consent == exports.LegalConsent.NotGiven &&
7239
7236
  rule.type == RuleType.EXPERIMENTATION) {
7240
7237
  const behaviour = clientConfiguration.consentBlockingBehaviour;
7241
7238
  if (behaviour == ConsentBlockingBehaviour.PartiallyBlocked) {
@@ -8764,7 +8761,7 @@ class KameleoonClient {
8764
8761
  }
8765
8762
  updateConsentData(visitorCode, consent) {
8766
8763
  const readResult = this.consentDataStorage.read();
8767
- const legalConsent = consent ? LegalConsent.Given : LegalConsent.NotGiven;
8764
+ const legalConsent = consent ? exports.LegalConsent.Given : exports.LegalConsent.NotGiven;
8768
8765
  if (!readResult.ok) {
8769
8766
  if (readResult.error.type === exports.KameleoonException.StorageEmpty) {
8770
8767
  this.consentDataStorage.write({
@@ -8787,26 +8784,26 @@ class KameleoonClient {
8787
8784
  const consentDataResult = this.consentDataStorage.read();
8788
8785
  legalConsent = consentDataResult.ok
8789
8786
  ? this.extractLegalConsent(consentDataResult.data[visitorCode])
8790
- : LegalConsent.Unknown;
8787
+ : exports.LegalConsent.Unknown;
8791
8788
  KameleoonLogger.debug `RETURN: KameleoonClient.getLegalConsent(visitorCode: ${visitorCode}) -> (legalConsent: ${legalConsent})`;
8792
8789
  return legalConsent;
8793
8790
  }
8794
8791
  extractLegalConsent(consentData) {
8795
8792
  if (consentData === undefined)
8796
- return LegalConsent.Unknown;
8793
+ return exports.LegalConsent.Unknown;
8797
8794
  if (typeof consentData === 'boolean') {
8798
- return consentData ? LegalConsent.Given : LegalConsent.NotGiven;
8795
+ return consentData ? exports.LegalConsent.Given : exports.LegalConsent.NotGiven;
8799
8796
  }
8800
8797
  const value = consentData.consent;
8801
8798
  if (typeof value === 'boolean')
8802
- return value ? LegalConsent.Given : LegalConsent.NotGiven;
8799
+ return value ? exports.LegalConsent.Given : exports.LegalConsent.NotGiven;
8803
8800
  return value;
8804
8801
  }
8805
8802
  _isConsentProvided(visitorCode) {
8806
8803
  KameleoonLogger.debug `CALL: KameleoonClient._isConsentProvided(visitorCode: ${visitorCode})`;
8807
8804
  const { isConsentRequired } = this.clientConfiguration;
8808
8805
  const isConsentProvided = !isConsentRequired ||
8809
- this.getLegalConsent(visitorCode) == LegalConsent.Given;
8806
+ this.getLegalConsent(visitorCode) == exports.LegalConsent.Given;
8810
8807
  KameleoonLogger.debug `RETURN: KameleoonClient._isConsentProvided(visitorCode: ${visitorCode}) -> (isConsentProvided: ${isConsentProvided})`;
8811
8808
  return isConsentProvided;
8812
8809
  }
@@ -9014,8 +9011,8 @@ class KameleoonClient {
9014
9011
  // Checking if the evaluation is blocked due to the consent policy
9015
9012
  const legalConsent = this.clientConfiguration.isConsentRequired
9016
9013
  ? this.getLegalConsent(visitorCode)
9017
- : LegalConsent.Given;
9018
- if (legalConsent == LegalConsent.NotGiven) {
9014
+ : exports.LegalConsent.Given;
9015
+ if (legalConsent == exports.LegalConsent.NotGiven) {
9019
9016
  const behaviour = this.clientConfiguration.consentBlockingBehaviour;
9020
9017
  if (behaviour == ConsentBlockingBehaviour.CompletelyBlocked) {
9021
9018
  throw new KameleoonError(exports.KameleoonException.FeatureFlagEnvironmentDisabled, `Evaluation of holdout is blocked because consent is not provided for visitor '${visitorCode}'`);