@splitsoftware/splitio-commons 3.1.1-rc.10 → 3.1.1-rc.12
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 +3 -0
- package/cjs/evaluator/condition/index.js +2 -2
- package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/cjs/evaluator/index.js +81 -71
- package/cjs/listeners/browser.js +2 -1
- package/cjs/listeners/node.js +4 -4
- package/cjs/logger/constants.js +15 -20
- package/cjs/logger/messages/debug.js +5 -6
- package/cjs/logger/messages/error.js +3 -3
- package/cjs/logger/messages/info.js +3 -4
- package/cjs/logger/messages/warn.js +6 -7
- package/cjs/platform/browser.js +15 -0
- package/cjs/platform/getEventSource/browser.js +8 -0
- package/cjs/platform/getEventSource/eventsource.js +480 -0
- package/cjs/platform/getEventSource/node.js +26 -0
- package/cjs/platform/getFetch/browser.js +9 -0
- package/cjs/platform/getFetch/node.js +27 -0
- package/cjs/platform/getOptions/node.js +25 -0
- package/cjs/platform/node.js +17 -0
- package/cjs/presets/serverSide.js +2 -2
- package/cjs/readiness/constants.js +5 -4
- package/cjs/readiness/readinessManager.js +23 -23
- package/cjs/readiness/sdkReadinessManager.js +1 -17
- package/cjs/sdkClient/client.js +24 -50
- package/cjs/sdkClient/clientInputValidation.js +6 -17
- package/cjs/sdkClient/sdkClient.js +3 -60
- package/cjs/sdkClient/sdkLifecycle.js +74 -0
- package/cjs/sdkClient/trackMethod.js +56 -0
- package/cjs/sdkFactory/index.js +11 -15
- package/cjs/sdkManager/index.js +5 -5
- package/cjs/services/authProvider.js +80 -0
- package/cjs/services/decorateHeaders.js +2 -1
- package/cjs/{sync/streaming/AuthClient/index.js → services/fetchAuth.js} +15 -16
- package/cjs/services/secureSplitHttpClient.js +36 -0
- package/cjs/services/serviceApi.js +147 -0
- package/cjs/services/splitApi.js +24 -10
- package/cjs/services/splitHttpClient.js +3 -5
- package/cjs/storages/AbstractDefinitionsCacheAsync.js +51 -0
- package/cjs/storages/AbstractDefinitionsCacheSync.js +76 -0
- package/cjs/storages/KeyBuilder.js +6 -6
- package/cjs/storages/KeyBuilderCS.js +5 -5
- package/cjs/storages/KeyBuilderSS.js +2 -2
- package/cjs/storages/getRolloutPlan.js +3 -3
- package/cjs/storages/inLocalStorage/DefinitionsCacheInLocal.js +195 -0
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -2
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +12 -11
- package/cjs/storages/inLocalStorage/index.js +6 -6
- package/cjs/storages/inLocalStorage/validateCache.js +3 -3
- package/cjs/storages/inMemory/DefinitionsCacheInMemory.js +122 -0
- package/cjs/storages/inMemory/InMemoryStorage.js +4 -4
- package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +7 -6
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/{SplitsCacheInRedis.js → DefinitionsCacheInRedis.js} +79 -77
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +4 -2
- package/cjs/storages/inRedis/index.js +2 -2
- package/cjs/storages/pluggable/DefinitionsCachePluggable.js +214 -0
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +4 -2
- package/cjs/storages/pluggable/index.js +2 -2
- package/cjs/storages/setRolloutPlan.js +4 -4
- package/cjs/storages/utils.js +1 -0
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +5 -5
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +24 -15
- package/cjs/sync/polling/pollingManagerCS.js +86 -81
- package/cjs/sync/polling/pollingManagerSS.js +44 -36
- package/cjs/sync/polling/syncTasks/definitionsSyncTask.js +13 -0
- package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +2 -3
- package/cjs/sync/polling/updaters/definitionChangesUpdater.js +207 -0
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +2 -1
- package/cjs/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +19 -20
- package/cjs/sync/streaming/constants.js +4 -3
- package/cjs/sync/streaming/parseUtils.js +14 -14
- package/cjs/sync/streaming/pushManager.js +22 -26
- package/cjs/sync/submitters/eventsSubmitter.js +1 -1
- package/cjs/sync/submitters/impressionCountsSubmitter.js +1 -1
- package/cjs/sync/submitters/impressionsSubmitter.js +5 -4
- package/cjs/sync/submitters/telemetrySubmitter.js +3 -4
- package/cjs/sync/submitters/uniqueKeysSubmitter.js +1 -1
- package/cjs/sync/syncManagerOnline.js +5 -5
- package/cjs/utils/Backoff.js +35 -3
- package/cjs/utils/EventEmitter.js +391 -0
- package/cjs/utils/filter/bloomFilter.js +37 -0
- package/cjs/utils/inputValidation/{split.js → definition.js} +10 -10
- package/cjs/utils/inputValidation/{splitExistence.js → definitionExistence.js} +6 -6
- package/cjs/utils/inputValidation/definitions.js +25 -0
- package/cjs/utils/inputValidation/index.js +7 -7
- package/cjs/utils/inputValidation/isOperational.js +4 -4
- package/cjs/utils/inputValidation/target.js +22 -0
- package/cjs/utils/labels/index.js +3 -3
- package/cjs/utils/settingsValidation/index.js +2 -0
- package/cjs/utils/settingsValidation/splitFilters.js +3 -3
- package/cjs/utils/settingsValidation/url.js +6 -2
- package/esm/evaluator/condition/index.js +2 -2
- package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/esm/evaluator/index.js +80 -71
- package/esm/listeners/browser.js +2 -1
- package/esm/listeners/node.js +4 -4
- package/esm/logger/constants.js +12 -17
- package/esm/logger/messages/debug.js +5 -6
- package/esm/logger/messages/error.js +3 -3
- package/esm/logger/messages/info.js +3 -4
- package/esm/logger/messages/warn.js +6 -7
- package/esm/platform/browser.js +12 -0
- package/esm/platform/getEventSource/browser.js +4 -0
- package/esm/platform/getEventSource/eventsource.js +480 -0
- package/esm/platform/getEventSource/node.js +20 -0
- package/esm/platform/getFetch/browser.js +5 -0
- package/esm/platform/getFetch/node.js +22 -0
- package/esm/platform/getOptions/node.js +20 -0
- package/esm/platform/node.js +14 -0
- package/esm/presets/serverSide.js +2 -2
- package/esm/readiness/constants.js +4 -3
- package/esm/readiness/readinessManager.js +24 -24
- package/esm/readiness/sdkReadinessManager.js +2 -18
- package/esm/sdkClient/client.js +23 -50
- package/esm/sdkClient/clientInputValidation.js +8 -19
- package/esm/sdkClient/sdkClient.js +3 -60
- package/esm/sdkClient/sdkLifecycle.js +70 -0
- package/esm/sdkClient/trackMethod.js +52 -0
- package/esm/sdkFactory/index.js +12 -16
- package/esm/sdkManager/index.js +6 -6
- package/esm/services/authProvider.js +76 -0
- package/esm/services/decorateHeaders.js +2 -1
- package/esm/{sync/streaming/AuthClient/index.js → services/fetchAuth.js} +13 -13
- package/esm/services/secureSplitHttpClient.js +32 -0
- package/esm/services/serviceApi.js +143 -0
- package/esm/services/splitApi.js +24 -10
- package/esm/services/splitHttpClient.js +3 -5
- package/esm/storages/AbstractDefinitionsCacheAsync.js +48 -0
- package/esm/storages/AbstractDefinitionsCacheSync.js +71 -0
- package/esm/storages/KeyBuilder.js +6 -6
- package/esm/storages/KeyBuilderCS.js +5 -5
- package/esm/storages/KeyBuilderSS.js +2 -2
- package/esm/storages/getRolloutPlan.js +3 -3
- package/esm/storages/inLocalStorage/DefinitionsCacheInLocal.js +192 -0
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -2
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +9 -8
- package/esm/storages/inLocalStorage/index.js +6 -6
- package/esm/storages/inLocalStorage/validateCache.js +3 -3
- package/esm/storages/inMemory/DefinitionsCacheInMemory.js +119 -0
- package/esm/storages/inMemory/InMemoryStorage.js +4 -4
- package/esm/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +4 -3
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/esm/storages/inRedis/{SplitsCacheInRedis.js → DefinitionsCacheInRedis.js} +78 -76
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +4 -2
- package/esm/storages/inRedis/index.js +2 -2
- package/esm/storages/pluggable/DefinitionsCachePluggable.js +211 -0
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +4 -2
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/storages/setRolloutPlan.js +4 -4
- package/esm/storages/utils.js +1 -0
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +6 -6
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +25 -16
- package/esm/sync/polling/pollingManagerCS.js +87 -82
- package/esm/sync/polling/pollingManagerSS.js +44 -36
- package/esm/sync/polling/syncTasks/definitionsSyncTask.js +9 -0
- package/esm/sync/polling/syncTasks/segmentsSyncTask.js +2 -3
- package/esm/sync/polling/updaters/definitionChangesUpdater.js +201 -0
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +7 -7
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +2 -2
- package/esm/sync/streaming/SSEHandler/index.js +3 -2
- package/esm/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +19 -20
- package/esm/sync/streaming/constants.js +3 -2
- package/esm/sync/streaming/parseUtils.js +11 -11
- package/esm/sync/streaming/pushManager.js +24 -28
- package/esm/sync/submitters/eventsSubmitter.js +1 -1
- package/esm/sync/submitters/impressionCountsSubmitter.js +1 -1
- package/esm/sync/submitters/impressionsSubmitter.js +5 -4
- package/esm/sync/submitters/telemetrySubmitter.js +3 -4
- package/esm/sync/submitters/uniqueKeysSubmitter.js +1 -1
- package/esm/sync/syncManagerOnline.js +4 -4
- package/esm/utils/Backoff.js +35 -3
- package/esm/utils/EventEmitter.js +387 -0
- package/esm/utils/filter/bloomFilter.js +33 -0
- package/esm/utils/inputValidation/{split.js → definition.js} +8 -8
- package/esm/utils/inputValidation/definitionExistence.js +15 -0
- package/esm/utils/inputValidation/definitions.js +21 -0
- package/esm/utils/inputValidation/index.js +3 -3
- package/esm/utils/inputValidation/isOperational.js +4 -4
- package/esm/utils/inputValidation/target.js +18 -0
- package/esm/utils/labels/index.js +2 -2
- package/esm/utils/settingsValidation/index.js +2 -0
- package/esm/utils/settingsValidation/splitFilters.js +3 -3
- package/esm/utils/settingsValidation/url.js +6 -2
- package/package.json +1 -1
- package/src/dtos/types.ts +4 -4
- package/src/services/authProvider.ts +2 -2
- package/src/{sync/streaming/AuthClient/index.ts → services/fetchAuth.ts} +3 -4
- package/src/services/splitApi.ts +1 -1
- package/src/services/types.ts +21 -4
- package/src/storages/AbstractDefinitionsCacheAsync.ts +3 -3
- package/src/storages/AbstractDefinitionsCacheSync.ts +2 -2
- package/src/storages/inLocalStorage/DefinitionsCacheInLocal.ts +2 -2
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +3 -3
- package/src/storages/inMemory/DefinitionsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +2 -2
- package/src/storages/inRedis/DefinitionsCacheInRedis.ts +6 -4
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +7 -5
- package/src/storages/pluggable/DefinitionsCachePluggable.ts +4 -2
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +5 -3
- package/src/storages/types.ts +6 -6
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +5 -5
- package/src/sync/polling/types.ts +22 -1
- package/src/sync/polling/updaters/definitionChangesUpdater.ts +26 -20
- package/src/sync/streaming/SSEClient/index.ts +1 -1
- package/src/sync/streaming/SSEClient/types.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/DefinitionsUpdateWorker.ts +15 -11
- package/src/sync/streaming/UpdateWorkers/types.ts +6 -0
- package/src/sync/streaming/parseUtils.ts +3 -4
- package/src/sync/streaming/pushManager.ts +4 -3
- package/cjs/storages/AbstractSplitsCacheAsync.js +0 -51
- package/cjs/storages/AbstractSplitsCacheSync.js +0 -76
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +0 -194
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +0 -121
- package/cjs/storages/pluggable/SplitsCachePluggable.js +0 -212
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +0 -13
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +0 -200
- package/cjs/sync/streaming/AuthClient/types.js +0 -2
- package/cjs/utils/inputValidation/splits.js +0 -25
- package/esm/storages/AbstractSplitsCacheAsync.js +0 -48
- package/esm/storages/AbstractSplitsCacheSync.js +0 -71
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +0 -191
- package/esm/storages/inMemory/SplitsCacheInMemory.js +0 -118
- package/esm/storages/pluggable/SplitsCachePluggable.js +0 -209
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +0 -9
- package/esm/sync/polling/updaters/splitChangesUpdater.js +0 -194
- package/esm/sync/streaming/AuthClient/types.js +0 -1
- package/esm/utils/inputValidation/splitExistence.js +0 -15
- package/esm/utils/inputValidation/splits.js +0 -21
- package/src/sync/streaming/AuthClient/types.ts +0 -19
package/CHANGES.txt
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
3.2.0 (XXX XX, 2026)
|
|
2
|
+
- Added support for streaming in the Configs SDK, handling CONFIG_UPDATE notifications. Unlike feature flag notifications, the previous change number of CONFIG_UPDATE and RB_SEGMENT_UPDATE notifications are scoped to the referenced entity rather than to the environment, and so instant updates are applied without updating the storage change number.
|
|
2
3
|
- Added support for AI configs.
|
|
3
4
|
- Added support for ioredis v6 (Related to issue https://github.com/splitio/javascript-client/issues/951). Note that ioredis v6 requires Node.js 20 or above; stay on ioredis v4 or v5 for older Node.js versions.
|
|
4
5
|
- Removed the `@types/ioredis` dependency, which is no longer required since the public type definitions don't depend on ioredis types. The `@types/node` dependency, previously installed transitively by `@types/ioredis`, is now declared explicitly, since the public type definitions use Node.js types for the `agent` and `tls` options.
|
|
5
6
|
- Removed Configs SDK-related types and modules and moved them to the Configs SDK repository.
|
|
7
|
+
- Bugfix - Fixed a memory leak in the `Backoff` utility, where promises returned by pending scheduled calls were never settled when the backoff was reset.
|
|
8
|
+
- Bugfix - Fixed the authentication service to not send unauthenticated requests when the SDK is destroyed while an authentication retry is pending.
|
|
6
9
|
|
|
7
10
|
3.1.0 (July 23, 2026)
|
|
8
11
|
- Added support for rule-based segments in /api/v1/configs endpoint.
|
|
@@ -10,7 +10,7 @@ function match(log, matchingResult, bucketingKey, seed, treatments, label) {
|
|
|
10
10
|
return treatments ? // Feature flag
|
|
11
11
|
{
|
|
12
12
|
treatment: (0, engineUtils_1.getTreatment)(log, bucketingKey, seed, treatments),
|
|
13
|
-
label: label
|
|
13
|
+
label: label !== null && label !== void 0 ? label : ''
|
|
14
14
|
} : // Rule-based segment
|
|
15
15
|
true;
|
|
16
16
|
}
|
|
@@ -23,7 +23,7 @@ function conditionContext(log, matcherEvaluator, treatments, label, conditionTyp
|
|
|
23
23
|
// Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
|
|
24
24
|
if (conditionType === 'ROLLOUT' && !(0, engineUtils_1.shouldApplyRollout)(trafficAllocation, key.bucketingKey, trafficAllocationSeed)) {
|
|
25
25
|
return {
|
|
26
|
-
treatment
|
|
26
|
+
// treatment value is assigned later, at Engine's evaluationResult
|
|
27
27
|
label: labels_1.NOT_IN_SPLIT
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sanitizeFallbacks = exports.isValidTreatment = exports.isValidFlagName = void 0;
|
|
4
4
|
var lang_1 = require("../../../utils/lang");
|
|
5
|
-
var
|
|
6
|
-
(
|
|
7
|
-
FallbackDiscardReason["FlagName"] = "Invalid flag name (max 100 chars, no spaces)";
|
|
8
|
-
FallbackDiscardReason["Treatment"] = "Invalid treatment (max 100 chars and must match pattern)";
|
|
9
|
-
})(FallbackDiscardReason || (FallbackDiscardReason = {}));
|
|
5
|
+
var FLAG_NAME_DISCARD_REASON = 'Invalid flag name (max 100 chars, no spaces)';
|
|
6
|
+
var TREATMENT_DISCARD_REASON = 'Invalid treatment (max 100 chars and must match pattern)';
|
|
10
7
|
var TREATMENT_PATTERN = /^[0-9]+[.a-zA-Z0-9_-]*$|^[a-zA-Z]+[a-zA-Z0-9_-]*$/;
|
|
11
8
|
function isValidFlagName(name) {
|
|
12
9
|
return name.length <= 100 && !name.includes(' ');
|
|
@@ -24,7 +21,7 @@ function sanitizeGlobal(logger, treatment) {
|
|
|
24
21
|
if (treatment === undefined)
|
|
25
22
|
return undefined;
|
|
26
23
|
if (!isValidTreatment(treatment)) {
|
|
27
|
-
logger.error("Fallback treatments - Discarded fallback: ".concat(
|
|
24
|
+
logger.error("Fallback treatments - Discarded fallback: ".concat(TREATMENT_DISCARD_REASON));
|
|
28
25
|
return undefined;
|
|
29
26
|
}
|
|
30
27
|
return treatment;
|
|
@@ -36,11 +33,11 @@ function sanitizeByFlag(logger, byFlagFallbacks) {
|
|
|
36
33
|
Object.keys(byFlagFallbacks).forEach(function (flag) {
|
|
37
34
|
var t = byFlagFallbacks[flag];
|
|
38
35
|
if (!isValidFlagName(flag)) {
|
|
39
|
-
logger.error("Fallback treatments - Discarded flag '".concat(flag, "': ").concat(
|
|
36
|
+
logger.error("Fallback treatments - Discarded flag '".concat(flag, "': ").concat(FLAG_NAME_DISCARD_REASON));
|
|
40
37
|
return;
|
|
41
38
|
}
|
|
42
39
|
if (!isValidTreatment(t)) {
|
|
43
|
-
logger.error("Fallback treatments - Discarded treatment for flag '".concat(flag, "': ").concat(
|
|
40
|
+
logger.error("Fallback treatments - Discarded treatment for flag '".concat(flag, "': ").concat(TREATMENT_DISCARD_REASON));
|
|
44
41
|
return;
|
|
45
42
|
}
|
|
46
43
|
sanitizedByFlag[flag] = t;
|
package/cjs/evaluator/index.js
CHANGED
|
@@ -1,62 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.evaluateFeaturesByFlagSets = exports.evaluateFeatures = exports.evaluateFeature = void 0;
|
|
3
|
+
exports.evaluateDefaultTreatment = exports.evaluateFeaturesByFlagSets = exports.evaluateFeatures = exports.evaluateFeature = void 0;
|
|
4
4
|
var Engine_1 = require("./Engine");
|
|
5
5
|
var thenable_1 = require("../utils/promise/thenable");
|
|
6
6
|
var labels_1 = require("../utils/labels");
|
|
7
7
|
var constants_1 = require("../utils/constants");
|
|
8
8
|
var sets_1 = require("../utils/lang/sets");
|
|
9
9
|
var constants_2 = require("../logger/constants");
|
|
10
|
-
var
|
|
10
|
+
var objectAssign_1 = require("../utils/lang/objectAssign");
|
|
11
|
+
var EVALUATION_EXCEPTION = {
|
|
11
12
|
treatment: constants_1.CONTROL,
|
|
12
13
|
label: labels_1.EXCEPTION,
|
|
13
14
|
config: null
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
var EVALUATION_DEFINITION_NOT_FOUND = {
|
|
17
|
+
treatment: constants_1.CONTROL,
|
|
18
|
+
label: labels_1.DEFINITION_NOT_FOUND,
|
|
19
|
+
config: null
|
|
20
|
+
};
|
|
21
|
+
function treatmentsException(definitionNames) {
|
|
16
22
|
var evaluations = {};
|
|
17
|
-
|
|
18
|
-
evaluations[
|
|
23
|
+
definitionNames.forEach(function (definitionName) {
|
|
24
|
+
evaluations[definitionName] = EVALUATION_EXCEPTION;
|
|
19
25
|
});
|
|
20
26
|
return evaluations;
|
|
21
27
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
28
|
+
function setEvaluationDataFromDefinition(evaluation, definition) {
|
|
29
|
+
return (0, objectAssign_1.objectAssign)(evaluation, {
|
|
30
|
+
definition: definition,
|
|
31
|
+
config: definition.configurations && definition.configurations[evaluation.treatment] || null
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function evaluateFeature(log, key, definitionName, attributes, storage) {
|
|
35
|
+
var definition;
|
|
24
36
|
try {
|
|
25
|
-
|
|
37
|
+
definition = storage.definitions.get(definitionName);
|
|
26
38
|
}
|
|
27
39
|
catch (e) {
|
|
28
|
-
// Exception on sync
|
|
29
|
-
return
|
|
40
|
+
// Exception on sync storage. Not possible ATM with InMemory and InLocal storages.
|
|
41
|
+
return EVALUATION_EXCEPTION;
|
|
30
42
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
return (0, thenable_1.thenable)(definition) ?
|
|
44
|
+
definition.then(function (definition) { return getEvaluation(log, key, definition, attributes, storage); })
|
|
45
|
+
.catch(
|
|
46
|
+
// Exception on async storage. For example, when the storage is redis or
|
|
34
47
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
35
|
-
function () { return
|
|
36
|
-
|
|
37
|
-
return getEvaluation(log, key, parsedSplit, attributes, storage, options);
|
|
48
|
+
function () { return EVALUATION_EXCEPTION; }) :
|
|
49
|
+
getEvaluation(log, key, definition, attributes, storage);
|
|
38
50
|
}
|
|
39
51
|
exports.evaluateFeature = evaluateFeature;
|
|
40
|
-
function evaluateFeatures(log, key,
|
|
41
|
-
var
|
|
52
|
+
function evaluateFeatures(log, key, definitionNames, attributes, storage) {
|
|
53
|
+
var definitions;
|
|
42
54
|
try {
|
|
43
|
-
|
|
55
|
+
definitions = storage.definitions.getMany(definitionNames);
|
|
44
56
|
}
|
|
45
57
|
catch (e) {
|
|
46
|
-
// Exception on sync
|
|
47
|
-
return treatmentsException(
|
|
58
|
+
// Exception on sync storage. Not possible ATM with InMemory and InLocal storages.
|
|
59
|
+
return treatmentsException(definitionNames);
|
|
48
60
|
}
|
|
49
|
-
return (0, thenable_1.thenable)(
|
|
50
|
-
|
|
51
|
-
.catch(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
getEvaluations(log, key, splitNames, parsedSplits, attributes, storage, options);
|
|
61
|
+
return (0, thenable_1.thenable)(definitions) ?
|
|
62
|
+
definitions.then(function (definitions) { return getEvaluations(log, key, definitionNames, definitions, attributes, storage); })
|
|
63
|
+
.catch(
|
|
64
|
+
// Exception on async storage. For example, when the storage is redis or
|
|
65
|
+
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
66
|
+
function () { return treatmentsException(definitionNames); }) :
|
|
67
|
+
getEvaluations(log, key, definitionNames, definitions, attributes, storage);
|
|
57
68
|
}
|
|
58
69
|
exports.evaluateFeatures = evaluateFeatures;
|
|
59
|
-
function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method
|
|
70
|
+
function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
|
|
60
71
|
var storedFlagNames;
|
|
61
72
|
function evaluate(featureFlagsByFlagSets) {
|
|
62
73
|
var featureFlags = new Set();
|
|
@@ -70,12 +81,12 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
|
|
|
70
81
|
}
|
|
71
82
|
}
|
|
72
83
|
return featureFlags.size ?
|
|
73
|
-
evaluateFeatures(log, key, (0, sets_1.setToArray)(featureFlags), attributes, storage
|
|
84
|
+
evaluateFeatures(log, key, (0, sets_1.setToArray)(featureFlags), attributes, storage) :
|
|
74
85
|
{};
|
|
75
86
|
}
|
|
76
87
|
// get features by flag sets
|
|
77
88
|
try {
|
|
78
|
-
storedFlagNames = storage.
|
|
89
|
+
storedFlagNames = storage.definitions.getNamesBySets(flagSets);
|
|
79
90
|
}
|
|
80
91
|
catch (e) {
|
|
81
92
|
// return empty evaluations
|
|
@@ -84,53 +95,52 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
|
|
|
84
95
|
// evaluate related features
|
|
85
96
|
return (0, thenable_1.thenable)(storedFlagNames) ?
|
|
86
97
|
storedFlagNames.then(function (storedFlagNames) { return evaluate(storedFlagNames); })
|
|
87
|
-
.catch(function () {
|
|
88
|
-
return {};
|
|
89
|
-
}) :
|
|
98
|
+
.catch(function () { return ({}); }) :
|
|
90
99
|
evaluate(storedFlagNames);
|
|
91
100
|
}
|
|
92
101
|
exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
|
|
93
|
-
function getEvaluation(log, key,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var split = (0, Engine_1.engineParser)(log, splitJSON, storage);
|
|
101
|
-
evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
102
|
-
// If the storage is async and the evaluated flag uses segments or dependencies, evaluation is thenable
|
|
103
|
-
if ((0, thenable_1.thenable)(evaluation)) {
|
|
104
|
-
return evaluation.then(function (result) {
|
|
105
|
-
result.changeNumber = splitJSON.changeNumber;
|
|
106
|
-
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
|
|
107
|
-
// @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
|
|
108
|
-
result.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || splitJSON.impressionsDisabled;
|
|
109
|
-
return result;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
evaluation.changeNumber = splitJSON.changeNumber;
|
|
114
|
-
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
|
|
115
|
-
// @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
|
|
116
|
-
evaluation.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || splitJSON.impressionsDisabled;
|
|
117
|
-
}
|
|
102
|
+
function getEvaluation(log, key, definition, attributes, storage) {
|
|
103
|
+
if (definition) {
|
|
104
|
+
var split = (0, Engine_1.engineParser)(log, definition, storage);
|
|
105
|
+
var evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
106
|
+
return (0, thenable_1.thenable)(evaluation) ?
|
|
107
|
+
evaluation.then(function (result) { return setEvaluationDataFromDefinition(result, definition); }) :
|
|
108
|
+
setEvaluationDataFromDefinition(evaluation, definition);
|
|
118
109
|
}
|
|
119
|
-
return
|
|
110
|
+
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
120
111
|
}
|
|
121
|
-
function getEvaluations(log, key,
|
|
112
|
+
function getEvaluations(log, key, definitionNames, definitions, attributes, storage) {
|
|
122
113
|
var result = {};
|
|
123
114
|
var thenables = [];
|
|
124
|
-
|
|
125
|
-
var evaluation = getEvaluation(log, key,
|
|
126
|
-
|
|
115
|
+
definitionNames.forEach(function (definitionName) {
|
|
116
|
+
var evaluation = getEvaluation(log, key, definitions[definitionName], attributes, storage);
|
|
117
|
+
(0, thenable_1.thenable)(evaluation) ?
|
|
127
118
|
thenables.push(evaluation.then(function (res) {
|
|
128
|
-
result[
|
|
129
|
-
}))
|
|
130
|
-
|
|
131
|
-
else {
|
|
132
|
-
result[splitName] = evaluation;
|
|
133
|
-
}
|
|
119
|
+
result[definitionName] = res;
|
|
120
|
+
})) :
|
|
121
|
+
result[definitionName] = evaluation;
|
|
134
122
|
});
|
|
135
123
|
return thenables.length > 0 ? Promise.all(thenables).then(function () { return result; }) : result;
|
|
136
124
|
}
|
|
125
|
+
function evaluateDefaultTreatment(definitionName, storage) {
|
|
126
|
+
var definition;
|
|
127
|
+
try {
|
|
128
|
+
definition = storage.definitions.get(definitionName);
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
return EVALUATION_EXCEPTION;
|
|
132
|
+
}
|
|
133
|
+
return (0, thenable_1.thenable)(definition) ?
|
|
134
|
+
definition.then(getDefaultTreatment).catch(function () { return EVALUATION_EXCEPTION; }) :
|
|
135
|
+
getDefaultTreatment(definition);
|
|
136
|
+
}
|
|
137
|
+
exports.evaluateDefaultTreatment = evaluateDefaultTreatment;
|
|
138
|
+
function getDefaultTreatment(definition) {
|
|
139
|
+
if (definition) {
|
|
140
|
+
return setEvaluationDataFromDefinition({
|
|
141
|
+
treatment: definition.defaultTreatment,
|
|
142
|
+
label: labels_1.NO_CONDITION_MATCH, // "default rule"
|
|
143
|
+
}, definition);
|
|
144
|
+
}
|
|
145
|
+
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
146
|
+
}
|
package/cjs/listeners/browser.js
CHANGED
|
@@ -13,7 +13,8 @@ var EVENT_NAME = 'for visibilitychange and pagehide events.';
|
|
|
13
13
|
* We'll listen for events over the window object.
|
|
14
14
|
*/
|
|
15
15
|
var BrowserSignalListener = /** @class */ (function () {
|
|
16
|
-
function BrowserSignalListener(
|
|
16
|
+
function BrowserSignalListener(_a) {
|
|
17
|
+
var syncManager = _a.syncManager, settings = _a.settings, storage = _a.storage, serviceApi = _a.serviceApi;
|
|
17
18
|
this.syncManager = syncManager;
|
|
18
19
|
this.settings = settings;
|
|
19
20
|
this.storage = storage;
|
package/cjs/listeners/node.js
CHANGED
|
@@ -13,8 +13,8 @@ var EVENT_NAME = 'for SIGTERM signal.';
|
|
|
13
13
|
* the process is already exiting.
|
|
14
14
|
*/
|
|
15
15
|
var NodeSignalListener = /** @class */ (function () {
|
|
16
|
-
function NodeSignalListener(
|
|
17
|
-
|
|
16
|
+
function NodeSignalListener(_a) {
|
|
17
|
+
var syncManager = _a.syncManager, settings = _a.settings;
|
|
18
18
|
// @TODO review handler logic when implementing Node.js SDK
|
|
19
19
|
this.handler = function () {
|
|
20
20
|
if (syncManager) {
|
|
@@ -47,13 +47,13 @@ var NodeSignalListener = /** @class */ (function () {
|
|
|
47
47
|
// eslint-disable-next-line no-undef
|
|
48
48
|
process.kill(process.pid, SIGTERM);
|
|
49
49
|
};
|
|
50
|
-
this.settings.log.debug("".concat(constants_1.LOG_PREFIX_CLEANUP, "
|
|
50
|
+
this.settings.log.debug("".concat(constants_1.LOG_PREFIX_CLEANUP, "SDK graceful shutdown after SIGTERM."));
|
|
51
51
|
var handlerResult = null;
|
|
52
52
|
try {
|
|
53
53
|
handlerResult = this.handler();
|
|
54
54
|
}
|
|
55
55
|
catch (err) {
|
|
56
|
-
this.settings.log.error("".concat(constants_1.LOG_PREFIX_CLEANUP, "Error with
|
|
56
|
+
this.settings.log.error("".concat(constants_1.LOG_PREFIX_CLEANUP, "Error with SDK graceful shutdown: ").concat(err));
|
|
57
57
|
}
|
|
58
58
|
if ((0, thenable_1.thenable)(handlerResult)) {
|
|
59
59
|
// Always exit, even with errors. The promise is returned for UT purposes.
|
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.SUBMITTERS_PUSH_PAGE_HIDDEN = 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.
|
|
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.
|
|
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.
|
|
3
|
+
exports.CLIENT_NOT_READY_FROM_CACHE = exports.ENGINE_VALUE_NO_ATTRIBUTES = exports.ENGINE_VALUE_INVALID = exports.SUBMITTERS_PUSH_PAGE_HIDDEN = 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.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.ENGINE_DEFAULT = 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_UPDATE = exports.SYNC_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_NOT_BOOLEAN = 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_DEFINITION = 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_FETCH_FAILS = exports.SYNC_FETCH_RETRY = 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_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC_AUTH = 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 = 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.
|
|
@@ -24,9 +24,8 @@ exports.RETRIEVE_CLIENT_DEFAULT = 27;
|
|
|
24
24
|
exports.RETRIEVE_CLIENT_EXISTING = 28;
|
|
25
25
|
exports.RETRIEVE_MANAGER = 29;
|
|
26
26
|
exports.SYNC_OFFLINE_DATA = 30;
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
29
|
-
exports.SYNC_RBS_UPDATE = 33;
|
|
27
|
+
exports.SYNC_FETCH = 31;
|
|
28
|
+
exports.SYNC_UPDATE = 32;
|
|
30
29
|
exports.STREAMING_NEW_MESSAGE = 35;
|
|
31
30
|
exports.SYNC_TASK_START = 36;
|
|
32
31
|
exports.SYNC_TASK_EXECUTE = 37;
|
|
@@ -42,7 +41,6 @@ exports.NEW_FACTORY = 105;
|
|
|
42
41
|
exports.POLLING_SMART_PAUSING = 106;
|
|
43
42
|
exports.POLLING_START = 107;
|
|
44
43
|
exports.POLLING_STOP = 108;
|
|
45
|
-
exports.SYNC_SPLITS_FETCH_RETRY = 109;
|
|
46
44
|
exports.STREAMING_REFRESH_TOKEN = 110;
|
|
47
45
|
exports.STREAMING_RECONNECT = 111;
|
|
48
46
|
exports.STREAMING_CONNECTING = 112;
|
|
@@ -61,10 +59,9 @@ exports.USER_CONSENT_INITIAL = 124;
|
|
|
61
59
|
exports.SUBMITTERS_PUSH_PAGE_HIDDEN = 125;
|
|
62
60
|
exports.ENGINE_VALUE_INVALID = 200;
|
|
63
61
|
exports.ENGINE_VALUE_NO_ATTRIBUTES = 201;
|
|
64
|
-
exports.CLIENT_NO_LISTENER = 202;
|
|
65
62
|
exports.CLIENT_NOT_READY_FROM_CACHE = 203;
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
63
|
+
exports.SYNC_FETCH_RETRY = 204;
|
|
64
|
+
exports.SYNC_FETCH_FAILS = 205;
|
|
68
65
|
exports.STREAMING_PARSING_ERROR_FAILS = 206;
|
|
69
66
|
exports.STREAMING_PARSING_MESSAGE_FAILS = 207;
|
|
70
67
|
exports.STREAMING_FALLBACK = 208;
|
|
@@ -74,7 +71,7 @@ exports.WARN_SETTING_NULL = 211;
|
|
|
74
71
|
exports.WARN_TRIMMING_PROPERTIES = 212;
|
|
75
72
|
exports.WARN_CONVERTING = 213;
|
|
76
73
|
exports.WARN_TRIMMING = 214;
|
|
77
|
-
exports.
|
|
74
|
+
exports.WARN_NOT_EXISTENT_DEFINITION = 215;
|
|
78
75
|
exports.WARN_LOWERCASE_TRAFFIC_TYPE = 216;
|
|
79
76
|
exports.WARN_NOT_EXISTENT_TT = 217;
|
|
80
77
|
exports.WARN_INTEGRATION_INVALID = 218;
|
|
@@ -125,15 +122,13 @@ exports.LOG_PREFIX_ENGINE = 'engine';
|
|
|
125
122
|
exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE + ':combiner: ';
|
|
126
123
|
exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE + ':matcher: ';
|
|
127
124
|
exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE + ':value: ';
|
|
128
|
-
exports.LOG_PREFIX_SYNC = 'sync';
|
|
129
|
-
exports.
|
|
130
|
-
exports.
|
|
131
|
-
exports.
|
|
132
|
-
exports.
|
|
133
|
-
exports.
|
|
134
|
-
exports.
|
|
135
|
-
exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC + ':polling-manager: ';
|
|
136
|
-
exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC + ':submitter: ';
|
|
125
|
+
exports.LOG_PREFIX_SYNC = 'sync: ';
|
|
126
|
+
exports.LOG_PREFIX_SYNC_AUTH = 'sync:auth: ';
|
|
127
|
+
exports.LOG_PREFIX_SYNC_MANAGER = 'sync:sync-manager: ';
|
|
128
|
+
exports.LOG_PREFIX_SYNC_OFFLINE = 'sync:offline: ';
|
|
129
|
+
exports.LOG_PREFIX_SYNC_STREAMING = 'sync:streaming: ';
|
|
130
|
+
exports.LOG_PREFIX_SYNC_POLLING = 'sync:polling-manager: ';
|
|
131
|
+
exports.LOG_PREFIX_SYNC_SUBMITTERS = 'sync:submitter: ';
|
|
137
132
|
exports.LOG_PREFIX_IMPRESSIONS_TRACKER = 'impressions-tracker: ';
|
|
138
133
|
exports.LOG_PREFIX_EVENTS_TRACKER = 'events-tracker: ';
|
|
139
134
|
exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = 'unique-keys-tracker: ';
|
|
@@ -24,13 +24,12 @@ exports.codesDebug = info_1.codesInfo.concat([
|
|
|
24
24
|
[c.RETRIEVE_MANAGER, 'Retrieving manager instance.'],
|
|
25
25
|
// synchronizer
|
|
26
26
|
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
|
|
27
|
-
[c.
|
|
28
|
-
[c.
|
|
29
|
-
[c.SYNC_RBS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New rule-based segments: %s. Removed rule-based segments: %s.'],
|
|
27
|
+
[c.SYNC_FETCH, c.LOG_PREFIX_SYNC + 'Spin up %s updates using since = %s and rbSince = %s.'],
|
|
28
|
+
[c.SYNC_UPDATE, c.LOG_PREFIX_SYNC + 'Updated %s: %s. Removed: %s.'],
|
|
30
29
|
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
|
|
31
|
-
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + '
|
|
32
|
-
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + '
|
|
33
|
-
[c.SYNC_TASK_STOP, c.LOG_PREFIX_SYNC + '
|
|
30
|
+
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + 'Starting %s. Running each %s millis'],
|
|
31
|
+
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + 'Running %s'],
|
|
32
|
+
[c.SYNC_TASK_STOP, c.LOG_PREFIX_SYNC + 'Stopping %s'],
|
|
34
33
|
// initialization / settings validation
|
|
35
34
|
[c.SETTINGS_SPLITS_FILTER, c.LOG_PREFIX_SETTINGS + ': feature flags filtering criteria is "%s".']
|
|
36
35
|
]);
|
|
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var c = tslib_1.__importStar(require("../constants"));
|
|
6
6
|
exports.codesError = [
|
|
7
7
|
// evaluator
|
|
8
|
-
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid
|
|
8
|
+
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid definition, no valid rules or unsupported targeting rule type found'],
|
|
9
9
|
[c.ENGINE_MATCHER_ERROR, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] %s'],
|
|
10
10
|
// SDK
|
|
11
11
|
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
|
|
@@ -16,7 +16,7 @@ exports.codesError = [
|
|
|
16
16
|
// synchronizer
|
|
17
17
|
[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'],
|
|
18
18
|
[c.ERROR_STREAMING_SSE, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to connect or error on streaming connection, with error message: %s'],
|
|
19
|
-
[c.ERROR_STREAMING_AUTH, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to authenticate for streaming. Error: %s
|
|
19
|
+
[c.ERROR_STREAMING_AUTH, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to authenticate for streaming. Error: %s'],
|
|
20
20
|
[c.ERROR_HTTP, 'HTTP request failed with %s. URL: %s. Message: %s'],
|
|
21
21
|
// client status
|
|
22
22
|
[c.ERROR_CLIENT_LISTENER, 'A listener was added for %s on the SDK, which has already fired and won\'t be emitted again. The callback won\'t be executed.'],
|
|
@@ -37,6 +37,6 @@ exports.codesError = [
|
|
|
37
37
|
[c.ERROR_INVALID_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "%s" config param. It should be one of the following values: %s. Defaulting to "%s".'],
|
|
38
38
|
[c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': the provided storage is invalid.%s Falling back into default MEMORY storage'],
|
|
39
39
|
[c.ERROR_MIN_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': the provided "%s" config param is lower than allowed. Setting to the minimum value %s seconds'],
|
|
40
|
-
[c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the
|
|
40
|
+
[c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the number of sets provided is too high, which causes a URI length error.'],
|
|
41
41
|
[c.ERROR_SETS_FILTER_EXCLUSIVE, c.LOG_PREFIX_SETTINGS + ': the Set filter is exclusive and cannot be used simultaneously with names or prefix filters. Ignoring names and prefixes.'],
|
|
42
42
|
];
|
|
@@ -4,15 +4,15 @@ exports.codesInfo = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var c = tslib_1.__importStar(require("../constants"));
|
|
6
6
|
var warn_1 = require("./warn");
|
|
7
|
-
var READY_MSG = '
|
|
7
|
+
var READY_MSG = 'SDK client is ready';
|
|
8
8
|
exports.codesInfo = warn_1.codesWarn.concat([
|
|
9
9
|
// client status
|
|
10
10
|
[c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
|
|
11
11
|
[c.CLIENT_READY, READY_MSG],
|
|
12
12
|
// SDK
|
|
13
|
-
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing impression.
|
|
13
|
+
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing impression. %s: %s. Key: %s. Evaluation: %s. Label: %s'],
|
|
14
14
|
[c.NEW_SHARED_CLIENT, 'New shared client instance created.'],
|
|
15
|
-
[c.NEW_FACTORY, 'New
|
|
15
|
+
[c.NEW_FACTORY, 'New SDK instance created. %s'],
|
|
16
16
|
[c.EVENTS_TRACKER_SUCCESS, c.LOG_PREFIX_EVENTS_TRACKER + 'Successfully queued %s'],
|
|
17
17
|
[c.IMPRESSIONS_TRACKER_SUCCESS, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Successfully stored %s impression(s).'],
|
|
18
18
|
[c.USER_CONSENT_UPDATED, 'UserConsent: consent status changed from %s to %s.'],
|
|
@@ -22,7 +22,6 @@ exports.codesInfo = warn_1.codesWarn.concat([
|
|
|
22
22
|
[c.POLLING_SMART_PAUSING, c.LOG_PREFIX_SYNC_POLLING + 'Turning segments data polling %s.'],
|
|
23
23
|
[c.POLLING_START, c.LOG_PREFIX_SYNC_POLLING + 'Starting polling'],
|
|
24
24
|
[c.POLLING_STOP, c.LOG_PREFIX_SYNC_POLLING + 'Stopping polling'],
|
|
25
|
-
[c.SYNC_SPLITS_FETCH_RETRY, c.LOG_PREFIX_SYNC_SPLITS + 'Retrying fetch of feature flags (attempt #%s). Reason: %s'],
|
|
26
25
|
[c.SUBMITTERS_PUSH_FULL_QUEUE, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing full %s queue and resetting timer.'],
|
|
27
26
|
[c.SUBMITTERS_PUSH, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Pushing %s.'],
|
|
28
27
|
[c.SUBMITTERS_PUSH_PAGE_HIDDEN, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing %s because page became hidden.'],
|
|
@@ -9,22 +9,21 @@ exports.codesWarn = error_1.codesError.concat([
|
|
|
9
9
|
[c.ENGINE_VALUE_INVALID, c.LOG_PREFIX_ENGINE_VALUE + 'Value %s doesn\'t match with expected type.'],
|
|
10
10
|
[c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute `%s`. No attributes received.'],
|
|
11
11
|
// synchronizer
|
|
12
|
-
[c.
|
|
13
|
-
[c.
|
|
12
|
+
[c.SYNC_FETCH_RETRY, c.LOG_PREFIX_SYNC + 'Retrying fetch of %s (attempt #%s). Reason: %s'],
|
|
13
|
+
[c.SYNC_FETCH_FAILS, c.LOG_PREFIX_SYNC + 'Error while doing fetch of %s. %s'],
|
|
14
14
|
[c.STREAMING_PARSING_ERROR_FAILS, c.LOG_PREFIX_SYNC_STREAMING + 'Error parsing SSE error notification: %s'],
|
|
15
15
|
[c.STREAMING_PARSING_MESSAGE_FAILS, c.LOG_PREFIX_SYNC_STREAMING + 'Error parsing SSE message notification: %s'],
|
|
16
16
|
[c.STREAMING_FALLBACK, c.LOG_PREFIX_SYNC_STREAMING + 'Falling back to polling mode. Reason: %s'],
|
|
17
|
-
[c.SUBMITTERS_PUSH_FAILS, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Dropping %s after retry. Reason: %s
|
|
18
|
-
[c.SUBMITTERS_PUSH_RETRY, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Failed to push %s, keeping data to retry on next iteration. Reason: %s
|
|
17
|
+
[c.SUBMITTERS_PUSH_FAILS, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Dropping %s after retry. Reason: %s'],
|
|
18
|
+
[c.SUBMITTERS_PUSH_RETRY, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Failed to push %s, keeping data to retry on next iteration. Reason: %s'],
|
|
19
19
|
// client status
|
|
20
|
-
[c.CLIENT_NOT_READY_FROM_CACHE, '%s: the SDK is not ready to evaluate. Results may be incorrect
|
|
21
|
-
[c.CLIENT_NO_LISTENER, 'No listeners for SDK_READY event detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet synchronized with the backend.'],
|
|
20
|
+
[c.CLIENT_NOT_READY_FROM_CACHE, '%s: the SDK is not ready to evaluate. Results may be incorrect. Make sure to wait for SDK readiness before using this method.'],
|
|
22
21
|
// input validation
|
|
23
22
|
[c.WARN_SETTING_NULL, '%s: Property "%s" is of invalid type. Setting value to null.'],
|
|
24
23
|
[c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
|
|
25
24
|
[c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
|
|
26
25
|
[c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
|
|
27
|
-
[c.
|
|
26
|
+
[c.WARN_NOT_EXISTENT_DEFINITION, '%s: "%s" does not exist in this environment. Please double check that it exists in Harness FME UI.'],
|
|
28
27
|
[c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
|
|
29
28
|
[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 Harness FME UI.'],
|
|
30
29
|
[c.WARN_FLAGSET_NOT_CONFIGURED, '%s: you passed %s which is not part of the configured FlagSetsFilter, ignoring Flag Set.'],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.platform = void 0;
|
|
4
|
+
var EventEmitter_1 = require("../utils/EventEmitter");
|
|
5
|
+
var browser_1 = require("../platform/getFetch/browser");
|
|
6
|
+
var browser_2 = require("../platform/getEventSource/browser");
|
|
7
|
+
var browser_3 = require("../listeners/browser");
|
|
8
|
+
var browser_4 = require("../utils/timeTracker/now/browser");
|
|
9
|
+
exports.platform = {
|
|
10
|
+
getFetch: browser_1.getFetch,
|
|
11
|
+
getEventSource: browser_2.getEventSource,
|
|
12
|
+
EventEmitter: EventEmitter_1.EventEmitter,
|
|
13
|
+
now: browser_4.now,
|
|
14
|
+
SignalListener: browser_3.BrowserSignalListener
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEventSource = void 0;
|
|
4
|
+
function getEventSource() {
|
|
5
|
+
// eslint-disable-next-line no-undef -- Feature detection for EventSource
|
|
6
|
+
return typeof EventSource === 'function' ? EventSource : undefined;
|
|
7
|
+
}
|
|
8
|
+
exports.getEventSource = getEventSource;
|