@splitsoftware/splitio-commons 2.2.1-rc.0 → 2.2.1-rc.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/CHANGES.txt +2 -3
- package/README.md +0 -1
- package/cjs/evaluator/Engine.js +61 -40
- package/cjs/evaluator/combiners/and.js +6 -2
- package/cjs/evaluator/combiners/ifelseif.js +6 -6
- package/cjs/evaluator/condition/index.js +5 -6
- package/cjs/evaluator/index.js +11 -11
- package/cjs/evaluator/matchers/index.js +1 -3
- package/cjs/evaluator/matchers/matcherTypes.js +0 -1
- package/cjs/evaluator/matchersTransform/index.js +0 -4
- package/cjs/evaluator/parser/index.js +2 -2
- package/cjs/evaluator/value/sanitize.js +0 -1
- package/cjs/logger/constants.js +3 -5
- package/cjs/logger/messages/debug.js +2 -4
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/sdkManager/index.js +1 -2
- package/cjs/services/splitApi.js +4 -3
- package/cjs/storages/AbstractSplitsCacheSync.js +2 -5
- package/cjs/storages/KeyBuilder.js +0 -9
- package/cjs/storages/KeyBuilderCS.js +0 -3
- package/cjs/storages/KeyBuilderSS.js +0 -3
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
- package/cjs/storages/inLocalStorage/index.js +1 -5
- package/cjs/storages/inLocalStorage/validateCache.js +1 -2
- package/cjs/storages/inMemory/InMemoryStorage.js +0 -3
- package/cjs/storages/inMemory/InMemoryStorageCS.js +0 -4
- package/cjs/storages/inRedis/index.js +9 -5
- package/cjs/storages/pluggable/index.js +0 -2
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +4 -51
- package/cjs/sync/polling/pollingManagerCS.js +7 -7
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +33 -51
- package/cjs/sync/streaming/SSEHandler/index.js +0 -1
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +77 -106
- package/cjs/sync/streaming/constants.js +1 -2
- package/cjs/sync/streaming/pushManager.js +16 -3
- package/cjs/sync/syncManagerOnline.js +2 -2
- package/cjs/utils/constants/index.js +2 -3
- package/cjs/utils/labels/index.js +1 -2
- package/esm/evaluator/Engine.js +62 -40
- package/esm/evaluator/combiners/and.js +6 -2
- package/esm/evaluator/combiners/ifelseif.js +7 -7
- package/esm/evaluator/condition/index.js +5 -6
- package/esm/evaluator/index.js +12 -12
- package/esm/evaluator/matchers/index.js +1 -3
- package/esm/evaluator/matchers/matcherTypes.js +0 -1
- package/esm/evaluator/matchersTransform/index.js +0 -4
- package/esm/evaluator/parser/index.js +2 -2
- package/esm/evaluator/value/sanitize.js +0 -1
- package/esm/logger/constants.js +0 -2
- package/esm/logger/messages/debug.js +2 -4
- package/esm/logger/messages/warn.js +1 -1
- package/esm/sdkManager/index.js +1 -2
- package/esm/services/splitApi.js +4 -3
- package/esm/storages/AbstractSplitsCacheSync.js +2 -5
- package/esm/storages/KeyBuilder.js +0 -9
- package/esm/storages/KeyBuilderCS.js +0 -3
- package/esm/storages/KeyBuilderSS.js +0 -3
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -9
- package/esm/storages/inLocalStorage/index.js +1 -5
- package/esm/storages/inLocalStorage/validateCache.js +1 -2
- package/esm/storages/inMemory/InMemoryStorage.js +0 -3
- package/esm/storages/inMemory/InMemoryStorageCS.js +0 -4
- package/esm/storages/inRedis/index.js +9 -5
- package/esm/storages/pluggable/index.js +0 -2
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +4 -51
- package/esm/sync/polling/pollingManagerCS.js +7 -7
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +33 -51
- package/esm/sync/streaming/SSEHandler/index.js +1 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +73 -102
- package/esm/sync/streaming/constants.js +0 -1
- package/esm/sync/streaming/pushManager.js +19 -6
- package/esm/sync/syncManagerOnline.js +2 -2
- package/esm/utils/constants/index.js +1 -2
- package/esm/utils/labels/index.js +0 -1
- package/package.json +1 -1
- package/src/dtos/types.ts +8 -36
- package/src/evaluator/Engine.ts +69 -42
- package/src/evaluator/combiners/and.ts +4 -5
- package/src/evaluator/combiners/ifelseif.ts +9 -7
- package/src/evaluator/condition/engineUtils.ts +1 -1
- package/src/evaluator/condition/index.ts +12 -12
- package/src/evaluator/index.ts +14 -12
- package/src/evaluator/matchers/index.ts +1 -3
- package/src/evaluator/matchers/matcherTypes.ts +0 -1
- package/src/evaluator/matchersTransform/index.ts +0 -3
- package/src/evaluator/parser/index.ts +3 -3
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +4 -5
- package/src/logger/constants.ts +0 -2
- package/src/logger/messages/debug.ts +2 -4
- package/src/logger/messages/warn.ts +1 -1
- package/src/sdkManager/index.ts +2 -3
- package/src/services/splitApi.ts +4 -3
- package/src/services/types.ts +1 -1
- package/src/storages/AbstractSplitsCacheSync.ts +3 -6
- package/src/storages/KeyBuilder.ts +0 -12
- package/src/storages/KeyBuilderCS.ts +0 -4
- package/src/storages/KeyBuilderSS.ts +0 -4
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +14 -10
- package/src/storages/inLocalStorage/index.ts +1 -5
- package/src/storages/inLocalStorage/validateCache.ts +1 -3
- package/src/storages/inMemory/InMemoryStorage.ts +0 -3
- package/src/storages/inMemory/InMemoryStorageCS.ts +0 -4
- package/src/storages/inRedis/index.ts +11 -7
- package/src/storages/pluggable/index.ts +0 -2
- package/src/storages/types.ts +1 -33
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +4 -62
- package/src/sync/polling/fetchers/types.ts +0 -1
- package/src/sync/polling/pollingManagerCS.ts +7 -7
- package/src/sync/polling/syncTasks/splitsSyncTask.ts +1 -1
- package/src/sync/polling/types.ts +2 -2
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +42 -61
- package/src/sync/streaming/SSEHandler/index.ts +1 -2
- package/src/sync/streaming/SSEHandler/types.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +68 -98
- package/src/sync/streaming/constants.ts +0 -1
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +18 -6
- package/src/sync/streaming/types.ts +2 -3
- package/src/sync/syncManagerOnline.ts +2 -2
- package/src/utils/constants/index.ts +1 -2
- package/src/utils/labels/index.ts +0 -1
- package/src/utils/lang/index.ts +1 -1
- package/types/splitio.d.ts +1 -5
- package/cjs/evaluator/matchers/prerequisites.js +0 -22
- package/cjs/evaluator/matchers/rbsegment.js +0 -44
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -117
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +0 -61
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +0 -64
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +0 -64
- package/esm/evaluator/matchers/prerequisites.js +0 -18
- package/esm/evaluator/matchers/rbsegment.js +0 -40
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +0 -114
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +0 -58
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +0 -61
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +0 -61
- package/src/evaluator/matchers/prerequisites.ts +0 -24
- package/src/evaluator/matchers/rbsegment.ts +0 -62
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +0 -136
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +0 -68
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +0 -79
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +0 -76
package/CHANGES.txt
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
2.
|
|
2
|
-
-
|
|
3
|
-
- Added support for feature flag prerequisites.
|
|
1
|
+
2.2.1 (May 7, 2025)
|
|
2
|
+
- Updated Redis storage to avoid lazy require of the `ioredis` dependency when the SDK is initialized.
|
|
4
3
|
|
|
5
4
|
2.2.0 (March 28, 2025)
|
|
6
5
|
- Added a new optional argument to the client `getTreatment` methods to allow passing additional evaluation options, such as a map of properties to append to the generated impressions sent to Split backend. Read more in our docs.
|
package/README.md
CHANGED
|
@@ -27,7 +27,6 @@ Split has built and maintains SDKs for:
|
|
|
27
27
|
* .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
|
|
28
28
|
* Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
|
|
29
29
|
* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
|
|
30
|
-
* Elixir thin-client [Github](https://github.com/splitio/elixir-thin-client) [Docs](https://help.split.io/hc/en-us/articles/26988707417869-Elixir-Thin-Client-SDK)
|
|
31
30
|
* Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
|
|
32
31
|
* GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
|
|
33
32
|
* iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
|
package/cjs/evaluator/Engine.js
CHANGED
|
@@ -1,58 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Engine = void 0;
|
|
4
4
|
var lang_1 = require("../utils/lang");
|
|
5
5
|
var parser_1 = require("./parser");
|
|
6
6
|
var key_1 = require("../utils/key");
|
|
7
7
|
var thenable_1 = require("../utils/promise/thenable");
|
|
8
8
|
var labels_1 = require("../utils/labels");
|
|
9
9
|
var constants_1 = require("../utils/constants");
|
|
10
|
-
var constants_2 = require("../logger/constants");
|
|
11
|
-
var prerequisites_1 = require("./matchers/prerequisites");
|
|
12
10
|
function evaluationResult(result, defaultTreatment) {
|
|
13
11
|
return {
|
|
14
12
|
treatment: (0, lang_1.get)(result, 'treatment', defaultTreatment),
|
|
15
13
|
label: (0, lang_1.get)(result, 'label', labels_1.NO_CONDITION_MATCH)
|
|
16
14
|
};
|
|
17
15
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
var Engine = /** @class */ (function () {
|
|
17
|
+
function Engine(baseInfo, evaluator) {
|
|
18
|
+
this.baseInfo = baseInfo;
|
|
19
|
+
this.evaluator = evaluator;
|
|
20
|
+
// in case we don't have a default treatment in the instantiation, use 'control'
|
|
21
|
+
if (typeof this.baseInfo.defaultTreatment !== 'string') {
|
|
22
|
+
this.baseInfo.defaultTreatment = constants_1.CONTROL;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
Engine.parse = function (log, splitFlatStructure, storage) {
|
|
26
|
+
var conditions = splitFlatStructure.conditions;
|
|
27
|
+
var evaluator = (0, parser_1.parser)(log, conditions, storage);
|
|
28
|
+
return new Engine(splitFlatStructure, evaluator);
|
|
29
|
+
};
|
|
30
|
+
Engine.prototype.getKey = function () {
|
|
31
|
+
return this.baseInfo.name;
|
|
32
|
+
};
|
|
33
|
+
Engine.prototype.getTreatment = function (key, attributes, splitEvaluator) {
|
|
34
|
+
var _a = this.baseInfo, killed = _a.killed, seed = _a.seed, defaultTreatment = _a.defaultTreatment, trafficAllocation = _a.trafficAllocation, trafficAllocationSeed = _a.trafficAllocationSeed;
|
|
35
|
+
var parsedKey;
|
|
36
|
+
var treatment;
|
|
37
|
+
var label;
|
|
38
|
+
try {
|
|
39
|
+
parsedKey = (0, key_1.keyParser)(key);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
return {
|
|
43
|
+
treatment: constants_1.CONTROL,
|
|
44
|
+
label: labels_1.EXCEPTION
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (this.isGarbage()) {
|
|
48
|
+
treatment = constants_1.CONTROL;
|
|
49
|
+
label = labels_1.SPLIT_ARCHIVED;
|
|
50
|
+
}
|
|
51
|
+
else if (killed) {
|
|
52
|
+
treatment = defaultTreatment;
|
|
53
|
+
label = labels_1.SPLIT_KILLED;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
var evaluation = this.evaluator(parsedKey, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator);
|
|
57
|
+
// Evaluation could be async, so we should handle that case checking for a
|
|
58
|
+
// thenable object
|
|
59
|
+
if ((0, thenable_1.thenable)(evaluation)) {
|
|
60
|
+
return evaluation.then(function (result) { return evaluationResult(result, defaultTreatment); });
|
|
38
61
|
}
|
|
39
|
-
|
|
40
|
-
return
|
|
41
|
-
treatment: constants_1.CONTROL,
|
|
42
|
-
label: labels_1.SPLIT_ARCHIVED
|
|
43
|
-
};
|
|
44
|
-
if (killed) {
|
|
45
|
-
log.debug(constants_2.ENGINE_DEFAULT, ['Flag is killed']);
|
|
46
|
-
return {
|
|
47
|
-
treatment: defaultTreatment,
|
|
48
|
-
label: labels_1.SPLIT_KILLED
|
|
49
|
-
};
|
|
62
|
+
else {
|
|
63
|
+
return evaluationResult(evaluation, defaultTreatment);
|
|
50
64
|
}
|
|
51
|
-
var prerequisitesMet = prerequisiteMatcher({ key: key, attributes: attributes }, splitEvaluator);
|
|
52
|
-
return (0, thenable_1.thenable)(prerequisitesMet) ?
|
|
53
|
-
prerequisitesMet.then(evaluate) :
|
|
54
|
-
evaluate(prerequisitesMet);
|
|
55
65
|
}
|
|
66
|
+
return {
|
|
67
|
+
treatment: treatment,
|
|
68
|
+
label: label
|
|
69
|
+
};
|
|
56
70
|
};
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
Engine.prototype.isGarbage = function () {
|
|
72
|
+
return this.baseInfo.status === 'ARCHIVED';
|
|
73
|
+
};
|
|
74
|
+
Engine.prototype.getChangeNumber = function () {
|
|
75
|
+
return this.baseInfo.changeNumber;
|
|
76
|
+
};
|
|
77
|
+
return Engine;
|
|
78
|
+
}());
|
|
79
|
+
exports.Engine = Engine;
|
|
@@ -11,8 +11,12 @@ function andCombinerContext(log, matchers) {
|
|
|
11
11
|
log.debug(constants_1.ENGINE_COMBINER_AND, [hasMatchedAll]);
|
|
12
12
|
return hasMatchedAll;
|
|
13
13
|
}
|
|
14
|
-
return function andCombiner(
|
|
15
|
-
var
|
|
14
|
+
return function andCombiner() {
|
|
15
|
+
var params = [];
|
|
16
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
17
|
+
params[_i] = arguments[_i];
|
|
18
|
+
}
|
|
19
|
+
var matcherResults = matchers.map(function (matcher) { return matcher.apply(void 0, params); });
|
|
16
20
|
// If any matching result is a thenable we should use Promise.all
|
|
17
21
|
if ((0, lang_1.findIndex)(matcherResults, thenable_1.thenable) !== -1) {
|
|
18
22
|
return Promise.all(matcherResults).then(andResults);
|
|
@@ -14,12 +14,12 @@ function ifElseIfCombinerContext(log, predicates) {
|
|
|
14
14
|
label: labels_1.UNSUPPORTED_MATCHER_TYPE
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
|
|
17
|
+
function computeTreatment(predicateResults) {
|
|
18
|
+
var len = predicateResults.length;
|
|
19
|
+
for (var i = 0; i < len; i++) {
|
|
19
20
|
var evaluation = predicateResults[i];
|
|
20
21
|
if (evaluation !== undefined) {
|
|
21
|
-
|
|
22
|
-
log.debug(constants_2.ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
|
|
22
|
+
log.debug(constants_2.ENGINE_COMBINER_IFELSEIF, [evaluation.treatment]);
|
|
23
23
|
return evaluation;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -33,9 +33,9 @@ function ifElseIfCombinerContext(log, predicates) {
|
|
|
33
33
|
var predicateResults = predicates.map(function (evaluator) { return evaluator(key, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator); });
|
|
34
34
|
// if we find a thenable
|
|
35
35
|
if ((0, lang_1.findIndex)(predicateResults, thenable_1.thenable) !== -1) {
|
|
36
|
-
return Promise.all(predicateResults).then(function (results) { return
|
|
36
|
+
return Promise.all(predicateResults).then(function (results) { return computeTreatment(results); });
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return computeTreatment(predicateResults);
|
|
39
39
|
}
|
|
40
40
|
// if there is none predicates, then there was an error in parsing phase
|
|
41
41
|
if (!Array.isArray(predicates) || predicates.length === 0) {
|
|
@@ -7,12 +7,11 @@ var labels_1 = require("../../utils/labels");
|
|
|
7
7
|
// Build Evaluation object if and only if matchingResult is true
|
|
8
8
|
function match(log, matchingResult, bucketingKey, seed, treatments, label) {
|
|
9
9
|
if (matchingResult) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
true;
|
|
10
|
+
var treatment = (0, engineUtils_1.getTreatment)(log, bucketingKey, seed, treatments);
|
|
11
|
+
return {
|
|
12
|
+
treatment: treatment,
|
|
13
|
+
label: label
|
|
14
|
+
};
|
|
16
15
|
}
|
|
17
16
|
// else we should notify the engine to continue evaluating
|
|
18
17
|
return undefined;
|
package/cjs/evaluator/index.js
CHANGED
|
@@ -29,12 +29,12 @@ function evaluateFeature(log, key, splitName, attributes, storage) {
|
|
|
29
29
|
return treatmentException;
|
|
30
30
|
}
|
|
31
31
|
if ((0, thenable_1.thenable)(parsedSplit)) {
|
|
32
|
-
return parsedSplit.then(function (split) { return getEvaluation(log,
|
|
32
|
+
return parsedSplit.then(function (split) { return getEvaluation(log, split, key, attributes, storage); }).catch(
|
|
33
33
|
// Exception on async `getSplit` storage. For example, when the storage is redis or
|
|
34
34
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
35
35
|
function () { return treatmentException; });
|
|
36
36
|
}
|
|
37
|
-
return getEvaluation(log,
|
|
37
|
+
return getEvaluation(log, parsedSplit, key, attributes, storage);
|
|
38
38
|
}
|
|
39
39
|
exports.evaluateFeature = evaluateFeature;
|
|
40
40
|
function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
@@ -47,13 +47,13 @@ function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
|
47
47
|
return treatmentsException(splitNames);
|
|
48
48
|
}
|
|
49
49
|
return (0, thenable_1.thenable)(parsedSplits) ?
|
|
50
|
-
parsedSplits.then(function (splits) { return getEvaluations(log,
|
|
50
|
+
parsedSplits.then(function (splits) { return getEvaluations(log, splitNames, splits, key, attributes, storage); })
|
|
51
51
|
.catch(function () {
|
|
52
52
|
// Exception on async `getSplits` storage. For example, when the storage is redis or
|
|
53
53
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
54
54
|
return treatmentsException(splitNames);
|
|
55
55
|
}) :
|
|
56
|
-
getEvaluations(log,
|
|
56
|
+
getEvaluations(log, splitNames, parsedSplits, key, attributes, storage);
|
|
57
57
|
}
|
|
58
58
|
exports.evaluateFeatures = evaluateFeatures;
|
|
59
59
|
function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
|
|
@@ -90,37 +90,37 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
|
|
|
90
90
|
evaluate(storedFlagNames);
|
|
91
91
|
}
|
|
92
92
|
exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
|
|
93
|
-
function getEvaluation(log,
|
|
93
|
+
function getEvaluation(log, splitJSON, key, attributes, storage) {
|
|
94
94
|
var evaluation = {
|
|
95
95
|
treatment: constants_1.CONTROL,
|
|
96
96
|
label: labels_1.SPLIT_NOT_FOUND,
|
|
97
97
|
config: null
|
|
98
98
|
};
|
|
99
99
|
if (splitJSON) {
|
|
100
|
-
var
|
|
101
|
-
evaluation =
|
|
100
|
+
var split_1 = Engine_1.Engine.parse(log, splitJSON, storage);
|
|
101
|
+
evaluation = split_1.getTreatment(key, attributes, evaluateFeature);
|
|
102
102
|
// If the storage is async and the evaluated flag uses segments or dependencies, evaluation is thenable
|
|
103
103
|
if ((0, thenable_1.thenable)(evaluation)) {
|
|
104
104
|
return evaluation.then(function (result) {
|
|
105
|
-
result.changeNumber =
|
|
105
|
+
result.changeNumber = split_1.getChangeNumber();
|
|
106
106
|
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
|
|
107
107
|
result.impressionsDisabled = splitJSON.impressionsDisabled;
|
|
108
108
|
return result;
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
|
-
evaluation.changeNumber =
|
|
112
|
+
evaluation.changeNumber = split_1.getChangeNumber(); // Always sync and optional
|
|
113
113
|
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
|
|
114
114
|
evaluation.impressionsDisabled = splitJSON.impressionsDisabled;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
return evaluation;
|
|
118
118
|
}
|
|
119
|
-
function getEvaluations(log,
|
|
119
|
+
function getEvaluations(log, splitNames, splits, key, attributes, storage) {
|
|
120
120
|
var result = {};
|
|
121
121
|
var thenables = [];
|
|
122
122
|
splitNames.forEach(function (splitName) {
|
|
123
|
-
var evaluation = getEvaluation(log,
|
|
123
|
+
var evaluation = getEvaluation(log, splits[splitName], key, attributes, storage);
|
|
124
124
|
if ((0, thenable_1.thenable)(evaluation)) {
|
|
125
125
|
thenables.push(evaluation.then(function (res) {
|
|
126
126
|
result[splitName] = res;
|
|
@@ -24,7 +24,6 @@ var semver_gte_1 = require("./semver_gte");
|
|
|
24
24
|
var semver_lte_1 = require("./semver_lte");
|
|
25
25
|
var semver_between_1 = require("./semver_between");
|
|
26
26
|
var semver_inlist_1 = require("./semver_inlist");
|
|
27
|
-
var rbsegment_1 = require("./rbsegment");
|
|
28
27
|
var matchers = [
|
|
29
28
|
undefined,
|
|
30
29
|
all_1.allMatcherContext,
|
|
@@ -49,8 +48,7 @@ var matchers = [
|
|
|
49
48
|
semver_lte_1.lessThanEqualToSemverMatcherContext,
|
|
50
49
|
semver_between_1.betweenSemverMatcherContext,
|
|
51
50
|
semver_inlist_1.inListSemverMatcherContext,
|
|
52
|
-
large_segment_1.largeSegmentMatcherContext,
|
|
53
|
-
rbsegment_1.ruleBasedSegmentMatcherContext // IN_RULE_BASED_SEGMENT: 24
|
|
51
|
+
large_segment_1.largeSegmentMatcherContext, // IN_LARGE_SEGMENT: 23
|
|
54
52
|
];
|
|
55
53
|
/**
|
|
56
54
|
* Matcher factory.
|
|
@@ -81,10 +81,6 @@ function matchersTransform(matchers) {
|
|
|
81
81
|
type === matcherTypes_1.matcherTypes.LESS_THAN_OR_EQUAL_TO_SEMVER) {
|
|
82
82
|
value = stringMatcherData;
|
|
83
83
|
}
|
|
84
|
-
else if (type === matcherTypes_1.matcherTypes.IN_RULE_BASED_SEGMENT) {
|
|
85
|
-
value = (0, segment_1.segmentTransform)(userDefinedSegmentMatcherData);
|
|
86
|
-
dataType = matcherTypes_1.matcherDataTypes.NOT_SPECIFIED;
|
|
87
|
-
}
|
|
88
84
|
return {
|
|
89
85
|
attribute: attribute,
|
|
90
86
|
negate: negate,
|
|
@@ -53,9 +53,9 @@ function parser(log, conditions, storage) {
|
|
|
53
53
|
// and break the loop
|
|
54
54
|
break;
|
|
55
55
|
}
|
|
56
|
-
predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions),
|
|
56
|
+
predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions), treatments_1.Treatments.parse(partitions), label, conditionType));
|
|
57
57
|
}
|
|
58
|
-
//
|
|
58
|
+
// Instanciate evaluator given the set of conditions using if else if logic
|
|
59
59
|
return (0, ifelseif_1.ifElseIfCombinerContext)(log, predicates);
|
|
60
60
|
}
|
|
61
61
|
exports.parser = parser;
|
|
@@ -52,7 +52,6 @@ function getProcessingFunction(matcherTypeID, dataType) {
|
|
|
52
52
|
case matcherTypes_1.matcherTypes.BETWEEN:
|
|
53
53
|
return dataType === 'DATETIME' ? convertions_1.zeroSinceSS : undefined;
|
|
54
54
|
case matcherTypes_1.matcherTypes.IN_SPLIT_TREATMENT:
|
|
55
|
-
case matcherTypes_1.matcherTypes.IN_RULE_BASED_SEGMENT:
|
|
56
55
|
return dependencyProcessor;
|
|
57
56
|
default:
|
|
58
57
|
return undefined;
|
package/cjs/logger/constants.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENGINE_VALUE_INVALID = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.
|
|
4
|
-
exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MEMBERSHIPS_UPDATE = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY =
|
|
5
|
-
exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN =
|
|
3
|
+
exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.ENGINE_MATCHER_RESULT = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_UPDATE = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
|
|
4
|
+
exports.ERROR_STORAGE_INVALID = exports.ERROR_HTTP = exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MEMBERSHIPS_UPDATE = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY = void 0;
|
|
5
|
+
exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* Message codes used to trim string log messages from commons and client-side API modules,
|
|
8
8
|
* in order to reduce the minimal SDK size for Browser and eventually other client-side environments.
|
|
@@ -26,14 +26,12 @@ exports.RETRIEVE_MANAGER = 29;
|
|
|
26
26
|
exports.SYNC_OFFLINE_DATA = 30;
|
|
27
27
|
exports.SYNC_SPLITS_FETCH = 31;
|
|
28
28
|
exports.SYNC_SPLITS_UPDATE = 32;
|
|
29
|
-
exports.SYNC_RBS_UPDATE = 33;
|
|
30
29
|
exports.STREAMING_NEW_MESSAGE = 35;
|
|
31
30
|
exports.SYNC_TASK_START = 36;
|
|
32
31
|
exports.SYNC_TASK_EXECUTE = 37;
|
|
33
32
|
exports.SYNC_TASK_STOP = 38;
|
|
34
33
|
exports.SETTINGS_SPLITS_FILTER = 39;
|
|
35
34
|
exports.ENGINE_MATCHER_RESULT = 40;
|
|
36
|
-
exports.ENGINE_DEFAULT = 41;
|
|
37
35
|
exports.CLIENT_READY_FROM_CACHE = 100;
|
|
38
36
|
exports.CLIENT_READY = 101;
|
|
39
37
|
exports.IMPRESSION = 102;
|
|
@@ -15,7 +15,6 @@ exports.codesDebug = info_1.codesInfo.concat([
|
|
|
15
15
|
[c.ENGINE_VALUE, c.LOG_PREFIX_ENGINE_VALUE + 'Extracted attribute `%s`. %s will be used for matching.'],
|
|
16
16
|
[c.ENGINE_SANITIZE, c.LOG_PREFIX_ENGINE + ':sanitize: Attempted to sanitize %s which should be of type %s. Sanitized and processed value => %s'],
|
|
17
17
|
[c.ENGINE_MATCHER_RESULT, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] Result: %s. Rule value: %s. Evaluation value: %s'],
|
|
18
|
-
[c.ENGINE_DEFAULT, c.LOG_PREFIX_ENGINE + 'Evaluates to default treatment. %s'],
|
|
19
18
|
// SDK
|
|
20
19
|
[c.CLEANUP_REGISTERING, c.LOG_PREFIX_CLEANUP + 'Registering cleanup handler %s'],
|
|
21
20
|
[c.CLEANUP_DEREGISTERING, c.LOG_PREFIX_CLEANUP + 'Deregistering cleanup handler %s'],
|
|
@@ -24,9 +23,8 @@ exports.codesDebug = info_1.codesInfo.concat([
|
|
|
24
23
|
[c.RETRIEVE_MANAGER, 'Retrieving manager instance.'],
|
|
25
24
|
// synchronizer
|
|
26
25
|
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
|
|
27
|
-
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s
|
|
28
|
-
[c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s.'],
|
|
29
|
-
[c.SYNC_RBS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New rule-based segments %s. Removed rule-based segments %s.'],
|
|
26
|
+
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s'],
|
|
27
|
+
[c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s. Segment names collected %s'],
|
|
30
28
|
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
|
|
31
29
|
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + ': Starting %s. Running each %s millis'],
|
|
32
30
|
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + ': Running %s'],
|
|
@@ -35,7 +35,7 @@ exports.codesWarn = error_1.codesError.concat([
|
|
|
35
35
|
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
|
|
36
36
|
[c.WARN_SDK_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
|
|
37
37
|
[c.STREAMING_PARSING_MEMBERSHIPS_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching Memberships due to an error processing %s notification: %s'],
|
|
38
|
-
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing
|
|
38
|
+
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing SPLIT_UPDATE notification: %s'],
|
|
39
39
|
[c.WARN_INVALID_FLAGSET, '%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.'],
|
|
40
40
|
[c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
|
|
41
41
|
[c.WARN_FLAGSET_WITHOUT_FLAGS, '%s: you passed %s flag set that does not contain cached feature flag names. Please double check what flag sets are in use in the Split user interface.'],
|
package/cjs/sdkManager/index.js
CHANGED
|
@@ -29,8 +29,7 @@ function objectToView(splitObject) {
|
|
|
29
29
|
configs: splitObject.configurations || {},
|
|
30
30
|
sets: splitObject.sets || [],
|
|
31
31
|
defaultTreatment: splitObject.defaultTreatment,
|
|
32
|
-
impressionsDisabled: splitObject.impressionsDisabled === true
|
|
33
|
-
prerequisites: (splitObject.prerequisites || []).map(function (p) { return ({ flagName: p.n, treatments: p.ts }); }),
|
|
32
|
+
impressionsDisabled: splitObject.impressionsDisabled === true
|
|
34
33
|
};
|
|
35
34
|
}
|
|
36
35
|
function objectsToViews(splitObjects) {
|
package/cjs/services/splitApi.js
CHANGED
|
@@ -20,6 +20,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
20
20
|
var urls = settings.urls;
|
|
21
21
|
var filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
|
|
22
22
|
var SplitSDKImpressionsMode = settings.sync.impressionsMode;
|
|
23
|
+
var flagSpecVersion = settings.sync.flagSpecVersion;
|
|
23
24
|
var splitHttpClient = (0, splitHttpClient_1.splitHttpClientFactory)(settings, platform);
|
|
24
25
|
return {
|
|
25
26
|
// @TODO throw errors if health check requests fail, to log them in the Synchronizer
|
|
@@ -32,7 +33,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
32
33
|
return splitHttpClient(url).then(function () { return true; }).catch(function () { return false; });
|
|
33
34
|
},
|
|
34
35
|
fetchAuth: function (userMatchingKeys) {
|
|
35
|
-
var url = urls.auth + "/v2/auth?s=" +
|
|
36
|
+
var url = urls.auth + "/v2/auth?s=" + flagSpecVersion;
|
|
36
37
|
if (userMatchingKeys) { // `userMatchingKeys` is undefined in server-side
|
|
37
38
|
var queryParams = userMatchingKeys.map(userKeyToQueryParam).join('&');
|
|
38
39
|
if (queryParams)
|
|
@@ -40,8 +41,8 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
40
41
|
}
|
|
41
42
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(constants_1.TOKEN));
|
|
42
43
|
},
|
|
43
|
-
fetchSplitChanges: function (since, noCache, till
|
|
44
|
-
var url = urls.sdk + "/splitChanges?s=" +
|
|
44
|
+
fetchSplitChanges: function (since, noCache, till) {
|
|
45
|
+
var url = urls.sdk + "/splitChanges?s=" + flagSpecVersion + "&since=" + since + (filterQueryString || '') + (till ? '&till=' + till : '');
|
|
45
46
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS))
|
|
46
47
|
.catch(function (err) {
|
|
47
48
|
if (err.statusCode === 414)
|
|
@@ -53,8 +53,8 @@ exports.AbstractSplitsCacheSync = AbstractSplitsCacheSync;
|
|
|
53
53
|
* Given a parsed split, it returns a boolean flagging if its conditions use segments matchers (rules & whitelists).
|
|
54
54
|
* This util is intended to simplify the implementation of `splitsCache::usesSegments` method
|
|
55
55
|
*/
|
|
56
|
-
function usesSegments(
|
|
57
|
-
var conditions =
|
|
56
|
+
function usesSegments(split) {
|
|
57
|
+
var conditions = split.conditions || [];
|
|
58
58
|
for (var i = 0; i < conditions.length; i++) {
|
|
59
59
|
var matchers = conditions[i].matcherGroup.matchers;
|
|
60
60
|
for (var j = 0; j < matchers.length; j++) {
|
|
@@ -63,9 +63,6 @@ function usesSegments(ruleEntity) {
|
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
var excluded = ruleEntity.excluded;
|
|
67
|
-
if (excluded && excluded.segments && excluded.segments.length > 0)
|
|
68
|
-
return true;
|
|
69
66
|
return false;
|
|
70
67
|
}
|
|
71
68
|
exports.usesSegments = usesSegments;
|
|
@@ -28,15 +28,6 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
28
28
|
KeyBuilder.prototype.buildSplitKeyPrefix = function () {
|
|
29
29
|
return this.prefix + ".split.";
|
|
30
30
|
};
|
|
31
|
-
KeyBuilder.prototype.buildRBSegmentKey = function (rbsegmentName) {
|
|
32
|
-
return this.prefix + ".rbsegment." + rbsegmentName;
|
|
33
|
-
};
|
|
34
|
-
KeyBuilder.prototype.buildRBSegmentsTillKey = function () {
|
|
35
|
-
return this.prefix + ".rbsegments.till";
|
|
36
|
-
};
|
|
37
|
-
KeyBuilder.prototype.buildRBSegmentKeyPrefix = function () {
|
|
38
|
-
return this.prefix + ".rbsegment.";
|
|
39
|
-
};
|
|
40
31
|
KeyBuilder.prototype.buildSegmentNameKey = function (segmentName) {
|
|
41
32
|
return this.prefix + ".segment." + segmentName;
|
|
42
33
|
};
|
|
@@ -35,9 +35,6 @@ var KeyBuilderCS = /** @class */ (function (_super) {
|
|
|
35
35
|
KeyBuilderCS.prototype.isSplitKey = function (key) {
|
|
36
36
|
return (0, lang_1.startsWith)(key, this.prefix + ".split.");
|
|
37
37
|
};
|
|
38
|
-
KeyBuilderCS.prototype.isRBSegmentKey = function (key) {
|
|
39
|
-
return (0, lang_1.startsWith)(key, this.prefix + ".rbsegment.");
|
|
40
|
-
};
|
|
41
38
|
KeyBuilderCS.prototype.buildSplitsWithSegmentCountKey = function () {
|
|
42
39
|
return this.prefix + ".splits.usingSegments";
|
|
43
40
|
};
|
|
@@ -42,9 +42,6 @@ var KeyBuilderSS = /** @class */ (function (_super) {
|
|
|
42
42
|
KeyBuilderSS.prototype.searchPatternForSplitKeys = function () {
|
|
43
43
|
return this.buildSplitKeyPrefix() + "*";
|
|
44
44
|
};
|
|
45
|
-
KeyBuilderSS.prototype.searchPatternForRBSegmentKeys = function () {
|
|
46
|
-
return this.buildRBSegmentKeyPrefix() + "*";
|
|
47
|
-
};
|
|
48
45
|
/* Telemetry keys */
|
|
49
46
|
KeyBuilderSS.prototype.buildLatencyKey = function (method, bucket) {
|
|
50
47
|
return this.latencyPrefix + "::" + this.versionablePrefix + "/" + exports.METHOD_NAMES[method] + "/" + bucket;
|
|
@@ -41,13 +41,15 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
41
41
|
};
|
|
42
42
|
SplitsCacheInLocal.prototype._incrementCounts = function (split) {
|
|
43
43
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
localStorage.setItem(ttKey, (0, lang_1.toNumber)(localStorage.getItem(ttKey)) + 1);
|
|
47
|
-
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split)) {
|
|
48
|
-
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
44
|
+
if (split) {
|
|
45
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
49
46
|
// @ts-expect-error
|
|
50
|
-
localStorage.setItem(
|
|
47
|
+
localStorage.setItem(ttKey, (0, lang_1.toNumber)(localStorage.getItem(ttKey)) + 1);
|
|
48
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split)) {
|
|
49
|
+
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
50
|
+
// @ts-expect-error
|
|
51
|
+
localStorage.setItem(segmentsCountKey, (0, lang_1.toNumber)(localStorage.getItem(segmentsCountKey)) + 1);
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
catch (e) {
|
|
@@ -156,9 +158,12 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
156
158
|
return true;
|
|
157
159
|
var storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
|
|
158
160
|
var splitsWithSegmentsCount = storedCount === null ? 0 : (0, lang_1.toNumber)(storedCount);
|
|
159
|
-
|
|
160
|
-
splitsWithSegmentsCount > 0
|
|
161
|
-
|
|
161
|
+
if ((0, lang_1.isFiniteNumber)(splitsWithSegmentsCount)) {
|
|
162
|
+
return splitsWithSegmentsCount > 0;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
162
167
|
};
|
|
163
168
|
SplitsCacheInLocal.prototype.getNamesByFlagSets = function (flagSets) {
|
|
164
169
|
var _this = this;
|
|
@@ -8,7 +8,6 @@ var KeyBuilder_1 = require("../KeyBuilder");
|
|
|
8
8
|
var KeyBuilderCS_1 = require("../KeyBuilderCS");
|
|
9
9
|
var isLocalStorageAvailable_1 = require("../../utils/env/isLocalStorageAvailable");
|
|
10
10
|
var SplitsCacheInLocal_1 = require("./SplitsCacheInLocal");
|
|
11
|
-
var RBSegmentsCacheInLocal_1 = require("./RBSegmentsCacheInLocal");
|
|
12
11
|
var MySegmentsCacheInLocal_1 = require("./MySegmentsCacheInLocal");
|
|
13
12
|
var InMemoryStorageCS_1 = require("../inMemory/InMemoryStorageCS");
|
|
14
13
|
var constants_1 = require("./constants");
|
|
@@ -33,12 +32,10 @@ function InLocalStorage(options) {
|
|
|
33
32
|
var matchingKey = (0, key_1.getMatching)(settings.core.key);
|
|
34
33
|
var keys = new KeyBuilderCS_1.KeyBuilderCS(prefix, matchingKey);
|
|
35
34
|
var splits = new SplitsCacheInLocal_1.SplitsCacheInLocal(settings, keys);
|
|
36
|
-
var rbSegments = new RBSegmentsCacheInLocal_1.RBSegmentsCacheInLocal(settings, keys);
|
|
37
35
|
var segments = new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, keys);
|
|
38
36
|
var largeSegments = new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, (0, KeyBuilderCS_1.myLargeSegmentsKeyBuilder)(prefix, matchingKey));
|
|
39
37
|
return {
|
|
40
38
|
splits: splits,
|
|
41
|
-
rbSegments: rbSegments,
|
|
42
39
|
segments: segments,
|
|
43
40
|
largeSegments: largeSegments,
|
|
44
41
|
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(impressionsQueueSize),
|
|
@@ -47,14 +44,13 @@ function InLocalStorage(options) {
|
|
|
47
44
|
telemetry: (0, TelemetryCacheInMemory_1.shouldRecordTelemetry)(params) ? new TelemetryCacheInMemory_1.TelemetryCacheInMemory(splits, segments) : undefined,
|
|
48
45
|
uniqueKeys: new UniqueKeysCacheInMemoryCS_1.UniqueKeysCacheInMemoryCS(),
|
|
49
46
|
validateCache: function () {
|
|
50
|
-
return (0, validateCache_1.validateCache)(options, settings, keys, splits,
|
|
47
|
+
return (0, validateCache_1.validateCache)(options, settings, keys, splits, segments, largeSegments);
|
|
51
48
|
},
|
|
52
49
|
destroy: function () { },
|
|
53
50
|
// When using shared instantiation with MEMORY we reuse everything but segments (they are customer per key).
|
|
54
51
|
shared: function (matchingKey) {
|
|
55
52
|
return {
|
|
56
53
|
splits: this.splits,
|
|
57
|
-
rbSegments: this.rbSegments,
|
|
58
54
|
segments: new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, new KeyBuilderCS_1.KeyBuilderCS(prefix, matchingKey)),
|
|
59
55
|
largeSegments: new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, (0, KeyBuilderCS_1.myLargeSegmentsKeyBuilder)(prefix, matchingKey)),
|
|
60
56
|
impressions: this.impressions,
|
|
@@ -57,12 +57,11 @@ function validateExpiration(options, settings, keys, currentTimestamp, isThereCa
|
|
|
57
57
|
*
|
|
58
58
|
* @returns `true` if cache is ready to be used, `false` otherwise (cache was cleared or there is no cache)
|
|
59
59
|
*/
|
|
60
|
-
function validateCache(options, settings, keys, splits,
|
|
60
|
+
function validateCache(options, settings, keys, splits, segments, largeSegments) {
|
|
61
61
|
var currentTimestamp = Date.now();
|
|
62
62
|
var isThereCache = splits.getChangeNumber() > -1;
|
|
63
63
|
if (validateExpiration(options, settings, keys, currentTimestamp, isThereCache)) {
|
|
64
64
|
splits.clear();
|
|
65
|
-
rbSegments.clear();
|
|
66
65
|
segments.clear();
|
|
67
66
|
largeSegments.clear();
|
|
68
67
|
// Update last clear timestamp
|