@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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.16.0 (2025-10-22)
4
+
5
+ ### Minor Changes
6
+
7
+ - Introduced a new [`getDataFile`](getDataFile) method. This method returns the current SDK configuration (also known as the **data file**) used for evaluation and targeting. It is **not** intended for production use to fetch variations for every feature flag in the returned list, as it is not optimized for performance. For that purpose, use [`getVariations`](getVariations) instead. `getDataFile` is mainly useful for debugging or QA, for example to let internal users manually select a variant for a specific feature flag in production.
8
+
9
+ ### Patch Changes
10
+
11
+ - Addressed an issue where tracking data was sent for visitors who had not provided [consent](setLegalConsent).
12
+
13
+ [setLegalConsent]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#setLegalConsent
14
+ [getDataFile]: https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/js-sdk#getdatafile
15
+
3
16
  ## 5.15.0 (2025-09-01)
4
17
 
5
18
  > [!WARNING]
package/dist/browser.d.ts CHANGED
@@ -23,3 +23,4 @@ export { MappingIdentifierType } from './storage/types';
23
23
  export { CustomDataConfigurationType, CustomDataScope, } from './clientConfiguration';
24
24
  export { ListUtilities, Utilities } from './utilities';
25
25
  export { BrowserDataType, CustomDataType, DataFilterType, DataManagerParametersType, DeviceDataType, GeolocationDataType, KameleoonVisitorDataType, MutUpdateTargetingDataParametersType, OperatingSystemDataType, PageViewDataType, ProcessCustomDataManagerParametersType, VisitDataType, VisitorsDataType, } from './kameleoonData/types';
26
+ export { FeatureFlag, Rule, DataFile, Variable, Variation } from './types';
@@ -70,6 +70,7 @@ export type ExperimentType = {
70
70
  variationByExposition: VariationByExpositionType[];
71
71
  };
72
72
  export type FeatureVariationType = {
73
+ name?: string;
73
74
  key: string;
74
75
  variables: FeatureVariableType[];
75
76
  };
package/dist/index.d.ts CHANGED
@@ -23,3 +23,4 @@ export { MappingIdentifierType } from './storage/types';
23
23
  export { CustomDataConfigurationType, CustomDataScope, } from './clientConfiguration';
24
24
  export { ListUtilities, Utilities } from './utilities';
25
25
  export { BrowserDataType, CustomDataType, DataFilterType, DataManagerParametersType, DeviceDataType, GeolocationDataType, KameleoonVisitorDataType, MutUpdateTargetingDataParametersType, OperatingSystemDataType, PageViewDataType, ProcessCustomDataManagerParametersType, VisitDataType, VisitorsDataType, } from './kameleoonData/types';
26
+ export { FeatureFlag, Rule, DataFile, Variable, Variation } from './types';
@@ -5149,7 +5149,7 @@ class ConditionFactory {
5149
5149
  case TargetingType.HEAT_SLICE:
5150
5150
  return buildExports.Ok(new ConversionLikelihood(data));
5151
5151
  default:
5152
- KameleoonLogger.error `Unsupported targeted condition type found: ${targetingType}`;
5152
+ KameleoonLogger.info `Unsupported targeted condition type found: ${targetingType}`;
5153
5153
  return buildExports.Err(new KameleoonError(exports.KameleoonException.TargetingCondition, targetingType));
5154
5154
  }
5155
5155
  }
@@ -7807,7 +7807,7 @@ class BodyProvider {
7807
7807
  const identifier = isMappingIdentifier
7808
7808
  ? UrlParameter.MappingValue
7809
7809
  : UrlParameter.VisitorCode;
7810
- return identifier + visitorCode;
7810
+ return identifier + encodeURIComponent(visitorCode);
7811
7811
  }
7812
7812
  }
7813
7813
 
@@ -8391,6 +8391,7 @@ class KameleoonClient {
8391
8391
  }
8392
8392
  const resultVariables = variables.map((variable) => Parser.parseFeatureVariable(variable).throw());
8393
8393
  resultFeatureList.set(variation.featureKey, {
8394
+ name: '',
8394
8395
  key: variationKey,
8395
8396
  id: variationId,
8396
8397
  experimentId,
@@ -8611,6 +8612,62 @@ class KameleoonClient {
8611
8612
  this.flush(visitorCode);
8612
8613
  KameleoonLogger.info `RETURN: KameleoonClient.evaluateAudiences(visitorCode: ${visitorCode})`;
8613
8614
  }
8615
+ getDataFile() {
8616
+ const dataFile = {
8617
+ featureFlags: new Map(),
8618
+ };
8619
+ if (this.stubMode) {
8620
+ return dataFile;
8621
+ }
8622
+ KameleoonLogger.debug `CALL: KameleoonClient.getDataFile()`;
8623
+ this.clientConfiguration.featureFlags.forEach((featureFlag, key) => {
8624
+ const variationsMap = new Map();
8625
+ featureFlag.variations.forEach((sourceVariation) => {
8626
+ var _a;
8627
+ const variablesMap = new Map();
8628
+ sourceVariation.variables.forEach((variable) => {
8629
+ try {
8630
+ const parsedVariable = Parser.parseFeatureVariable(variable).throw();
8631
+ variablesMap.set(variable.key, parsedVariable);
8632
+ }
8633
+ catch (err) {
8634
+ KameleoonLogger.error `Error parsing variable ${variable.key} of feature flag ${featureFlag.featureKey}: ${err}`;
8635
+ }
8636
+ });
8637
+ variationsMap.set(sourceVariation.key, {
8638
+ name: (_a = sourceVariation.name) !== null && _a !== void 0 ? _a : '',
8639
+ key: sourceVariation.key,
8640
+ id: null,
8641
+ experimentId: null,
8642
+ variables: variablesMap,
8643
+ });
8644
+ });
8645
+ const rules = featureFlag.rules.map((rule) => {
8646
+ const ruleVariations = new Map();
8647
+ rule.variationByExposition.forEach((varByExp) => {
8648
+ const baseVariation = variationsMap.get(varByExp.variationKey);
8649
+ if (!baseVariation)
8650
+ return;
8651
+ ruleVariations.set(baseVariation.key, {
8652
+ name: baseVariation.name,
8653
+ key: baseVariation.key,
8654
+ id: varByExp.variationId,
8655
+ experimentId: rule.experimentId,
8656
+ variables: baseVariation.variables,
8657
+ });
8658
+ });
8659
+ return { variations: ruleVariations };
8660
+ });
8661
+ dataFile.featureFlags.set(key, {
8662
+ variations: variationsMap,
8663
+ environmentEnabled: featureFlag.environmentEnabled,
8664
+ rules,
8665
+ defaultVariationKey: featureFlag.defaultVariationKey,
8666
+ });
8667
+ });
8668
+ KameleoonLogger.debug `RETURN: KameleoonClient.getDataFile() -> (dataFile: ${dataFile})`;
8669
+ return dataFile;
8670
+ }
8614
8671
  setUserConsent({ visitorCode, consent, setData, }) {
8615
8672
  if (this.stubMode) {
8616
8673
  return;
@@ -8797,6 +8854,7 @@ class KameleoonClient {
8797
8854
  return selected;
8798
8855
  }
8799
8856
  _getFeatureVariation({ visitorCode, featureKey, track, }) {
8857
+ var _a, _b;
8800
8858
  KameleoonLogger.debug `CALL: KameleoonClient._getFeatureVariation(visitorCode: ${visitorCode}, featureKey: ${featureKey}, track: ${track})`;
8801
8859
  if (!this.initialized) {
8802
8860
  return buildExports.Err(new KameleoonError(exports.KameleoonException.Initialization));
@@ -8847,7 +8905,9 @@ class KameleoonClient {
8847
8905
  if (track && !isSimulated) {
8848
8906
  this.tracker.scheduleVisitor(visitorCode, this._isConsentProvided(visitorCode));
8849
8907
  }
8908
+ const variationName = (_b = (_a = featureFlag.variations.find((item) => item.key === variationKey)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '';
8850
8909
  const resultData = {
8910
+ name: variationName,
8851
8911
  key: variationKey,
8852
8912
  id: variationId,
8853
8913
  experimentId,