@kameleoon/javascript-sdk-core 5.15.0 → 5.16.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.
@@ -5147,7 +5147,7 @@ class ConditionFactory {
5147
5147
  case TargetingType.HEAT_SLICE:
5148
5148
  return buildExports.Ok(new ConversionLikelihood(data));
5149
5149
  default:
5150
- KameleoonLogger.error `Unsupported targeted condition type found: ${targetingType}`;
5150
+ KameleoonLogger.info `Unsupported targeted condition type found: ${targetingType}`;
5151
5151
  return buildExports.Err(new KameleoonError(KameleoonException.TargetingCondition, targetingType));
5152
5152
  }
5153
5153
  }
@@ -7805,7 +7805,7 @@ class BodyProvider {
7805
7805
  const identifier = isMappingIdentifier
7806
7806
  ? UrlParameter.MappingValue
7807
7807
  : UrlParameter.VisitorCode;
7808
- return identifier + visitorCode;
7808
+ return identifier + encodeURIComponent(visitorCode);
7809
7809
  }
7810
7810
  }
7811
7811
 
@@ -8389,6 +8389,7 @@ class KameleoonClient {
8389
8389
  }
8390
8390
  const resultVariables = variables.map((variable) => Parser.parseFeatureVariable(variable).throw());
8391
8391
  resultFeatureList.set(variation.featureKey, {
8392
+ name: '',
8392
8393
  key: variationKey,
8393
8394
  id: variationId,
8394
8395
  experimentId,
@@ -8609,6 +8610,62 @@ class KameleoonClient {
8609
8610
  this.flush(visitorCode);
8610
8611
  KameleoonLogger.info `RETURN: KameleoonClient.evaluateAudiences(visitorCode: ${visitorCode})`;
8611
8612
  }
8613
+ getDataFile() {
8614
+ const dataFile = {
8615
+ featureFlags: new Map(),
8616
+ };
8617
+ if (this.stubMode) {
8618
+ return dataFile;
8619
+ }
8620
+ KameleoonLogger.debug `CALL: KameleoonClient.getDataFile()`;
8621
+ this.clientConfiguration.featureFlags.forEach((featureFlag, key) => {
8622
+ const variationsMap = new Map();
8623
+ featureFlag.variations.forEach((sourceVariation) => {
8624
+ var _a;
8625
+ const variablesMap = new Map();
8626
+ sourceVariation.variables.forEach((variable) => {
8627
+ try {
8628
+ const parsedVariable = Parser.parseFeatureVariable(variable).throw();
8629
+ variablesMap.set(variable.key, parsedVariable);
8630
+ }
8631
+ catch (err) {
8632
+ KameleoonLogger.error `Error parsing variable ${variable.key} of feature flag ${featureFlag.featureKey}: ${err}`;
8633
+ }
8634
+ });
8635
+ variationsMap.set(sourceVariation.key, {
8636
+ name: (_a = sourceVariation.name) !== null && _a !== void 0 ? _a : '',
8637
+ key: sourceVariation.key,
8638
+ id: null,
8639
+ experimentId: null,
8640
+ variables: variablesMap,
8641
+ });
8642
+ });
8643
+ const rules = featureFlag.rules.map((rule) => {
8644
+ const ruleVariations = new Map();
8645
+ rule.variationByExposition.forEach((varByExp) => {
8646
+ const baseVariation = variationsMap.get(varByExp.variationKey);
8647
+ if (!baseVariation)
8648
+ return;
8649
+ ruleVariations.set(baseVariation.key, {
8650
+ name: baseVariation.name,
8651
+ key: baseVariation.key,
8652
+ id: varByExp.variationId,
8653
+ experimentId: rule.experimentId,
8654
+ variables: baseVariation.variables,
8655
+ });
8656
+ });
8657
+ return { variations: ruleVariations };
8658
+ });
8659
+ dataFile.featureFlags.set(key, {
8660
+ variations: variationsMap,
8661
+ environmentEnabled: featureFlag.environmentEnabled,
8662
+ rules,
8663
+ defaultVariationKey: featureFlag.defaultVariationKey,
8664
+ });
8665
+ });
8666
+ KameleoonLogger.debug `RETURN: KameleoonClient.getDataFile() -> (dataFile: ${dataFile})`;
8667
+ return dataFile;
8668
+ }
8612
8669
  setUserConsent({ visitorCode, consent, setData, }) {
8613
8670
  if (this.stubMode) {
8614
8671
  return;
@@ -8795,6 +8852,7 @@ class KameleoonClient {
8795
8852
  return selected;
8796
8853
  }
8797
8854
  _getFeatureVariation({ visitorCode, featureKey, track, }) {
8855
+ var _a, _b;
8798
8856
  KameleoonLogger.debug `CALL: KameleoonClient._getFeatureVariation(visitorCode: ${visitorCode}, featureKey: ${featureKey}, track: ${track})`;
8799
8857
  if (!this.initialized) {
8800
8858
  return buildExports.Err(new KameleoonError(KameleoonException.Initialization));
@@ -8845,7 +8903,9 @@ class KameleoonClient {
8845
8903
  if (track && !isSimulated) {
8846
8904
  this.tracker.scheduleVisitor(visitorCode, this._isConsentProvided(visitorCode));
8847
8905
  }
8906
+ const variationName = (_b = (_a = featureFlag.variations.find((item) => item.key === variationKey)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '';
8848
8907
  const resultData = {
8908
+ name: variationName,
8849
8909
  key: variationKey,
8850
8910
  id: variationId,
8851
8911
  experimentId,