@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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.url = void 0;
|
|
4
|
-
var telemetryEndpointMatcher = /^\/v1\/metrics\/(config|usage)/;
|
|
4
|
+
var telemetryEndpointMatcher = /^\/v1\/(metrics|keys)\/(config|usage|ss|cs)/;
|
|
5
5
|
var eventsEndpointMatcher = /^\/(testImpressions|metrics|events)/;
|
|
6
|
-
var authEndpointMatcher = /^\/v2\/auth/;
|
|
6
|
+
var authEndpointMatcher = /^\/(v2|v3)\/auth/;
|
|
7
7
|
var streamingEndpointMatcher = /^\/(sse|event-stream)/;
|
|
8
|
+
var configsEndpointMatcher = /^\/v1\/(configs|segmentChanges)/;
|
|
8
9
|
/**
|
|
9
10
|
* Get URL based on a given target (path).
|
|
10
11
|
* ATM, it is only used for testing purposes.
|
|
@@ -26,6 +27,9 @@ function url(settings, target) {
|
|
|
26
27
|
if (streamingEndpointMatcher.test(target)) {
|
|
27
28
|
return "".concat(settings.urls.streaming).concat(target);
|
|
28
29
|
}
|
|
30
|
+
if (configsEndpointMatcher.test(target)) {
|
|
31
|
+
return "".concat(settings.urls.configs).concat(target);
|
|
32
|
+
}
|
|
29
33
|
return "".concat(settings.urls.sdk).concat(target);
|
|
30
34
|
}
|
|
31
35
|
exports.url = url;
|
|
@@ -7,7 +7,7 @@ function match(log, matchingResult, bucketingKey, seed, treatments, label) {
|
|
|
7
7
|
return treatments ? // Feature flag
|
|
8
8
|
{
|
|
9
9
|
treatment: getTreatment(log, bucketingKey, seed, treatments),
|
|
10
|
-
label: label
|
|
10
|
+
label: label !== null && label !== void 0 ? label : ''
|
|
11
11
|
} : // Rule-based segment
|
|
12
12
|
true;
|
|
13
13
|
}
|
|
@@ -20,7 +20,7 @@ export function conditionContext(log, matcherEvaluator, treatments, label, condi
|
|
|
20
20
|
// Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
|
|
21
21
|
if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation, key.bucketingKey, trafficAllocationSeed)) {
|
|
22
22
|
return {
|
|
23
|
-
treatment
|
|
23
|
+
// treatment value is assigned later, at Engine's evaluationResult
|
|
24
24
|
label: NOT_IN_SPLIT
|
|
25
25
|
};
|
|
26
26
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { isObject, isString } from '../../../utils/lang';
|
|
2
|
-
var
|
|
3
|
-
(
|
|
4
|
-
FallbackDiscardReason["FlagName"] = "Invalid flag name (max 100 chars, no spaces)";
|
|
5
|
-
FallbackDiscardReason["Treatment"] = "Invalid treatment (max 100 chars and must match pattern)";
|
|
6
|
-
})(FallbackDiscardReason || (FallbackDiscardReason = {}));
|
|
2
|
+
var FLAG_NAME_DISCARD_REASON = 'Invalid flag name (max 100 chars, no spaces)';
|
|
3
|
+
var TREATMENT_DISCARD_REASON = 'Invalid treatment (max 100 chars and must match pattern)';
|
|
7
4
|
var TREATMENT_PATTERN = /^[0-9]+[.a-zA-Z0-9_-]*$|^[a-zA-Z]+[a-zA-Z0-9_-]*$/;
|
|
8
5
|
export function isValidFlagName(name) {
|
|
9
6
|
return name.length <= 100 && !name.includes(' ');
|
|
@@ -19,7 +16,7 @@ function sanitizeGlobal(logger, treatment) {
|
|
|
19
16
|
if (treatment === undefined)
|
|
20
17
|
return undefined;
|
|
21
18
|
if (!isValidTreatment(treatment)) {
|
|
22
|
-
logger.error("Fallback treatments - Discarded fallback: ".concat(
|
|
19
|
+
logger.error("Fallback treatments - Discarded fallback: ".concat(TREATMENT_DISCARD_REASON));
|
|
23
20
|
return undefined;
|
|
24
21
|
}
|
|
25
22
|
return treatment;
|
|
@@ -31,11 +28,11 @@ function sanitizeByFlag(logger, byFlagFallbacks) {
|
|
|
31
28
|
Object.keys(byFlagFallbacks).forEach(function (flag) {
|
|
32
29
|
var t = byFlagFallbacks[flag];
|
|
33
30
|
if (!isValidFlagName(flag)) {
|
|
34
|
-
logger.error("Fallback treatments - Discarded flag '".concat(flag, "': ").concat(
|
|
31
|
+
logger.error("Fallback treatments - Discarded flag '".concat(flag, "': ").concat(FLAG_NAME_DISCARD_REASON));
|
|
35
32
|
return;
|
|
36
33
|
}
|
|
37
34
|
if (!isValidTreatment(t)) {
|
|
38
|
-
logger.error("Fallback treatments - Discarded treatment for flag '".concat(flag, "': ").concat(
|
|
35
|
+
logger.error("Fallback treatments - Discarded treatment for flag '".concat(flag, "': ").concat(TREATMENT_DISCARD_REASON));
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
38
|
sanitizedByFlag[flag] = t;
|
package/esm/evaluator/index.js
CHANGED
|
@@ -1,57 +1,68 @@
|
|
|
1
1
|
import { engineParser } from './Engine';
|
|
2
2
|
import { thenable } from '../utils/promise/thenable';
|
|
3
|
-
import { EXCEPTION,
|
|
3
|
+
import { EXCEPTION, NO_CONDITION_MATCH, DEFINITION_NOT_FOUND } from '../utils/labels';
|
|
4
4
|
import { CONTROL } from '../utils/constants';
|
|
5
5
|
import { returnSetsUnion, setToArray } from '../utils/lang/sets';
|
|
6
6
|
import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
|
|
7
|
-
|
|
7
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
8
|
+
var EVALUATION_EXCEPTION = {
|
|
8
9
|
treatment: CONTROL,
|
|
9
10
|
label: EXCEPTION,
|
|
10
11
|
config: null
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
+
var EVALUATION_DEFINITION_NOT_FOUND = {
|
|
14
|
+
treatment: CONTROL,
|
|
15
|
+
label: DEFINITION_NOT_FOUND,
|
|
16
|
+
config: null
|
|
17
|
+
};
|
|
18
|
+
function treatmentsException(definitionNames) {
|
|
13
19
|
var evaluations = {};
|
|
14
|
-
|
|
15
|
-
evaluations[
|
|
20
|
+
definitionNames.forEach(function (definitionName) {
|
|
21
|
+
evaluations[definitionName] = EVALUATION_EXCEPTION;
|
|
16
22
|
});
|
|
17
23
|
return evaluations;
|
|
18
24
|
}
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
function setEvaluationDataFromDefinition(evaluation, definition) {
|
|
26
|
+
return objectAssign(evaluation, {
|
|
27
|
+
definition: definition,
|
|
28
|
+
config: definition.configurations && definition.configurations[evaluation.treatment] || null
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function evaluateFeature(log, key, definitionName, attributes, storage) {
|
|
32
|
+
var definition;
|
|
21
33
|
try {
|
|
22
|
-
|
|
34
|
+
definition = storage.definitions.get(definitionName);
|
|
23
35
|
}
|
|
24
36
|
catch (e) {
|
|
25
|
-
// Exception on sync
|
|
26
|
-
return
|
|
37
|
+
// Exception on sync storage. Not possible ATM with InMemory and InLocal storages.
|
|
38
|
+
return EVALUATION_EXCEPTION;
|
|
27
39
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
return thenable(definition) ?
|
|
41
|
+
definition.then(function (definition) { return getEvaluation(log, key, definition, attributes, storage); })
|
|
42
|
+
.catch(
|
|
43
|
+
// Exception on async storage. For example, when the storage is redis or
|
|
31
44
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
32
|
-
function () { return
|
|
33
|
-
|
|
34
|
-
return getEvaluation(log, key, parsedSplit, attributes, storage, options);
|
|
45
|
+
function () { return EVALUATION_EXCEPTION; }) :
|
|
46
|
+
getEvaluation(log, key, definition, attributes, storage);
|
|
35
47
|
}
|
|
36
|
-
export function evaluateFeatures(log, key,
|
|
37
|
-
var
|
|
48
|
+
export function evaluateFeatures(log, key, definitionNames, attributes, storage) {
|
|
49
|
+
var definitions;
|
|
38
50
|
try {
|
|
39
|
-
|
|
51
|
+
definitions = storage.definitions.getMany(definitionNames);
|
|
40
52
|
}
|
|
41
53
|
catch (e) {
|
|
42
|
-
// Exception on sync
|
|
43
|
-
return treatmentsException(
|
|
54
|
+
// Exception on sync storage. Not possible ATM with InMemory and InLocal storages.
|
|
55
|
+
return treatmentsException(definitionNames);
|
|
44
56
|
}
|
|
45
|
-
return thenable(
|
|
46
|
-
|
|
47
|
-
.catch(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
getEvaluations(log, key, splitNames, parsedSplits, attributes, storage, options);
|
|
57
|
+
return thenable(definitions) ?
|
|
58
|
+
definitions.then(function (definitions) { return getEvaluations(log, key, definitionNames, definitions, attributes, storage); })
|
|
59
|
+
.catch(
|
|
60
|
+
// Exception on async storage. For example, when the storage is redis or
|
|
61
|
+
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
62
|
+
function () { return treatmentsException(definitionNames); }) :
|
|
63
|
+
getEvaluations(log, key, definitionNames, definitions, attributes, storage);
|
|
53
64
|
}
|
|
54
|
-
export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method
|
|
65
|
+
export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
|
|
55
66
|
var storedFlagNames;
|
|
56
67
|
function evaluate(featureFlagsByFlagSets) {
|
|
57
68
|
var featureFlags = new Set();
|
|
@@ -65,12 +76,12 @@ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, stora
|
|
|
65
76
|
}
|
|
66
77
|
}
|
|
67
78
|
return featureFlags.size ?
|
|
68
|
-
evaluateFeatures(log, key, setToArray(featureFlags), attributes, storage
|
|
79
|
+
evaluateFeatures(log, key, setToArray(featureFlags), attributes, storage) :
|
|
69
80
|
{};
|
|
70
81
|
}
|
|
71
82
|
// get features by flag sets
|
|
72
83
|
try {
|
|
73
|
-
storedFlagNames = storage.
|
|
84
|
+
storedFlagNames = storage.definitions.getNamesBySets(flagSets);
|
|
74
85
|
}
|
|
75
86
|
catch (e) {
|
|
76
87
|
// return empty evaluations
|
|
@@ -79,52 +90,50 @@ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, stora
|
|
|
79
90
|
// evaluate related features
|
|
80
91
|
return thenable(storedFlagNames) ?
|
|
81
92
|
storedFlagNames.then(function (storedFlagNames) { return evaluate(storedFlagNames); })
|
|
82
|
-
.catch(function () {
|
|
83
|
-
return {};
|
|
84
|
-
}) :
|
|
93
|
+
.catch(function () { return ({}); }) :
|
|
85
94
|
evaluate(storedFlagNames);
|
|
86
95
|
}
|
|
87
|
-
function getEvaluation(log, key,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var split = engineParser(log, splitJSON, storage);
|
|
95
|
-
evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
96
|
-
// If the storage is async and the evaluated flag uses segments or dependencies, evaluation is thenable
|
|
97
|
-
if (thenable(evaluation)) {
|
|
98
|
-
return evaluation.then(function (result) {
|
|
99
|
-
result.changeNumber = splitJSON.changeNumber;
|
|
100
|
-
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
|
|
101
|
-
// @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
|
|
102
|
-
result.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || splitJSON.impressionsDisabled;
|
|
103
|
-
return result;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
evaluation.changeNumber = splitJSON.changeNumber;
|
|
108
|
-
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
|
|
109
|
-
// @ts-expect-error impressionsDisabled is not exposed in the public typings yet.
|
|
110
|
-
evaluation.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || splitJSON.impressionsDisabled;
|
|
111
|
-
}
|
|
96
|
+
function getEvaluation(log, key, definition, attributes, storage) {
|
|
97
|
+
if (definition) {
|
|
98
|
+
var split = engineParser(log, definition, storage);
|
|
99
|
+
var evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
100
|
+
return thenable(evaluation) ?
|
|
101
|
+
evaluation.then(function (result) { return setEvaluationDataFromDefinition(result, definition); }) :
|
|
102
|
+
setEvaluationDataFromDefinition(evaluation, definition);
|
|
112
103
|
}
|
|
113
|
-
return
|
|
104
|
+
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
114
105
|
}
|
|
115
|
-
function getEvaluations(log, key,
|
|
106
|
+
function getEvaluations(log, key, definitionNames, definitions, attributes, storage) {
|
|
116
107
|
var result = {};
|
|
117
108
|
var thenables = [];
|
|
118
|
-
|
|
119
|
-
var evaluation = getEvaluation(log, key,
|
|
120
|
-
|
|
109
|
+
definitionNames.forEach(function (definitionName) {
|
|
110
|
+
var evaluation = getEvaluation(log, key, definitions[definitionName], attributes, storage);
|
|
111
|
+
thenable(evaluation) ?
|
|
121
112
|
thenables.push(evaluation.then(function (res) {
|
|
122
|
-
result[
|
|
123
|
-
}))
|
|
124
|
-
|
|
125
|
-
else {
|
|
126
|
-
result[splitName] = evaluation;
|
|
127
|
-
}
|
|
113
|
+
result[definitionName] = res;
|
|
114
|
+
})) :
|
|
115
|
+
result[definitionName] = evaluation;
|
|
128
116
|
});
|
|
129
117
|
return thenables.length > 0 ? Promise.all(thenables).then(function () { return result; }) : result;
|
|
130
118
|
}
|
|
119
|
+
export function evaluateDefaultTreatment(definitionName, storage) {
|
|
120
|
+
var definition;
|
|
121
|
+
try {
|
|
122
|
+
definition = storage.definitions.get(definitionName);
|
|
123
|
+
}
|
|
124
|
+
catch (e) {
|
|
125
|
+
return EVALUATION_EXCEPTION;
|
|
126
|
+
}
|
|
127
|
+
return thenable(definition) ?
|
|
128
|
+
definition.then(getDefaultTreatment).catch(function () { return EVALUATION_EXCEPTION; }) :
|
|
129
|
+
getDefaultTreatment(definition);
|
|
130
|
+
}
|
|
131
|
+
function getDefaultTreatment(definition) {
|
|
132
|
+
if (definition) {
|
|
133
|
+
return setEvaluationDataFromDefinition({
|
|
134
|
+
treatment: definition.defaultTreatment,
|
|
135
|
+
label: NO_CONDITION_MATCH, // "default rule"
|
|
136
|
+
}, definition);
|
|
137
|
+
}
|
|
138
|
+
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
139
|
+
}
|
package/esm/listeners/browser.js
CHANGED
|
@@ -10,7 +10,8 @@ var EVENT_NAME = 'for visibilitychange and pagehide events.';
|
|
|
10
10
|
* We'll listen for events over the window object.
|
|
11
11
|
*/
|
|
12
12
|
var BrowserSignalListener = /** @class */ (function () {
|
|
13
|
-
function BrowserSignalListener(
|
|
13
|
+
function BrowserSignalListener(_a) {
|
|
14
|
+
var syncManager = _a.syncManager, settings = _a.settings, storage = _a.storage, serviceApi = _a.serviceApi;
|
|
14
15
|
this.syncManager = syncManager;
|
|
15
16
|
this.settings = settings;
|
|
16
17
|
this.storage = storage;
|
package/esm/listeners/node.js
CHANGED
|
@@ -10,8 +10,8 @@ var EVENT_NAME = 'for SIGTERM signal.';
|
|
|
10
10
|
* the process is already exiting.
|
|
11
11
|
*/
|
|
12
12
|
var NodeSignalListener = /** @class */ (function () {
|
|
13
|
-
function NodeSignalListener(
|
|
14
|
-
|
|
13
|
+
function NodeSignalListener(_a) {
|
|
14
|
+
var syncManager = _a.syncManager, settings = _a.settings;
|
|
15
15
|
// @TODO review handler logic when implementing Node.js SDK
|
|
16
16
|
this.handler = function () {
|
|
17
17
|
if (syncManager) {
|
|
@@ -44,13 +44,13 @@ var NodeSignalListener = /** @class */ (function () {
|
|
|
44
44
|
// eslint-disable-next-line no-undef
|
|
45
45
|
process.kill(process.pid, SIGTERM);
|
|
46
46
|
};
|
|
47
|
-
this.settings.log.debug("".concat(LOG_PREFIX_CLEANUP, "
|
|
47
|
+
this.settings.log.debug("".concat(LOG_PREFIX_CLEANUP, "SDK graceful shutdown after SIGTERM."));
|
|
48
48
|
var handlerResult = null;
|
|
49
49
|
try {
|
|
50
50
|
handlerResult = this.handler();
|
|
51
51
|
}
|
|
52
52
|
catch (err) {
|
|
53
|
-
this.settings.log.error("".concat(LOG_PREFIX_CLEANUP, "Error with
|
|
53
|
+
this.settings.log.error("".concat(LOG_PREFIX_CLEANUP, "Error with SDK graceful shutdown: ").concat(err));
|
|
54
54
|
}
|
|
55
55
|
if (thenable(handlerResult)) {
|
|
56
56
|
// Always exit, even with errors. The promise is returned for UT purposes.
|
package/esm/logger/constants.js
CHANGED
|
@@ -19,9 +19,8 @@ export var RETRIEVE_CLIENT_DEFAULT = 27;
|
|
|
19
19
|
export var RETRIEVE_CLIENT_EXISTING = 28;
|
|
20
20
|
export var RETRIEVE_MANAGER = 29;
|
|
21
21
|
export var SYNC_OFFLINE_DATA = 30;
|
|
22
|
-
export var
|
|
23
|
-
export var
|
|
24
|
-
export var SYNC_RBS_UPDATE = 33;
|
|
22
|
+
export var SYNC_FETCH = 31;
|
|
23
|
+
export var SYNC_UPDATE = 32;
|
|
25
24
|
export var STREAMING_NEW_MESSAGE = 35;
|
|
26
25
|
export var SYNC_TASK_START = 36;
|
|
27
26
|
export var SYNC_TASK_EXECUTE = 37;
|
|
@@ -37,7 +36,6 @@ export var NEW_FACTORY = 105;
|
|
|
37
36
|
export var POLLING_SMART_PAUSING = 106;
|
|
38
37
|
export var POLLING_START = 107;
|
|
39
38
|
export var POLLING_STOP = 108;
|
|
40
|
-
export var SYNC_SPLITS_FETCH_RETRY = 109;
|
|
41
39
|
export var STREAMING_REFRESH_TOKEN = 110;
|
|
42
40
|
export var STREAMING_RECONNECT = 111;
|
|
43
41
|
export var STREAMING_CONNECTING = 112;
|
|
@@ -56,10 +54,9 @@ export var USER_CONSENT_INITIAL = 124;
|
|
|
56
54
|
export var SUBMITTERS_PUSH_PAGE_HIDDEN = 125;
|
|
57
55
|
export var ENGINE_VALUE_INVALID = 200;
|
|
58
56
|
export var ENGINE_VALUE_NO_ATTRIBUTES = 201;
|
|
59
|
-
export var CLIENT_NO_LISTENER = 202;
|
|
60
57
|
export var CLIENT_NOT_READY_FROM_CACHE = 203;
|
|
61
|
-
export var
|
|
62
|
-
export var
|
|
58
|
+
export var SYNC_FETCH_RETRY = 204;
|
|
59
|
+
export var SYNC_FETCH_FAILS = 205;
|
|
63
60
|
export var STREAMING_PARSING_ERROR_FAILS = 206;
|
|
64
61
|
export var STREAMING_PARSING_MESSAGE_FAILS = 207;
|
|
65
62
|
export var STREAMING_FALLBACK = 208;
|
|
@@ -69,7 +66,7 @@ export var WARN_SETTING_NULL = 211;
|
|
|
69
66
|
export var WARN_TRIMMING_PROPERTIES = 212;
|
|
70
67
|
export var WARN_CONVERTING = 213;
|
|
71
68
|
export var WARN_TRIMMING = 214;
|
|
72
|
-
export var
|
|
69
|
+
export var WARN_NOT_EXISTENT_DEFINITION = 215;
|
|
73
70
|
export var WARN_LOWERCASE_TRAFFIC_TYPE = 216;
|
|
74
71
|
export var WARN_NOT_EXISTENT_TT = 217;
|
|
75
72
|
export var WARN_INTEGRATION_INVALID = 218;
|
|
@@ -120,15 +117,13 @@ export var LOG_PREFIX_ENGINE = 'engine';
|
|
|
120
117
|
export var LOG_PREFIX_ENGINE_COMBINER = LOG_PREFIX_ENGINE + ':combiner: ';
|
|
121
118
|
export var LOG_PREFIX_ENGINE_MATCHER = LOG_PREFIX_ENGINE + ':matcher: ';
|
|
122
119
|
export var LOG_PREFIX_ENGINE_VALUE = LOG_PREFIX_ENGINE + ':value: ';
|
|
123
|
-
export var LOG_PREFIX_SYNC = 'sync';
|
|
124
|
-
export var
|
|
125
|
-
export var
|
|
126
|
-
export var
|
|
127
|
-
export var
|
|
128
|
-
export var
|
|
129
|
-
export var
|
|
130
|
-
export var LOG_PREFIX_SYNC_POLLING = LOG_PREFIX_SYNC + ':polling-manager: ';
|
|
131
|
-
export var LOG_PREFIX_SYNC_SUBMITTERS = LOG_PREFIX_SYNC + ':submitter: ';
|
|
120
|
+
export var LOG_PREFIX_SYNC = 'sync: ';
|
|
121
|
+
export var LOG_PREFIX_SYNC_AUTH = 'sync:auth: ';
|
|
122
|
+
export var LOG_PREFIX_SYNC_MANAGER = 'sync:sync-manager: ';
|
|
123
|
+
export var LOG_PREFIX_SYNC_OFFLINE = 'sync:offline: ';
|
|
124
|
+
export var LOG_PREFIX_SYNC_STREAMING = 'sync:streaming: ';
|
|
125
|
+
export var LOG_PREFIX_SYNC_POLLING = 'sync:polling-manager: ';
|
|
126
|
+
export var LOG_PREFIX_SYNC_SUBMITTERS = 'sync:submitter: ';
|
|
132
127
|
export var LOG_PREFIX_IMPRESSIONS_TRACKER = 'impressions-tracker: ';
|
|
133
128
|
export var LOG_PREFIX_EVENTS_TRACKER = 'events-tracker: ';
|
|
134
129
|
export var LOG_PREFIX_UNIQUE_KEYS_TRACKER = 'unique-keys-tracker: ';
|
|
@@ -20,13 +20,12 @@ export var codesDebug = codesInfo.concat([
|
|
|
20
20
|
[c.RETRIEVE_MANAGER, 'Retrieving manager instance.'],
|
|
21
21
|
// synchronizer
|
|
22
22
|
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
|
|
23
|
-
[c.
|
|
24
|
-
[c.
|
|
25
|
-
[c.SYNC_RBS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New rule-based segments: %s. Removed rule-based segments: %s.'],
|
|
23
|
+
[c.SYNC_FETCH, c.LOG_PREFIX_SYNC + 'Spin up %s updates using since = %s and rbSince = %s.'],
|
|
24
|
+
[c.SYNC_UPDATE, c.LOG_PREFIX_SYNC + 'Updated %s: %s. Removed: %s.'],
|
|
26
25
|
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
|
|
27
|
-
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + '
|
|
28
|
-
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + '
|
|
29
|
-
[c.SYNC_TASK_STOP, c.LOG_PREFIX_SYNC + '
|
|
26
|
+
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + 'Starting %s. Running each %s millis'],
|
|
27
|
+
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + 'Running %s'],
|
|
28
|
+
[c.SYNC_TASK_STOP, c.LOG_PREFIX_SYNC + 'Stopping %s'],
|
|
30
29
|
// initialization / settings validation
|
|
31
30
|
[c.SETTINGS_SPLITS_FILTER, c.LOG_PREFIX_SETTINGS + ': feature flags filtering criteria is "%s".']
|
|
32
31
|
]);
|
|
@@ -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 definition, no valid rules or unsupported targeting rule type found'],
|
|
5
5
|
[c.ENGINE_MATCHER_ERROR, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] %s'],
|
|
6
6
|
// SDK
|
|
7
7
|
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
|
|
@@ -12,7 +12,7 @@ export var codesError = [
|
|
|
12
12
|
// synchronizer
|
|
13
13
|
[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'],
|
|
14
14
|
[c.ERROR_STREAMING_SSE, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to connect or error on streaming connection, with error message: %s'],
|
|
15
|
-
[c.ERROR_STREAMING_AUTH, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to authenticate for streaming. Error: %s
|
|
15
|
+
[c.ERROR_STREAMING_AUTH, c.LOG_PREFIX_SYNC_STREAMING + 'Failed to authenticate for streaming. Error: %s'],
|
|
16
16
|
[c.ERROR_HTTP, 'HTTP request failed with %s. URL: %s. Message: %s'],
|
|
17
17
|
// client status
|
|
18
18
|
[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.'],
|
|
@@ -33,6 +33,6 @@ export var codesError = [
|
|
|
33
33
|
[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".'],
|
|
34
34
|
[c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': the provided storage is invalid.%s Falling back into default MEMORY storage'],
|
|
35
35
|
[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'],
|
|
36
|
-
[c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the
|
|
36
|
+
[c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the number of sets provided is too high, which causes a URI length error.'],
|
|
37
37
|
[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.'],
|
|
38
38
|
];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as c from '../constants';
|
|
2
2
|
import { codesWarn } from './warn';
|
|
3
|
-
var READY_MSG = '
|
|
3
|
+
var READY_MSG = 'SDK client is ready';
|
|
4
4
|
export var codesInfo = codesWarn.concat([
|
|
5
5
|
// client status
|
|
6
6
|
[c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
|
|
7
7
|
[c.CLIENT_READY, READY_MSG],
|
|
8
8
|
// SDK
|
|
9
|
-
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing impression.
|
|
9
|
+
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing impression. %s: %s. Key: %s. Evaluation: %s. Label: %s'],
|
|
10
10
|
[c.NEW_SHARED_CLIENT, 'New shared client instance created.'],
|
|
11
|
-
[c.NEW_FACTORY, 'New
|
|
11
|
+
[c.NEW_FACTORY, 'New SDK instance created. %s'],
|
|
12
12
|
[c.EVENTS_TRACKER_SUCCESS, c.LOG_PREFIX_EVENTS_TRACKER + 'Successfully queued %s'],
|
|
13
13
|
[c.IMPRESSIONS_TRACKER_SUCCESS, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Successfully stored %s impression(s).'],
|
|
14
14
|
[c.USER_CONSENT_UPDATED, 'UserConsent: consent status changed from %s to %s.'],
|
|
@@ -18,7 +18,6 @@ export var codesInfo = codesWarn.concat([
|
|
|
18
18
|
[c.POLLING_SMART_PAUSING, c.LOG_PREFIX_SYNC_POLLING + 'Turning segments data polling %s.'],
|
|
19
19
|
[c.POLLING_START, c.LOG_PREFIX_SYNC_POLLING + 'Starting polling'],
|
|
20
20
|
[c.POLLING_STOP, c.LOG_PREFIX_SYNC_POLLING + 'Stopping polling'],
|
|
21
|
-
[c.SYNC_SPLITS_FETCH_RETRY, c.LOG_PREFIX_SYNC_SPLITS + 'Retrying fetch of feature flags (attempt #%s). Reason: %s'],
|
|
22
21
|
[c.SUBMITTERS_PUSH_FULL_QUEUE, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing full %s queue and resetting timer.'],
|
|
23
22
|
[c.SUBMITTERS_PUSH, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Pushing %s.'],
|
|
24
23
|
[c.SUBMITTERS_PUSH_PAGE_HIDDEN, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing %s because page became hidden.'],
|
|
@@ -5,22 +5,21 @@ export var codesWarn = codesError.concat([
|
|
|
5
5
|
[c.ENGINE_VALUE_INVALID, c.LOG_PREFIX_ENGINE_VALUE + 'Value %s doesn\'t match with expected type.'],
|
|
6
6
|
[c.ENGINE_VALUE_NO_ATTRIBUTES, c.LOG_PREFIX_ENGINE_VALUE + 'Defined attribute `%s`. No attributes received.'],
|
|
7
7
|
// synchronizer
|
|
8
|
-
[c.
|
|
9
|
-
[c.
|
|
8
|
+
[c.SYNC_FETCH_RETRY, c.LOG_PREFIX_SYNC + 'Retrying fetch of %s (attempt #%s). Reason: %s'],
|
|
9
|
+
[c.SYNC_FETCH_FAILS, c.LOG_PREFIX_SYNC + 'Error while doing fetch of %s. %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'],
|
|
13
|
-
[c.SUBMITTERS_PUSH_FAILS, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Dropping %s after retry. Reason: %s
|
|
14
|
-
[c.SUBMITTERS_PUSH_RETRY, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Failed to push %s, keeping data to retry on next iteration. Reason: %s
|
|
13
|
+
[c.SUBMITTERS_PUSH_FAILS, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Dropping %s after retry. Reason: %s'],
|
|
14
|
+
[c.SUBMITTERS_PUSH_RETRY, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Failed to push %s, keeping data to retry on next iteration. Reason: %s'],
|
|
15
15
|
// client status
|
|
16
|
-
[c.CLIENT_NOT_READY_FROM_CACHE, '%s: the SDK is not ready to evaluate. Results may be incorrect
|
|
17
|
-
[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.'],
|
|
16
|
+
[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.'],
|
|
18
17
|
// input validation
|
|
19
18
|
[c.WARN_SETTING_NULL, '%s: Property "%s" is of invalid type. Setting value to null.'],
|
|
20
19
|
[c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
|
|
21
20
|
[c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
|
|
22
21
|
[c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
|
|
23
|
-
[c.
|
|
22
|
+
[c.WARN_NOT_EXISTENT_DEFINITION, '%s: "%s" does not exist in this environment. Please double check that it exists in Harness FME UI.'],
|
|
24
23
|
[c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
|
|
25
24
|
[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.'],
|
|
26
25
|
[c.WARN_FLAGSET_NOT_CONFIGURED, '%s: you passed %s which is not part of the configured FlagSetsFilter, ignoring Flag Set.'],
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventEmitter } from '../utils/EventEmitter';
|
|
2
|
+
import { getFetch } from '../platform/getFetch/browser';
|
|
3
|
+
import { getEventSource } from '../platform/getEventSource/browser';
|
|
4
|
+
import { BrowserSignalListener } from '../listeners/browser';
|
|
5
|
+
import { now } from '../utils/timeTracker/now/browser';
|
|
6
|
+
export var platform = {
|
|
7
|
+
getFetch: getFetch,
|
|
8
|
+
getEventSource: getEventSource,
|
|
9
|
+
EventEmitter: EventEmitter,
|
|
10
|
+
now: now,
|
|
11
|
+
SignalListener: BrowserSignalListener
|
|
12
|
+
};
|