@kameleoon/javascript-sdk-core 5.15.0 → 5.16.1
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 +19 -0
- package/dist/browser.d.ts +1 -0
- package/dist/clientConfiguration/types.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/javascript-sdk-core-browser.cjs.js +108 -19
- package/dist/javascript-sdk-core-browser.cjs.js.map +1 -1
- package/dist/javascript-sdk-core-browser.es.js +108 -19
- package/dist/javascript-sdk-core-browser.es.js.map +1 -1
- package/dist/javascript-sdk-core.cjs.js +108 -19
- package/dist/javascript-sdk-core.cjs.js.map +1 -1
- package/dist/javascript-sdk-core.es.js +108 -19
- package/dist/javascript-sdk-core.es.js.map +1 -1
- package/dist/kameleoonClient.d.ts +5 -4
- package/dist/kameleoonClientInterface.d.ts +13 -7
- package/dist/kameleoonData/conversion.d.ts +2 -0
- package/dist/kameleoonData/customData.d.ts +15 -4
- package/dist/kameleoonData/dataManager.d.ts +1 -0
- package/dist/types.d.ts +36 -4
- package/package.json +1 -1
|
@@ -2300,11 +2300,11 @@ let CustomData$1 = class CustomData {
|
|
|
2300
2300
|
const isNumber = typeof first === 'number';
|
|
2301
2301
|
const isBoolean = typeof second === 'boolean';
|
|
2302
2302
|
if (isNumber) {
|
|
2303
|
-
this.
|
|
2303
|
+
this._index = first;
|
|
2304
2304
|
}
|
|
2305
2305
|
else {
|
|
2306
|
-
this.
|
|
2307
|
-
this.
|
|
2306
|
+
this._name = first;
|
|
2307
|
+
this._index = CustomData.UNDEFINED_INDEX;
|
|
2308
2308
|
}
|
|
2309
2309
|
this.overwrite = isBoolean ? second : true;
|
|
2310
2310
|
this.value = isBoolean
|
|
@@ -2315,7 +2315,7 @@ let CustomData$1 = class CustomData {
|
|
|
2315
2315
|
// --- Note ---
|
|
2316
2316
|
// If SDK is used in vanilla JS codebase, then you're also able to create an instance
|
|
2317
2317
|
// with no required data, we don't want send anything to tracking in that case
|
|
2318
|
-
if (typeof this.
|
|
2318
|
+
if (typeof this._index !== 'number') {
|
|
2319
2319
|
return '';
|
|
2320
2320
|
}
|
|
2321
2321
|
const uniqueValues = [...new Set(this.value)];
|
|
@@ -2332,7 +2332,7 @@ let CustomData$1 = class CustomData {
|
|
|
2332
2332
|
}
|
|
2333
2333
|
return (UrlEventType.CustomData +
|
|
2334
2334
|
UrlParameter.Index +
|
|
2335
|
-
this.
|
|
2335
|
+
this._index +
|
|
2336
2336
|
UrlParameter.ValuesCountMap +
|
|
2337
2337
|
encodeURIComponent(JSON.stringify(resultValue)) +
|
|
2338
2338
|
UrlParameter.Overwrite +
|
|
@@ -2340,7 +2340,7 @@ let CustomData$1 = class CustomData {
|
|
|
2340
2340
|
identifierParameter);
|
|
2341
2341
|
}
|
|
2342
2342
|
get data() {
|
|
2343
|
-
return Object.assign(Object.assign({ index: this.
|
|
2343
|
+
return Object.assign(Object.assign({ index: this._index }, (this._name !== undefined ? { name: this._name } : {})), { value: this.value, type: KameleoonData.CustomData, isIdentifier: this.isIdentifier, status: this.status, overwrite: this.overwrite });
|
|
2344
2344
|
}
|
|
2345
2345
|
get status() {
|
|
2346
2346
|
if (this._isMappingIdentifier) {
|
|
@@ -2359,7 +2359,7 @@ let CustomData$1 = class CustomData {
|
|
|
2359
2359
|
let customData;
|
|
2360
2360
|
if (name) {
|
|
2361
2361
|
customData = new CustomData(name, overwrite !== null && overwrite !== void 0 ? overwrite : true, ...value);
|
|
2362
|
-
customData.
|
|
2362
|
+
customData.index = index;
|
|
2363
2363
|
}
|
|
2364
2364
|
else {
|
|
2365
2365
|
customData = new CustomData(index, overwrite !== null && overwrite !== void 0 ? overwrite : true, ...value);
|
|
@@ -2396,13 +2396,28 @@ let CustomData$1 = class CustomData {
|
|
|
2396
2396
|
}
|
|
2397
2397
|
/**
|
|
2398
2398
|
* @private
|
|
2399
|
-
* @method
|
|
2399
|
+
* @method index - an internal setter for setting index of custom data
|
|
2400
2400
|
* @param {number} value - an index value
|
|
2401
2401
|
* */
|
|
2402
|
-
set
|
|
2403
|
-
this.
|
|
2402
|
+
set index(value) {
|
|
2403
|
+
this._index = value;
|
|
2404
|
+
}
|
|
2405
|
+
/**
|
|
2406
|
+
* @private
|
|
2407
|
+
* @method index - an internal getter for index of custom data
|
|
2408
|
+
* */
|
|
2409
|
+
get index() {
|
|
2410
|
+
return this._index;
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* @private
|
|
2414
|
+
* @method name - an internal getter for a name of custom data
|
|
2415
|
+
* */
|
|
2416
|
+
get name() {
|
|
2417
|
+
return this._name;
|
|
2404
2418
|
}
|
|
2405
2419
|
};
|
|
2420
|
+
CustomData$1.UNDEFINED_INDEX = -1;
|
|
2406
2421
|
|
|
2407
2422
|
/**
|
|
2408
2423
|
* @class
|
|
@@ -2439,6 +2454,9 @@ let Conversion$1 = class Conversion {
|
|
|
2439
2454
|
? UrlParameter.Metadata + this._encodeMetadata()
|
|
2440
2455
|
: ''));
|
|
2441
2456
|
}
|
|
2457
|
+
get _metadata() {
|
|
2458
|
+
return this.metadata;
|
|
2459
|
+
}
|
|
2442
2460
|
get data() {
|
|
2443
2461
|
var _a;
|
|
2444
2462
|
return {
|
|
@@ -5147,7 +5165,7 @@ class ConditionFactory {
|
|
|
5147
5165
|
case TargetingType.HEAT_SLICE:
|
|
5148
5166
|
return buildExports.Ok(new ConversionLikelihood(data));
|
|
5149
5167
|
default:
|
|
5150
|
-
KameleoonLogger.
|
|
5168
|
+
KameleoonLogger.info `Unsupported targeted condition type found: ${targetingType}`;
|
|
5151
5169
|
return buildExports.Err(new KameleoonError(KameleoonException.TargetingCondition, targetingType));
|
|
5152
5170
|
}
|
|
5153
5171
|
}
|
|
@@ -5869,7 +5887,9 @@ class DataManager {
|
|
|
5869
5887
|
return null;
|
|
5870
5888
|
}
|
|
5871
5889
|
mutUpdateTargetingData({ infoData, visitorCode, kameleoonData, targetingData, }) {
|
|
5890
|
+
var _a;
|
|
5872
5891
|
for (const dataItem of kameleoonData) {
|
|
5892
|
+
// process custom data
|
|
5873
5893
|
if (dataItem.data.type === KameleoonData.CustomData) {
|
|
5874
5894
|
const customDataIsValid = this.processCustomData({
|
|
5875
5895
|
infoData,
|
|
@@ -5881,6 +5901,10 @@ class DataManager {
|
|
|
5881
5901
|
continue;
|
|
5882
5902
|
}
|
|
5883
5903
|
}
|
|
5904
|
+
// process metadata of conversions
|
|
5905
|
+
if (dataItem.data.type === KameleoonData.Conversion) {
|
|
5906
|
+
(_a = dataItem._metadata) === null || _a === void 0 ? void 0 : _a.forEach((item) => this.trySetCustomDataIndexByName(item));
|
|
5907
|
+
}
|
|
5884
5908
|
const expirationTime = this.dataProcessor.mutUpdateData({
|
|
5885
5909
|
infoData,
|
|
5886
5910
|
visitorCode,
|
|
@@ -5920,13 +5944,9 @@ class DataManager {
|
|
|
5920
5944
|
var _a;
|
|
5921
5945
|
const { data } = customData;
|
|
5922
5946
|
const isDataValid = Boolean(data.value.length && data.value[0].length);
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
return false;
|
|
5927
|
-
}
|
|
5928
|
-
data.index = cdIndex;
|
|
5929
|
-
customData._index = cdIndex;
|
|
5947
|
+
this.trySetCustomDataIndexByName(customData);
|
|
5948
|
+
if (data.index == CustomData$1.UNDEFINED_INDEX) {
|
|
5949
|
+
data.index = customData.index;
|
|
5930
5950
|
}
|
|
5931
5951
|
if (this.mappingIdentifierCustomDataIndex === data.index && isDataValid) {
|
|
5932
5952
|
customData._isMappingIdentifier = true;
|
|
@@ -5953,6 +5973,15 @@ class DataManager {
|
|
|
5953
5973
|
}
|
|
5954
5974
|
return true;
|
|
5955
5975
|
}
|
|
5976
|
+
trySetCustomDataIndexByName(customData) {
|
|
5977
|
+
if (customData.index == CustomData$1.UNDEFINED_INDEX && customData.name) {
|
|
5978
|
+
const cdIndex = this.customDataIndexByName.get(customData.name);
|
|
5979
|
+
if (cdIndex === undefined) {
|
|
5980
|
+
return;
|
|
5981
|
+
}
|
|
5982
|
+
customData.index = cdIndex;
|
|
5983
|
+
}
|
|
5984
|
+
}
|
|
5956
5985
|
get unsentDataVisitors() {
|
|
5957
5986
|
const infoResult = this.infoStorage.read();
|
|
5958
5987
|
if (!infoResult.ok) {
|
|
@@ -7805,7 +7834,7 @@ class BodyProvider {
|
|
|
7805
7834
|
const identifier = isMappingIdentifier
|
|
7806
7835
|
? UrlParameter.MappingValue
|
|
7807
7836
|
: UrlParameter.VisitorCode;
|
|
7808
|
-
return identifier + visitorCode;
|
|
7837
|
+
return identifier + encodeURIComponent(visitorCode);
|
|
7809
7838
|
}
|
|
7810
7839
|
}
|
|
7811
7840
|
|
|
@@ -8389,6 +8418,7 @@ class KameleoonClient {
|
|
|
8389
8418
|
}
|
|
8390
8419
|
const resultVariables = variables.map((variable) => Parser.parseFeatureVariable(variable).throw());
|
|
8391
8420
|
resultFeatureList.set(variation.featureKey, {
|
|
8421
|
+
name: '',
|
|
8392
8422
|
key: variationKey,
|
|
8393
8423
|
id: variationId,
|
|
8394
8424
|
experimentId,
|
|
@@ -8609,6 +8639,62 @@ class KameleoonClient {
|
|
|
8609
8639
|
this.flush(visitorCode);
|
|
8610
8640
|
KameleoonLogger.info `RETURN: KameleoonClient.evaluateAudiences(visitorCode: ${visitorCode})`;
|
|
8611
8641
|
}
|
|
8642
|
+
getDataFile() {
|
|
8643
|
+
const dataFile = {
|
|
8644
|
+
featureFlags: new Map(),
|
|
8645
|
+
};
|
|
8646
|
+
if (this.stubMode) {
|
|
8647
|
+
return dataFile;
|
|
8648
|
+
}
|
|
8649
|
+
KameleoonLogger.debug `CALL: KameleoonClient.getDataFile()`;
|
|
8650
|
+
this.clientConfiguration.featureFlags.forEach((featureFlag, key) => {
|
|
8651
|
+
const variationsMap = new Map();
|
|
8652
|
+
featureFlag.variations.forEach((sourceVariation) => {
|
|
8653
|
+
var _a;
|
|
8654
|
+
const variablesMap = new Map();
|
|
8655
|
+
sourceVariation.variables.forEach((variable) => {
|
|
8656
|
+
try {
|
|
8657
|
+
const parsedVariable = Parser.parseFeatureVariable(variable).throw();
|
|
8658
|
+
variablesMap.set(variable.key, parsedVariable);
|
|
8659
|
+
}
|
|
8660
|
+
catch (err) {
|
|
8661
|
+
KameleoonLogger.error `Error parsing variable ${variable.key} of feature flag ${featureFlag.featureKey}: ${err}`;
|
|
8662
|
+
}
|
|
8663
|
+
});
|
|
8664
|
+
variationsMap.set(sourceVariation.key, {
|
|
8665
|
+
name: (_a = sourceVariation.name) !== null && _a !== void 0 ? _a : '',
|
|
8666
|
+
key: sourceVariation.key,
|
|
8667
|
+
id: null,
|
|
8668
|
+
experimentId: null,
|
|
8669
|
+
variables: variablesMap,
|
|
8670
|
+
});
|
|
8671
|
+
});
|
|
8672
|
+
const rules = featureFlag.rules.map((rule) => {
|
|
8673
|
+
const ruleVariations = new Map();
|
|
8674
|
+
rule.variationByExposition.forEach((varByExp) => {
|
|
8675
|
+
const baseVariation = variationsMap.get(varByExp.variationKey);
|
|
8676
|
+
if (!baseVariation)
|
|
8677
|
+
return;
|
|
8678
|
+
ruleVariations.set(baseVariation.key, {
|
|
8679
|
+
name: baseVariation.name,
|
|
8680
|
+
key: baseVariation.key,
|
|
8681
|
+
id: varByExp.variationId,
|
|
8682
|
+
experimentId: rule.experimentId,
|
|
8683
|
+
variables: baseVariation.variables,
|
|
8684
|
+
});
|
|
8685
|
+
});
|
|
8686
|
+
return { variations: ruleVariations };
|
|
8687
|
+
});
|
|
8688
|
+
dataFile.featureFlags.set(key, {
|
|
8689
|
+
variations: variationsMap,
|
|
8690
|
+
environmentEnabled: featureFlag.environmentEnabled,
|
|
8691
|
+
rules,
|
|
8692
|
+
defaultVariationKey: featureFlag.defaultVariationKey,
|
|
8693
|
+
});
|
|
8694
|
+
});
|
|
8695
|
+
KameleoonLogger.debug `RETURN: KameleoonClient.getDataFile() -> (dataFile: ${dataFile})`;
|
|
8696
|
+
return dataFile;
|
|
8697
|
+
}
|
|
8612
8698
|
setUserConsent({ visitorCode, consent, setData, }) {
|
|
8613
8699
|
if (this.stubMode) {
|
|
8614
8700
|
return;
|
|
@@ -8795,6 +8881,7 @@ class KameleoonClient {
|
|
|
8795
8881
|
return selected;
|
|
8796
8882
|
}
|
|
8797
8883
|
_getFeatureVariation({ visitorCode, featureKey, track, }) {
|
|
8884
|
+
var _a, _b;
|
|
8798
8885
|
KameleoonLogger.debug `CALL: KameleoonClient._getFeatureVariation(visitorCode: ${visitorCode}, featureKey: ${featureKey}, track: ${track})`;
|
|
8799
8886
|
if (!this.initialized) {
|
|
8800
8887
|
return buildExports.Err(new KameleoonError(KameleoonException.Initialization));
|
|
@@ -8845,7 +8932,9 @@ class KameleoonClient {
|
|
|
8845
8932
|
if (track && !isSimulated) {
|
|
8846
8933
|
this.tracker.scheduleVisitor(visitorCode, this._isConsentProvided(visitorCode));
|
|
8847
8934
|
}
|
|
8935
|
+
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
8936
|
const resultData = {
|
|
8937
|
+
name: variationName,
|
|
8849
8938
|
key: variationKey,
|
|
8850
8939
|
id: variationId,
|
|
8851
8940
|
experimentId,
|