@splitsoftware/splitio-commons 1.8.2-rc.0 → 1.8.2-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 +24 -22
- package/README.md +1 -1
- package/cjs/logger/constants.js +3 -3
- package/cjs/logger/messages/debug.js +7 -7
- package/cjs/logger/messages/error.js +2 -2
- package/cjs/logger/messages/info.js +3 -3
- package/cjs/logger/messages/warn.js +7 -7
- package/cjs/sdkClient/client.js +20 -20
- package/cjs/sdkClient/clientAttributesDecoration.js +8 -8
- package/cjs/sdkClient/clientInputValidation.js +10 -10
- package/cjs/sdkClient/sdkClient.js +1 -1
- package/cjs/sdkFactory/index.js +1 -1
- package/cjs/sdkManager/index.js +10 -8
- package/cjs/services/splitApi.js +1 -0
- package/cjs/services/splitHttpClient.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +6 -10
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +8 -16
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +20 -23
- package/cjs/storages/pluggable/SplitsCachePluggable.js +18 -18
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +5 -12
- package/cjs/sync/streaming/pushManager.js +1 -1
- package/cjs/sync/submitters/telemetrySubmitter.js +2 -2
- package/cjs/utils/inputValidation/apiKey.js +26 -25
- package/cjs/utils/inputValidation/preloadedData.js +3 -3
- package/cjs/utils/inputValidation/split.js +1 -1
- package/cjs/utils/inputValidation/splits.js +2 -2
- package/cjs/utils/settingsValidation/index.js +1 -1
- package/esm/logger/constants.js +2 -2
- package/esm/logger/messages/debug.js +7 -7
- package/esm/logger/messages/error.js +2 -2
- package/esm/logger/messages/info.js +3 -3
- package/esm/logger/messages/warn.js +7 -7
- package/esm/sdkClient/client.js +20 -20
- package/esm/sdkClient/clientAttributesDecoration.js +8 -8
- package/esm/sdkClient/clientInputValidation.js +10 -10
- package/esm/sdkClient/sdkClient.js +1 -1
- package/esm/sdkFactory/index.js +1 -1
- package/esm/sdkManager/index.js +10 -8
- package/esm/services/splitApi.js +1 -0
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +6 -10
- package/esm/storages/inMemory/SplitsCacheInMemory.js +8 -16
- package/esm/storages/inRedis/SplitsCacheInRedis.js +20 -23
- package/esm/storages/pluggable/SplitsCachePluggable.js +18 -18
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +5 -12
- package/esm/sync/streaming/pushManager.js +1 -1
- package/esm/sync/submitters/telemetrySubmitter.js +2 -2
- package/esm/utils/inputValidation/apiKey.js +27 -26
- package/esm/utils/inputValidation/preloadedData.js +3 -3
- package/esm/utils/inputValidation/split.js +1 -1
- package/esm/utils/inputValidation/splits.js +2 -2
- package/esm/utils/settingsValidation/index.js +1 -1
- package/package.json +1 -1
- package/src/logger/constants.ts +2 -2
- package/src/logger/messages/debug.ts +7 -7
- package/src/logger/messages/error.ts +2 -2
- package/src/logger/messages/info.ts +3 -3
- package/src/logger/messages/warn.ts +7 -7
- package/src/sdkClient/client.ts +20 -20
- package/src/sdkClient/clientAttributesDecoration.ts +10 -10
- package/src/sdkClient/clientInputValidation.ts +10 -10
- package/src/sdkClient/sdkClient.ts +3 -3
- package/src/sdkFactory/index.ts +1 -1
- package/src/sdkManager/index.ts +11 -8
- package/src/services/splitApi.ts +1 -0
- package/src/services/splitHttpClient.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +6 -10
- package/src/storages/inMemory/AttributesCacheInMemory.ts +7 -6
- package/src/storages/inMemory/SplitsCacheInMemory.ts +6 -14
- package/src/storages/inRedis/SplitsCacheInRedis.ts +19 -20
- package/src/storages/pluggable/SplitsCachePluggable.ts +17 -18
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +6 -12
- package/src/sync/streaming/pushManager.ts +1 -1
- package/src/sync/submitters/telemetrySubmitter.ts +2 -2
- package/src/types.ts +147 -140
- package/src/utils/inputValidation/apiKey.ts +25 -24
- package/src/utils/inputValidation/preloadedData.ts +3 -3
- package/src/utils/inputValidation/split.ts +1 -1
- package/src/utils/inputValidation/splits.ts +1 -1
- package/src/utils/settingsValidation/index.ts +1 -1
- package/types/logger/constants.d.ts +1 -1
- package/types/sdkClient/clientAttributesDecoration.d.ts +7 -7
- package/types/storages/inMemory/AttributesCacheInMemory.d.ts +4 -3
- package/types/types.d.ts +142 -135
- package/types/utils/inputValidation/apiKey.d.ts +5 -5
- package/types/utils/inputValidation/sdkKey.d.ts +7 -0
- package/types/utils/settingsValidation/index.d.ts +1 -1
- package/types/storages/metadataBuilder.d.ts +0 -3
- /package/types/storages/inMemory/{uniqueKeysCacheInMemory.d.ts → UniqueKeysCacheInMemory.d.ts} +0 -0
- /package/types/storages/inMemory/{uniqueKeysCacheInMemoryCS.d.ts → UniqueKeysCacheInMemoryCS.d.ts} +0 -0
- /package/types/storages/inRedis/{uniqueKeysCacheInRedis.d.ts → UniqueKeysCacheInRedis.d.ts} +0 -0
|
@@ -38,19 +38,15 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
38
38
|
}
|
|
39
39
|
SplitsCacheInRedis.prototype._decrementCounts = function (split) {
|
|
40
40
|
var _this = this;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
}
|
|
41
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
42
|
+
return this.redis.decr(ttKey).then(function (count) {
|
|
43
|
+
if (count === 0)
|
|
44
|
+
return _this.redis.del(ttKey);
|
|
45
|
+
});
|
|
48
46
|
};
|
|
49
47
|
SplitsCacheInRedis.prototype._incrementCounts = function (split) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return this.redis.incr(ttKey);
|
|
53
|
-
}
|
|
48
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
49
|
+
return this.redis.incr(ttKey);
|
|
54
50
|
};
|
|
55
51
|
/**
|
|
56
52
|
* Add a given split.
|
|
@@ -68,18 +64,19 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
68
64
|
newStringifiedSplit = JSON.stringify(split);
|
|
69
65
|
}
|
|
70
66
|
catch (e) {
|
|
71
|
-
throw new Error('Error parsing
|
|
67
|
+
throw new Error('Error parsing feature flag definition: ' + e);
|
|
72
68
|
}
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
return _this.redis.set(splitKey, newStringifiedSplit).then(function () {
|
|
70
|
+
// avoid unnecessary increment/decrement operations
|
|
71
|
+
if (parsedPreviousSplit && parsedPreviousSplit.trafficTypeName === split.trafficTypeName)
|
|
72
|
+
return;
|
|
73
|
+
// update traffic type counts
|
|
74
|
+
return _this._incrementCounts(split).then(function () {
|
|
75
|
+
if (parsedPreviousSplit)
|
|
76
|
+
return _this._decrementCounts(parsedPreviousSplit);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}).then(function () { return true; });
|
|
83
80
|
};
|
|
84
81
|
/**
|
|
85
82
|
* Add a list of splits.
|
|
@@ -229,7 +226,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
229
226
|
return Promise.resolve(splits);
|
|
230
227
|
})
|
|
231
228
|
.catch(function (e) {
|
|
232
|
-
_this.log.error(constants_1.LOG_PREFIX + ("Could not grab
|
|
229
|
+
_this.log.error(constants_1.LOG_PREFIX + ("Could not grab feature flags due to an error: " + e + "."));
|
|
233
230
|
return Promise.reject(e);
|
|
234
231
|
});
|
|
235
232
|
};
|
|
@@ -25,19 +25,15 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
25
25
|
}
|
|
26
26
|
SplitsCachePluggable.prototype._decrementCounts = function (split) {
|
|
27
27
|
var _this = this;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
}
|
|
28
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
29
|
+
return this.wrapper.decr(ttKey).then(function (count) {
|
|
30
|
+
if (count === 0)
|
|
31
|
+
return _this.wrapper.del(ttKey);
|
|
32
|
+
});
|
|
35
33
|
};
|
|
36
34
|
SplitsCachePluggable.prototype._incrementCounts = function (split) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return this.wrapper.incr(ttKey);
|
|
40
|
-
}
|
|
35
|
+
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
36
|
+
return this.wrapper.incr(ttKey);
|
|
41
37
|
};
|
|
42
38
|
/**
|
|
43
39
|
* Add a given split.
|
|
@@ -55,14 +51,18 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
55
51
|
stringifiedNewSplit = JSON.stringify(split);
|
|
56
52
|
}
|
|
57
53
|
catch (e) {
|
|
58
|
-
throw new Error('Error parsing
|
|
54
|
+
throw new Error('Error parsing feature flag definition: ' + e);
|
|
59
55
|
}
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
return _this.wrapper.set(splitKey, stringifiedNewSplit).then(function () {
|
|
57
|
+
// avoid unnecessary increment/decrement operations
|
|
58
|
+
if (parsedPreviousSplit && parsedPreviousSplit.trafficTypeName === split.trafficTypeName)
|
|
59
|
+
return;
|
|
60
|
+
// update traffic type counts
|
|
61
|
+
return _this._incrementCounts(split).then(function () {
|
|
62
|
+
if (parsedPreviousSplit)
|
|
63
|
+
return _this._decrementCounts(parsedPreviousSplit);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
66
|
}).then(function () { return true; });
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
@@ -84,7 +84,7 @@ function segmentChangesUpdaterFactory(log, segmentChangesFetcher, segments, read
|
|
|
84
84
|
// @TODO although factory status is destroyed, synchronization is not stopped
|
|
85
85
|
if (readiness)
|
|
86
86
|
readiness.destroy();
|
|
87
|
-
log.error(constants_2.LOG_PREFIX_INSTANTIATION + ": you passed a client-side type authorizationKey, please grab an
|
|
87
|
+
log.error(constants_2.LOG_PREFIX_INSTANTIATION + ": you passed a client-side type authorizationKey, please grab an SDK Key from the Split user interface that is of type server-side.");
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
90
|
log.warn(constants_2.LOG_PREFIX_SYNC_SEGMENTS + "Error while doing fetch of segments. " + error);
|
|
@@ -5,7 +5,6 @@ var sets_1 = require("../../../utils/lang/sets");
|
|
|
5
5
|
var timeout_1 = require("../../../utils/promise/timeout");
|
|
6
6
|
var constants_1 = require("../../../readiness/constants");
|
|
7
7
|
var constants_2 = require("../../../logger/constants");
|
|
8
|
-
var maps_1 = require("../../../utils/lang/maps");
|
|
9
8
|
// Checks that all registered segments have been fetched (changeNumber !== -1 for every segment).
|
|
10
9
|
// Returns a promise that could be rejected.
|
|
11
10
|
// @TODO review together with Segments and MySegments storage APIs
|
|
@@ -39,25 +38,19 @@ exports.parseSegments = parseSegments;
|
|
|
39
38
|
* Exported for testing purposes.
|
|
40
39
|
*/
|
|
41
40
|
function computeSplitsMutation(entries) {
|
|
42
|
-
var uniqueEntries = new maps_1._Map();
|
|
43
|
-
entries.forEach(function (split) {
|
|
44
|
-
var prevSplit = uniqueEntries.get(split.name);
|
|
45
|
-
if (!prevSplit || prevSplit.changeNumber < split.changeNumber)
|
|
46
|
-
uniqueEntries.set(split.name, split);
|
|
47
|
-
});
|
|
48
41
|
var segments = new sets_1._Set();
|
|
49
|
-
var computed =
|
|
50
|
-
uniqueEntries.forEach(function (split) {
|
|
42
|
+
var computed = entries.reduce(function (accum, split) {
|
|
51
43
|
if (split.status === 'ACTIVE') {
|
|
52
|
-
|
|
44
|
+
accum.added.push([split.name, split]);
|
|
53
45
|
parseSegments(split).forEach(function (segmentName) {
|
|
54
46
|
segments.add(segmentName);
|
|
55
47
|
});
|
|
56
48
|
}
|
|
57
49
|
else {
|
|
58
|
-
|
|
50
|
+
accum.removed.push(split.name);
|
|
59
51
|
}
|
|
60
|
-
|
|
52
|
+
return accum;
|
|
53
|
+
}, { added: [], removed: [], segments: [] });
|
|
61
54
|
computed.segments = (0, sets_1.setToArray)(segments);
|
|
62
55
|
return computed;
|
|
63
56
|
}
|
|
@@ -113,7 +113,7 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
113
113
|
if (disconnected)
|
|
114
114
|
return;
|
|
115
115
|
log.error(constants_2.ERROR_STREAMING_AUTH, [error.message]);
|
|
116
|
-
// Handle 4XX HTTP errors: 401 (invalid
|
|
116
|
+
// Handle 4XX HTTP errors: 401 (invalid SDK Key) or 400 (using incorrect SDK Key, i.e., client-side SDK Key on server-side)
|
|
117
117
|
if (error.statusCode >= 400 && error.statusCode < 500) {
|
|
118
118
|
telemetryTracker.streamingEvent(constants_3.AUTH_REJECTION);
|
|
119
119
|
pushEmitter.emit(constants_1.PUSH_NONRETRYABLE_ERROR);
|
|
@@ -28,8 +28,8 @@ function getActiveFactories() {
|
|
|
28
28
|
return Object.keys(apiKey_1.usedKeysMap).length;
|
|
29
29
|
}
|
|
30
30
|
function getRedundantActiveFactories() {
|
|
31
|
-
return Object.keys(apiKey_1.usedKeysMap).reduce(function (acum,
|
|
32
|
-
return acum + apiKey_1.usedKeysMap[
|
|
31
|
+
return Object.keys(apiKey_1.usedKeysMap).reduce(function (acum, sdkKey) {
|
|
32
|
+
return acum + apiKey_1.usedKeysMap[sdkKey] - 1;
|
|
33
33
|
}, 0);
|
|
34
34
|
}
|
|
35
35
|
function getTelemetryConfigStats(mode, storageType) {
|
|
@@ -3,51 +3,52 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.releaseApiKey = exports.validateAndTrackApiKey = exports.usedKeysMap = exports.validateApiKey = void 0;
|
|
4
4
|
var constants_1 = require("../../logger/constants");
|
|
5
5
|
var lang_1 = require("../lang");
|
|
6
|
-
var item = '
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
var item = 'sdk_key';
|
|
7
|
+
// @TODO replace ApiKey with SdkKey in function names
|
|
8
|
+
/** validates the given SDK key */
|
|
9
|
+
function validateApiKey(log, maybeSdkKey) {
|
|
10
|
+
var sdkKey = false;
|
|
11
|
+
if (maybeSdkKey == undefined) { // eslint-disable-line eqeqeq
|
|
11
12
|
log.error(constants_1.ERROR_NULL, [constants_1.LOG_PREFIX_INSTANTIATION, item]);
|
|
12
13
|
}
|
|
13
|
-
else if ((0, lang_1.isString)(
|
|
14
|
-
if (
|
|
15
|
-
|
|
14
|
+
else if ((0, lang_1.isString)(maybeSdkKey)) {
|
|
15
|
+
if (maybeSdkKey.length > 0)
|
|
16
|
+
sdkKey = maybeSdkKey;
|
|
16
17
|
else
|
|
17
18
|
log.error(constants_1.ERROR_EMPTY, [constants_1.LOG_PREFIX_INSTANTIATION, item]);
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
21
|
log.error(constants_1.ERROR_INVALID, [constants_1.LOG_PREFIX_INSTANTIATION, item]);
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return sdkKey;
|
|
23
24
|
}
|
|
24
25
|
exports.validateApiKey = validateApiKey;
|
|
25
26
|
// Exported for telemetry
|
|
26
27
|
exports.usedKeysMap = {};
|
|
27
|
-
/** validates the given
|
|
28
|
-
function validateAndTrackApiKey(log,
|
|
29
|
-
var
|
|
30
|
-
// If
|
|
31
|
-
if (
|
|
32
|
-
if (!exports.usedKeysMap[
|
|
28
|
+
/** validates the given SDK key and also warns if it is in use */
|
|
29
|
+
function validateAndTrackApiKey(log, maybeSdkKey) {
|
|
30
|
+
var sdkKey = validateApiKey(log, maybeSdkKey);
|
|
31
|
+
// If sdkKey is correct, we'll save it as the instance creation should work.
|
|
32
|
+
if (sdkKey) {
|
|
33
|
+
if (!exports.usedKeysMap[sdkKey]) {
|
|
33
34
|
// If this key is not present, only warning scenarios is that we have factories for other keys.
|
|
34
|
-
exports.usedKeysMap[
|
|
35
|
+
exports.usedKeysMap[sdkKey] = 1;
|
|
35
36
|
if (Object.keys(exports.usedKeysMap).length > 1) {
|
|
36
|
-
log.warn(constants_1.
|
|
37
|
+
log.warn(constants_1.WARN_SDK_KEY, ['an instance of the Split factory']);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
else {
|
|
40
|
-
log.warn(constants_1.
|
|
41
|
-
exports.usedKeysMap[
|
|
41
|
+
log.warn(constants_1.WARN_SDK_KEY, [exports.usedKeysMap[sdkKey] + " factory/ies with this SDK Key"]);
|
|
42
|
+
exports.usedKeysMap[sdkKey]++;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
return
|
|
45
|
+
return sdkKey;
|
|
45
46
|
}
|
|
46
47
|
exports.validateAndTrackApiKey = validateAndTrackApiKey;
|
|
47
|
-
function releaseApiKey(
|
|
48
|
-
if (exports.usedKeysMap[
|
|
49
|
-
exports.usedKeysMap[
|
|
50
|
-
if (exports.usedKeysMap[
|
|
51
|
-
delete exports.usedKeysMap[
|
|
48
|
+
function releaseApiKey(sdkKey) {
|
|
49
|
+
if (exports.usedKeysMap[sdkKey])
|
|
50
|
+
exports.usedKeysMap[sdkKey]--;
|
|
51
|
+
if (exports.usedKeysMap[sdkKey] === 0)
|
|
52
|
+
delete exports.usedKeysMap[sdkKey];
|
|
52
53
|
}
|
|
53
54
|
exports.releaseApiKey = releaseApiKey;
|
|
@@ -13,12 +13,12 @@ function validateSplitsData(log, maybeSplitsData, method) {
|
|
|
13
13
|
if ((0, lang_1.isObject)(maybeSplitsData)) {
|
|
14
14
|
var splitNames = Object.keys(maybeSplitsData);
|
|
15
15
|
if (splitNames.length === 0)
|
|
16
|
-
log.warn(method + ": preloadedData.splitsData doesn't contain
|
|
16
|
+
log.warn(method + ": preloadedData.splitsData doesn't contain feature flag definitions.");
|
|
17
17
|
// @TODO in the future, consider handling the possibility of having parsed definitions of splits
|
|
18
18
|
if (splitNames.every(function (splitName) { return (0, split_1.validateSplit)(log, splitName, method) && (0, lang_1.isString)(maybeSplitsData[splitName]); }))
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
|
-
log.error(method + ": preloadedData.splitsData must be a map of
|
|
21
|
+
log.error(method + ": preloadedData.splitsData must be a map of feature flag names to their stringified definitions.");
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
function validateMySegmentsData(log, maybeMySegmentsData, method) {
|
|
@@ -40,7 +40,7 @@ function validateSegmentsData(log, maybeSegmentsData, method) {
|
|
|
40
40
|
if (segmentNames.every(function (segmentName) { return (0, lang_1.isString)(maybeSegmentsData[segmentName]); }))
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
43
|
-
log.error(method + ": preloadedData.segmentsData must be a map of segment names to their
|
|
43
|
+
log.error(method + ": preloadedData.segmentsData must be a map of segment names to their stringified definitions.");
|
|
44
44
|
return false;
|
|
45
45
|
}
|
|
46
46
|
function validatePreloadedData(log, maybePreloadedData, method) {
|
|
@@ -6,7 +6,7 @@ var lang_1 = require("../lang");
|
|
|
6
6
|
// include BOM and nbsp
|
|
7
7
|
var TRIMMABLE_SPACES_REGEX = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/;
|
|
8
8
|
function validateSplit(log, maybeSplit, method, item) {
|
|
9
|
-
if (item === void 0) { item = '
|
|
9
|
+
if (item === void 0) { item = 'feature flag name'; }
|
|
10
10
|
if (maybeSplit == undefined) { // eslint-disable-line eqeqeq
|
|
11
11
|
log.error(constants_1.ERROR_NULL, [method, item]);
|
|
12
12
|
}
|
|
@@ -5,8 +5,8 @@ var constants_1 = require("../../logger/constants");
|
|
|
5
5
|
var lang_1 = require("../lang");
|
|
6
6
|
var split_1 = require("./split");
|
|
7
7
|
function validateSplits(log, maybeSplits, method, listName, item) {
|
|
8
|
-
if (listName === void 0) { listName = '
|
|
9
|
-
if (item === void 0) { item = '
|
|
8
|
+
if (listName === void 0) { listName = 'feature flag names'; }
|
|
9
|
+
if (item === void 0) { item = 'feature flag name'; }
|
|
10
10
|
if (Array.isArray(maybeSplits) && maybeSplits.length > 0) {
|
|
11
11
|
var validatedArray_1 = [];
|
|
12
12
|
// Remove invalid values
|
|
@@ -84,7 +84,7 @@ function fromSecondsToMillis(n) {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Validates the given config and use it to build a settings object.
|
|
87
|
-
* NOTE: it doesn't validate the
|
|
87
|
+
* NOTE: it doesn't validate the SDK Key. Call `validateApiKey` or `validateAndTrackApiKey` for that after settings validation.
|
|
88
88
|
*
|
|
89
89
|
* @param config user defined configuration
|
|
90
90
|
* @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
|
package/esm/logger/constants.js
CHANGED
|
@@ -92,7 +92,7 @@ export var WARN_INTEGRATION_INVALID = 218;
|
|
|
92
92
|
export var WARN_SPLITS_FILTER_IGNORED = 219;
|
|
93
93
|
export var WARN_SPLITS_FILTER_INVALID = 220;
|
|
94
94
|
export var WARN_SPLITS_FILTER_EMPTY = 221;
|
|
95
|
-
export var
|
|
95
|
+
export var WARN_SDK_KEY = 222;
|
|
96
96
|
export var STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 223;
|
|
97
97
|
export var ERROR_ENGINE_COMBINER_IFELSEIF = 300;
|
|
98
98
|
export var ERROR_LOGLEVEL_INVALID = 301;
|
|
@@ -132,7 +132,7 @@ export var LOG_PREFIX_SYNC = 'sync';
|
|
|
132
132
|
export var LOG_PREFIX_SYNC_MANAGER = LOG_PREFIX_SYNC + ':sync-manager: ';
|
|
133
133
|
export var LOG_PREFIX_SYNC_OFFLINE = LOG_PREFIX_SYNC + ':offline: ';
|
|
134
134
|
export var LOG_PREFIX_SYNC_STREAMING = LOG_PREFIX_SYNC + ':streaming: ';
|
|
135
|
-
export var LOG_PREFIX_SYNC_SPLITS = LOG_PREFIX_SYNC + ':
|
|
135
|
+
export var LOG_PREFIX_SYNC_SPLITS = LOG_PREFIX_SYNC + ':featureflag-changes: ';
|
|
136
136
|
export var LOG_PREFIX_SYNC_SEGMENTS = LOG_PREFIX_SYNC + ':segment-changes: ';
|
|
137
137
|
export var LOG_PREFIX_SYNC_MYSEGMENTS = LOG_PREFIX_SYNC + ':my-segments: ';
|
|
138
138
|
export var LOG_PREFIX_SYNC_POLLING = LOG_PREFIX_SYNC + ':polling-manager: ';
|
|
@@ -12,8 +12,8 @@ export var codesDebug = codesInfo.concat([
|
|
|
12
12
|
[c.ENGINE_MATCHER_CONTAINS_ALL, c.LOG_PREFIX_ENGINE_MATCHER + '[containsAllMatcher] %s contains all elements of %s? %s'],
|
|
13
13
|
[c.ENGINE_MATCHER_CONTAINS_ANY, c.LOG_PREFIX_ENGINE_MATCHER + '[containsAnyMatcher] %s contains at least an element of %s? %s'],
|
|
14
14
|
[c.ENGINE_MATCHER_CONTAINS_STRING, c.LOG_PREFIX_ENGINE_MATCHER + '[containsStringMatcher] %s contains %s? %s'],
|
|
15
|
-
[c.ENGINE_MATCHER_DEPENDENCY, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] parent
|
|
16
|
-
[c.ENGINE_MATCHER_DEPENDENCY_PRE, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] will evaluate parent
|
|
15
|
+
[c.ENGINE_MATCHER_DEPENDENCY, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] parent feature flag "%s" evaluated to "%s" with label "%s". %s evaluated treatment is part of [%s] ? %s.'],
|
|
16
|
+
[c.ENGINE_MATCHER_DEPENDENCY_PRE, c.LOG_PREFIX_ENGINE_MATCHER + '[dependencyMatcher] will evaluate parent feature flag: "%s" with key: %s %s'],
|
|
17
17
|
[c.ENGINE_MATCHER_EQUAL, c.LOG_PREFIX_ENGINE_MATCHER + '[equalToMatcher] is %s equal to %s? %s'],
|
|
18
18
|
[c.ENGINE_MATCHER_EQUAL_TO_SET, c.LOG_PREFIX_ENGINE_MATCHER + '[equalToSetMatcher] is %s equal to set %s? %s'],
|
|
19
19
|
[c.ENGINE_MATCHER_ENDS_WITH, c.LOG_PREFIX_ENGINE_MATCHER + '[endsWithMatcher] %s ends with %s? %s'],
|
|
@@ -34,15 +34,15 @@ export var codesDebug = codesInfo.concat([
|
|
|
34
34
|
[c.RETRIEVE_CLIENT_EXISTING, 'Retrieving existing SDK client.'],
|
|
35
35
|
[c.RETRIEVE_MANAGER, 'Retrieving manager instance.'],
|
|
36
36
|
// synchronizer
|
|
37
|
-
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + '
|
|
38
|
-
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up
|
|
39
|
-
[c.SYNC_SPLITS_NEW, c.LOG_PREFIX_SYNC_SPLITS + 'New
|
|
40
|
-
[c.SYNC_SPLITS_REMOVED, c.LOG_PREFIX_SYNC_SPLITS + 'Removed
|
|
37
|
+
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
|
|
38
|
+
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s'],
|
|
39
|
+
[c.SYNC_SPLITS_NEW, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s'],
|
|
40
|
+
[c.SYNC_SPLITS_REMOVED, c.LOG_PREFIX_SYNC_SPLITS + 'Removed feature flags %s'],
|
|
41
41
|
[c.SYNC_SPLITS_SEGMENTS, c.LOG_PREFIX_SYNC_SPLITS + 'Segment names collected %s'],
|
|
42
42
|
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
|
|
43
43
|
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + ': Starting %s. Running each %s millis'],
|
|
44
44
|
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + ': Running %s'],
|
|
45
45
|
[c.SYNC_TASK_STOP, c.LOG_PREFIX_SYNC + ': Stopping %s'],
|
|
46
46
|
// initialization / settings validation
|
|
47
|
-
[c.SETTINGS_SPLITS_FILTER, c.LOG_PREFIX_SETTINGS + ':
|
|
47
|
+
[c.SETTINGS_SPLITS_FILTER, c.LOG_PREFIX_SETTINGS + ': feature flags filtering criteria is "%s".']
|
|
48
48
|
]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as c from '../constants';
|
|
2
2
|
export var codesError = [
|
|
3
3
|
// evaluator
|
|
4
|
-
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid
|
|
4
|
+
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules found'],
|
|
5
5
|
// SDK
|
|
6
6
|
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
|
|
7
7
|
[c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],
|
|
@@ -9,7 +9,7 @@ export var codesError = [
|
|
|
9
9
|
[c.ERROR_IMPRESSIONS_LISTENER, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Impression listener logImpression method threw: %s.'],
|
|
10
10
|
[c.ERROR_EVENTS_TRACKER, c.LOG_PREFIX_EVENTS_TRACKER + 'Failed to queue %s'],
|
|
11
11
|
// synchronizer
|
|
12
|
-
[c.ERROR_SYNC_OFFLINE_LOADING, c.LOG_PREFIX_SYNC_OFFLINE + 'There was an issue loading the mock
|
|
12
|
+
[c.ERROR_SYNC_OFFLINE_LOADING, c.LOG_PREFIX_SYNC_OFFLINE + 'There was an issue loading the mock feature flags data. No changes will be applied to the current cache. %s'],
|
|
13
13
|
[c.ERROR_STREAMING_SSE, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to connect or error on streaming connection, with error message: %s'],
|
|
14
14
|
[c.ERROR_STREAMING_AUTH, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to authenticate for streaming. Error: %s.'],
|
|
15
15
|
[c.ERROR_HTTP, 'Response status is not OK. Status: %s. URL: %s. Message: %s'],
|
|
@@ -6,7 +6,7 @@ export var codesInfo = codesWarn.concat([
|
|
|
6
6
|
[c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
|
|
7
7
|
[c.CLIENT_READY, READY_MSG],
|
|
8
8
|
// SDK
|
|
9
|
-
[c.IMPRESSION, c.LOG_PREFIX_IMPRESSIONS_TRACKER + '
|
|
9
|
+
[c.IMPRESSION, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
|
|
10
10
|
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing corresponding impression.'],
|
|
11
11
|
[c.NEW_SHARED_CLIENT, 'New shared client instance created.'],
|
|
12
12
|
[c.NEW_FACTORY, 'New Split SDK instance created.'],
|
|
@@ -19,13 +19,13 @@ export var codesInfo = codesWarn.concat([
|
|
|
19
19
|
[c.POLLING_SMART_PAUSING, c.LOG_PREFIX_SYNC_POLLING + 'Turning segments data polling %s.'],
|
|
20
20
|
[c.POLLING_START, c.LOG_PREFIX_SYNC_POLLING + 'Starting polling'],
|
|
21
21
|
[c.POLLING_STOP, c.LOG_PREFIX_SYNC_POLLING + 'Stopping polling'],
|
|
22
|
-
[c.SYNC_SPLITS_FETCH_RETRY, c.LOG_PREFIX_SYNC_SPLITS + 'Retrying download of
|
|
22
|
+
[c.SYNC_SPLITS_FETCH_RETRY, c.LOG_PREFIX_SYNC_SPLITS + 'Retrying download of feature flags #%s. Reason: %s'],
|
|
23
23
|
[c.SUBMITTERS_PUSH_FULL_QUEUE, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing full %s queue and reseting timer.'],
|
|
24
24
|
[c.SUBMITTERS_PUSH, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Pushing %s.'],
|
|
25
25
|
[c.STREAMING_REFRESH_TOKEN, c.LOG_PREFIX_SYNC_STREAMING + 'Refreshing streaming token in %s seconds, and connecting streaming in %s seconds.'],
|
|
26
26
|
[c.STREAMING_RECONNECT, c.LOG_PREFIX_SYNC_STREAMING + 'Attempting to reconnect streaming in %s seconds.'],
|
|
27
27
|
[c.STREAMING_CONNECTING, c.LOG_PREFIX_SYNC_STREAMING + 'Connecting streaming.'],
|
|
28
|
-
[c.STREAMING_DISABLED, c.LOG_PREFIX_SYNC_STREAMING + 'Streaming is disabled for given
|
|
28
|
+
[c.STREAMING_DISABLED, c.LOG_PREFIX_SYNC_STREAMING + 'Streaming is disabled for given SDK key. Switching to polling mode.'],
|
|
29
29
|
[c.STREAMING_DISCONNECTING, c.LOG_PREFIX_SYNC_STREAMING + 'Disconnecting streaming.'],
|
|
30
30
|
[c.SYNC_START_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming not available. Starting polling.'],
|
|
31
31
|
[c.SYNC_CONTINUE_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming couldn\'t connect. Continue polling.'],
|
|
@@ -6,7 +6,7 @@ export var codesWarn = codesError.concat([
|
|
|
6
6
|
[c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute [%s], no attributes received.'],
|
|
7
7
|
// synchronizer
|
|
8
8
|
[c.SYNC_MYSEGMENTS_FETCH_RETRY, c.LOG_PREFIX_SYNC_MYSEGMENTS + 'Retrying download of segments #%s. Reason: %s'],
|
|
9
|
-
[c.SYNC_SPLITS_FETCH_FAILS, c.LOG_PREFIX_SYNC_SPLITS + 'Error while doing fetch of
|
|
9
|
+
[c.SYNC_SPLITS_FETCH_FAILS, c.LOG_PREFIX_SYNC_SPLITS + 'Error while doing fetch of feature flags. %s'],
|
|
10
10
|
[c.STREAMING_PARSING_ERROR_FAILS, c.LOG_PREFIX_SYNC_STREAMING + 'Error parsing SSE error notification: %s'],
|
|
11
11
|
[c.STREAMING_PARSING_MESSAGE_FAILS, c.LOG_PREFIX_SYNC_STREAMING + 'Error parsing SSE message notification: %s'],
|
|
12
12
|
[c.STREAMING_FALLBACK, c.LOG_PREFIX_SYNC_STREAMING + 'Falling back to polling mode. Reason: %s'],
|
|
@@ -20,14 +20,14 @@ export var codesWarn = codesError.concat([
|
|
|
20
20
|
[c.WARN_TRIMMING_PROPERTIES, '%s: Event has more than 300 properties. Some of them will be trimmed when processed.'],
|
|
21
21
|
[c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
|
|
22
22
|
[c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
|
|
23
|
-
[c.WARN_NOT_EXISTENT_SPLIT, '%s:
|
|
23
|
+
[c.WARN_NOT_EXISTENT_SPLIT, '%s: feature flag "%s" does not exist in this environment. Please double check what feature flags exist in the Split user interface.'],
|
|
24
24
|
[c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
|
|
25
|
-
[c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding
|
|
25
|
+
[c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding feature flag in this environment, make sure you\'re tracking your events to a valid traffic type defined in the Split user interface.'],
|
|
26
26
|
// initialization / settings validation
|
|
27
27
|
[c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS + ': %s integration item(s) at settings is invalid. %s'],
|
|
28
|
-
[c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS + ':
|
|
29
|
-
[c.WARN_SPLITS_FILTER_INVALID, c.LOG_PREFIX_SETTINGS + ':
|
|
30
|
-
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ':
|
|
31
|
-
[c.
|
|
28
|
+
[c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS + ': feature flag filters have been configured but will have no effect if mode is not "%s", since synchronization is being deferred to an external tool.'],
|
|
29
|
+
[c.WARN_SPLITS_FILTER_INVALID, c.LOG_PREFIX_SETTINGS + ': feature flag filter at position %s is invalid. It must be an object with a valid filter type ("byName" or "byPrefix") and a list of "values".'],
|
|
30
|
+
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
|
|
31
|
+
[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'],
|
|
32
32
|
[c.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching MySegments due to an error processing %s notification: %s'],
|
|
33
33
|
]);
|
package/esm/sdkClient/client.js
CHANGED
|
@@ -8,10 +8,10 @@ import { CONTROL, TREATMENT, TREATMENTS, TREATMENT_WITH_CONFIG, TREATMENTS_WITH_
|
|
|
8
8
|
import { IMPRESSION, IMPRESSION_QUEUEING } from '../logger/constants';
|
|
9
9
|
import { isStorageSync } from '../trackers/impressionObserver/utils';
|
|
10
10
|
var treatmentNotReady = { treatment: CONTROL, label: SDK_NOT_READY };
|
|
11
|
-
function treatmentsNotReady(
|
|
11
|
+
function treatmentsNotReady(featureFlagNames) {
|
|
12
12
|
var evaluations = {};
|
|
13
|
-
|
|
14
|
-
evaluations[
|
|
13
|
+
featureFlagNames.forEach(function (featureFlagName) {
|
|
14
|
+
evaluations[featureFlagName] = treatmentNotReady;
|
|
15
15
|
});
|
|
16
16
|
return evaluations;
|
|
17
17
|
}
|
|
@@ -21,59 +21,59 @@ function treatmentsNotReady(splitNames) {
|
|
|
21
21
|
export function clientFactory(params) {
|
|
22
22
|
var readinessManager = params.sdkReadinessManager.readinessManager, storage = params.storage, settings = params.settings, impressionsTracker = params.impressionsTracker, eventTracker = params.eventTracker, telemetryTracker = params.telemetryTracker;
|
|
23
23
|
var log = settings.log, mode = settings.mode;
|
|
24
|
-
function getTreatment(key,
|
|
24
|
+
function getTreatment(key, featureFlagName, attributes, withConfig) {
|
|
25
25
|
if (withConfig === void 0) { withConfig = false; }
|
|
26
26
|
var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENT_WITH_CONFIG : TREATMENT);
|
|
27
27
|
var wrapUp = function (evaluationResult) {
|
|
28
28
|
var queue = [];
|
|
29
|
-
var treatment = processEvaluation(evaluationResult,
|
|
29
|
+
var treatment = processEvaluation(evaluationResult, featureFlagName, key, attributes, withConfig, "getTreatment" + (withConfig ? 'withConfig' : ''), queue);
|
|
30
30
|
impressionsTracker.track(queue, attributes);
|
|
31
31
|
stopTelemetryTracker(queue[0] && queue[0].label);
|
|
32
32
|
return treatment;
|
|
33
33
|
};
|
|
34
34
|
var evaluation = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
|
|
35
|
-
evaluateFeature(log, key,
|
|
35
|
+
evaluateFeature(log, key, featureFlagName, attributes, storage) :
|
|
36
36
|
isStorageSync(settings) ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
|
|
37
37
|
treatmentNotReady :
|
|
38
38
|
Promise.resolve(treatmentNotReady); // Promisify if async
|
|
39
39
|
return thenable(evaluation) ? evaluation.then(function (res) { return wrapUp(res); }) : wrapUp(evaluation);
|
|
40
40
|
}
|
|
41
|
-
function getTreatmentWithConfig(key,
|
|
42
|
-
return getTreatment(key,
|
|
41
|
+
function getTreatmentWithConfig(key, featureFlagName, attributes) {
|
|
42
|
+
return getTreatment(key, featureFlagName, attributes, true);
|
|
43
43
|
}
|
|
44
|
-
function getTreatments(key,
|
|
44
|
+
function getTreatments(key, featureFlagNames, attributes, withConfig) {
|
|
45
45
|
if (withConfig === void 0) { withConfig = false; }
|
|
46
46
|
var stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENTS_WITH_CONFIG : TREATMENTS);
|
|
47
47
|
var wrapUp = function (evaluationResults) {
|
|
48
48
|
var queue = [];
|
|
49
49
|
var treatments = {};
|
|
50
|
-
Object.keys(evaluationResults).forEach(function (
|
|
51
|
-
treatments[
|
|
50
|
+
Object.keys(evaluationResults).forEach(function (featureFlagName) {
|
|
51
|
+
treatments[featureFlagName] = processEvaluation(evaluationResults[featureFlagName], featureFlagName, key, attributes, withConfig, "getTreatments" + (withConfig ? 'withConfig' : ''), queue);
|
|
52
52
|
});
|
|
53
53
|
impressionsTracker.track(queue, attributes);
|
|
54
54
|
stopTelemetryTracker(queue[0] && queue[0].label);
|
|
55
55
|
return treatments;
|
|
56
56
|
};
|
|
57
57
|
var evaluations = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
|
|
58
|
-
evaluateFeatures(log, key,
|
|
58
|
+
evaluateFeatures(log, key, featureFlagNames, attributes, storage) :
|
|
59
59
|
isStorageSync(settings) ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
|
|
60
|
-
treatmentsNotReady(
|
|
61
|
-
Promise.resolve(treatmentsNotReady(
|
|
60
|
+
treatmentsNotReady(featureFlagNames) :
|
|
61
|
+
Promise.resolve(treatmentsNotReady(featureFlagNames)); // Promisify if async
|
|
62
62
|
return thenable(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
|
|
63
63
|
}
|
|
64
|
-
function getTreatmentsWithConfig(key,
|
|
65
|
-
return getTreatments(key,
|
|
64
|
+
function getTreatmentsWithConfig(key, featureFlagNames, attributes) {
|
|
65
|
+
return getTreatments(key, featureFlagNames, attributes, true);
|
|
66
66
|
}
|
|
67
67
|
// Internal function
|
|
68
|
-
function processEvaluation(evaluation,
|
|
68
|
+
function processEvaluation(evaluation, featureFlagName, key, attributes, withConfig, invokingMethodName, queue) {
|
|
69
69
|
var matchingKey = getMatching(key);
|
|
70
70
|
var bucketingKey = getBucketing(key);
|
|
71
71
|
var treatment = evaluation.treatment, label = evaluation.label, changeNumber = evaluation.changeNumber, _a = evaluation.config, config = _a === void 0 ? null : _a;
|
|
72
|
-
log.info(IMPRESSION, [
|
|
73
|
-
if (validateSplitExistance(log, readinessManager,
|
|
72
|
+
log.info(IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
|
|
73
|
+
if (validateSplitExistance(log, readinessManager, featureFlagName, label, invokingMethodName)) {
|
|
74
74
|
log.info(IMPRESSION_QUEUEING);
|
|
75
75
|
queue.push({
|
|
76
|
-
feature:
|
|
76
|
+
feature: featureFlagName,
|
|
77
77
|
keyName: matchingKey,
|
|
78
78
|
treatment: treatment,
|
|
79
79
|
time: Date.now(),
|
|
@@ -12,17 +12,17 @@ export function clientAttributesDecoration(log, client) {
|
|
|
12
12
|
var clientGetTreatments = client.getTreatments;
|
|
13
13
|
var clientGetTreatmentsWithConfig = client.getTreatmentsWithConfig;
|
|
14
14
|
var clientTrack = client.track;
|
|
15
|
-
function getTreatment(maybeKey,
|
|
16
|
-
return clientGetTreatment(maybeKey,
|
|
15
|
+
function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
|
|
16
|
+
return clientGetTreatment(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes));
|
|
17
17
|
}
|
|
18
|
-
function getTreatmentWithConfig(maybeKey,
|
|
19
|
-
return clientGetTreatmentWithConfig(maybeKey,
|
|
18
|
+
function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes) {
|
|
19
|
+
return clientGetTreatmentWithConfig(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes));
|
|
20
20
|
}
|
|
21
|
-
function getTreatments(maybeKey,
|
|
22
|
-
return clientGetTreatments(maybeKey,
|
|
21
|
+
function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
|
|
22
|
+
return clientGetTreatments(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes));
|
|
23
23
|
}
|
|
24
|
-
function getTreatmentsWithConfig(maybeKey,
|
|
25
|
-
return clientGetTreatmentsWithConfig(maybeKey,
|
|
24
|
+
function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
|
|
25
|
+
return clientGetTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes));
|
|
26
26
|
}
|
|
27
27
|
function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
|
|
28
28
|
return clientTrack(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties);
|