@splitsoftware/splitio-commons 2.11.1-rc.2 → 3.0.0-rc.0
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 +15 -2
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +70 -0
- package/cjs/evaluator/fallbackConfigsCalculator/index.js +25 -0
- package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/cjs/evaluator/fallbackTreatmentsCalculator/index.js +21 -32
- package/cjs/evaluator/index.js +67 -42
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/integrations/pluggable.js +1 -1
- package/cjs/listeners/browser.js +4 -3
- package/cjs/listeners/node.js +4 -4
- package/cjs/logger/constants.js +14 -20
- package/cjs/logger/index.js +1 -1
- package/cjs/logger/messages/debug.js +6 -7
- package/cjs/logger/messages/error.js +4 -4
- package/cjs/logger/messages/info.js +2 -4
- package/cjs/logger/messages/warn.js +9 -9
- 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/readiness/constants.js +2 -1
- package/cjs/sdkClient/client.js +9 -35
- package/cjs/sdkClient/clientAttributesDecoration.js +3 -3
- package/cjs/sdkClient/clientInputValidation.js +38 -81
- package/cjs/sdkClient/identity.js +1 -1
- package/cjs/sdkClient/sdkClient.js +4 -49
- package/cjs/sdkClient/sdkLifecycle.js +70 -0
- package/cjs/sdkClient/trackMethod.js +56 -0
- package/cjs/sdkFactory/index.js +8 -45
- package/cjs/sdkManager/index.js +3 -3
- package/cjs/services/splitApi.js +18 -13
- package/cjs/services/splitHttpClient.js +1 -1
- package/cjs/storages/AbstractSplitsCacheAsync.js +1 -1
- package/cjs/storages/AbstractSplitsCacheSync.js +1 -1
- package/cjs/storages/KeyBuilder.js +12 -12
- package/cjs/storages/KeyBuilderCS.js +13 -13
- package/cjs/storages/KeyBuilderSS.js +15 -15
- package/cjs/storages/getRolloutPlan.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +2 -2
- package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -5
- package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +8 -8
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -6
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +6 -6
- package/cjs/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +4 -4
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
- package/cjs/storages/pluggable/index.js +3 -3
- package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
- package/cjs/storages/setRolloutPlan.js +1 -1
- package/cjs/storages/utils.js +6 -6
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +23 -14
- package/cjs/sync/polling/pollingManagerCS.js +11 -11
- package/cjs/sync/polling/pollingManagerSS.js +13 -13
- package/cjs/sync/polling/syncTasks/definitionsSyncTask.js +12 -0
- package/cjs/sync/polling/updaters/{splitChangesUpdater.js → definitionChangesUpdater.js} +67 -59
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +1 -1
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/streaming/SSEClient/index.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/parseUtils.js +12 -12
- package/cjs/sync/streaming/pushManager.js +2 -2
- package/cjs/sync/submitters/impressionsSubmitter.js +6 -6
- package/cjs/sync/submitters/submitter.js +1 -1
- package/cjs/sync/syncManagerOnline.js +5 -2
- package/cjs/trackers/eventTracker.js +10 -12
- package/cjs/trackers/impressionObserver/buildKey.js +1 -1
- package/cjs/trackers/impressionsTracker.js +37 -20
- package/cjs/trackers/uniqueKeysTracker.js +1 -1
- package/cjs/utils/EventEmitter.js +391 -0
- package/cjs/utils/filter/bloomFilter.js +37 -0
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +2 -2
- 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/eventProperties.js +1 -1
- 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/lang/index.js +1 -1
- package/cjs/utils/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +4 -4
- package/cjs/utils/settingsValidation/url.js +5 -5
- package/esm/evaluator/condition/engineUtils.js +2 -2
- package/esm/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.js +64 -0
- package/esm/evaluator/fallbackConfigsCalculator/index.js +21 -0
- package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +5 -8
- package/esm/evaluator/fallbackTreatmentsCalculator/index.js +21 -33
- package/esm/evaluator/index.js +66 -42
- package/esm/evaluator/matchers/whitelist.js +1 -1
- package/esm/integrations/pluggable.js +1 -1
- package/esm/listeners/browser.js +4 -3
- package/esm/listeners/node.js +4 -4
- package/esm/logger/constants.js +11 -17
- package/esm/logger/index.js +1 -1
- package/esm/logger/messages/debug.js +5 -6
- package/esm/logger/messages/error.js +3 -3
- package/esm/logger/messages/info.js +1 -3
- package/esm/logger/messages/warn.js +8 -8
- 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/readiness/constants.js +1 -0
- package/esm/sdkClient/client.js +10 -37
- package/esm/sdkClient/clientAttributesDecoration.js +3 -3
- package/esm/sdkClient/clientInputValidation.js +40 -83
- package/esm/sdkClient/identity.js +1 -1
- package/esm/sdkClient/sdkClient.js +4 -49
- package/esm/sdkClient/sdkLifecycle.js +66 -0
- package/esm/sdkClient/trackMethod.js +52 -0
- package/esm/sdkFactory/index.js +8 -45
- package/esm/sdkManager/index.js +4 -4
- package/esm/services/splitApi.js +18 -13
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/AbstractSplitsCacheAsync.js +1 -1
- package/esm/storages/AbstractSplitsCacheSync.js +1 -1
- package/esm/storages/KeyBuilder.js +12 -12
- package/esm/storages/KeyBuilderCS.js +12 -12
- package/esm/storages/KeyBuilderSS.js +14 -14
- package/esm/storages/getRolloutPlan.js +1 -1
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +1 -1
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +2 -2
- package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/RBSegmentsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +7 -7
- package/esm/storages/inRedis/SplitsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +5 -5
- package/esm/storages/pluggable/RBSegmentsCachePluggable.js +1 -1
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/storages/pluggable/wrapperAdapter.js +1 -1
- package/esm/storages/setRolloutPlan.js +1 -1
- package/esm/storages/utils.js +6 -6
- package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +24 -15
- package/esm/sync/polling/pollingManagerCS.js +11 -11
- package/esm/sync/polling/pollingManagerSS.js +13 -13
- package/esm/sync/polling/syncTasks/definitionsSyncTask.js +8 -0
- package/esm/sync/polling/updaters/{splitChangesUpdater.js → definitionChangesUpdater.js} +67 -59
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +7 -7
- package/esm/sync/streaming/SSEClient/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/esm/sync/streaming/parseUtils.js +10 -10
- package/esm/sync/streaming/pushManager.js +3 -3
- package/esm/sync/submitters/impressionsSubmitter.js +6 -6
- package/esm/sync/submitters/submitter.js +1 -1
- package/esm/sync/syncManagerOnline.js +5 -2
- package/esm/trackers/eventTracker.js +10 -12
- package/esm/trackers/impressionObserver/buildKey.js +1 -1
- package/esm/trackers/impressionsTracker.js +38 -21
- package/esm/trackers/uniqueKeysTracker.js +1 -1
- package/esm/utils/EventEmitter.js +387 -0
- package/esm/utils/filter/bloomFilter.js +33 -0
- package/esm/utils/inputValidation/apiKey.js +1 -1
- package/esm/utils/inputValidation/attribute.js +2 -2
- 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/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +4 -4
- package/esm/utils/settingsValidation/url.js +5 -5
- package/package.json +15 -6
- package/src/dtos/types.ts +65 -70
- package/src/evaluator/Engine.ts +4 -4
- package/src/evaluator/combiners/and.ts +3 -3
- package/src/evaluator/combiners/ifelseif.ts +2 -2
- package/src/evaluator/condition/engineUtils.ts +2 -2
- package/src/evaluator/condition/index.ts +3 -3
- package/src/evaluator/fallbackConfigsCalculator/fallbackSanitizer/index.ts +76 -0
- package/src/evaluator/fallbackConfigsCalculator/index.ts +24 -0
- package/src/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.ts +5 -7
- package/src/evaluator/fallbackTreatmentsCalculator/index.ts +27 -41
- package/src/evaluator/index.ts +80 -45
- package/src/evaluator/matchers/dependency.ts +2 -2
- package/src/evaluator/matchers/matcherTypes.ts +2 -2
- package/src/evaluator/matchers/prerequisites.ts +4 -4
- package/src/evaluator/matchers/rbsegment.ts +2 -2
- package/src/evaluator/matchers/whitelist.ts +2 -2
- package/src/evaluator/matchersTransform/index.ts +2 -2
- package/src/evaluator/matchersTransform/whitelist.ts +2 -2
- package/src/evaluator/parser/index.ts +4 -4
- package/src/evaluator/treatments/index.ts +2 -2
- package/src/evaluator/types.ts +6 -6
- package/src/evaluator/value/index.ts +1 -1
- package/src/integrations/pluggable.ts +1 -1
- package/src/listeners/browser.ts +11 -8
- package/src/listeners/node.ts +2 -5
- package/src/logger/constants.ts +11 -17
- package/src/logger/messages/debug.ts +5 -6
- package/src/logger/messages/error.ts +3 -3
- package/src/logger/messages/info.ts +1 -3
- package/src/logger/messages/warn.ts +8 -8
- package/src/platform/browser.ts +14 -0
- package/src/platform/getEventSource/browser.ts +4 -0
- package/src/platform/getEventSource/eventsource.js +519 -0
- package/src/platform/getEventSource/node.ts +23 -0
- package/src/platform/getFetch/browser.ts +5 -0
- package/src/platform/getFetch/node.ts +27 -0
- package/src/platform/getOptions/node.ts +24 -0
- package/src/platform/node.ts +16 -0
- package/src/readiness/constants.ts +1 -0
- package/src/sdkClient/client.ts +11 -41
- package/src/sdkClient/clientInputValidation.ts +44 -84
- package/src/sdkClient/sdkClient.ts +5 -54
- package/src/sdkClient/sdkLifecycle.ts +78 -0
- package/src/sdkClient/trackMethod.ts +59 -0
- package/src/sdkFactory/index.ts +10 -54
- package/src/sdkFactory/types.ts +19 -16
- package/src/sdkManager/index.ts +9 -9
- package/src/services/splitApi.ts +6 -0
- package/src/services/types.ts +3 -2
- package/src/storages/AbstractSplitsCacheAsync.ts +7 -7
- package/src/storages/AbstractSplitsCacheSync.ts +10 -10
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +2 -2
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +6 -6
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/SplitsCacheInMemory.ts +5 -5
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +2 -2
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/SplitsCacheInRedis.ts +9 -9
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +2 -2
- package/src/storages/pluggable/SplitsCachePluggable.ts +9 -9
- package/src/storages/types.ts +21 -16
- package/src/sync/offline/splitsParser/parseCondition.ts +2 -2
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +3 -3
- package/src/sync/offline/splitsParser/types.ts +6 -3
- package/src/sync/offline/syncManagerOffline.ts +2 -2
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +6 -6
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +57 -22
- package/src/sync/polling/fetchers/types.ts +5 -3
- package/src/sync/polling/pollingManagerCS.ts +12 -10
- package/src/sync/polling/pollingManagerSS.ts +15 -13
- package/src/sync/polling/syncTasks/{splitsSyncTask.ts → definitionsSyncTask.ts} +10 -11
- package/src/sync/polling/types.ts +3 -3
- package/src/sync/polling/updaters/{splitChangesUpdater.ts → definitionChangesUpdater.ts} +77 -68
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +7 -7
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +6 -6
- package/src/sync/streaming/parseUtils.ts +12 -12
- package/src/sync/streaming/pushManager.ts +3 -3
- package/src/sync/submitters/impressionsSubmitter.ts +9 -9
- package/src/sync/submitters/types.ts +3 -0
- package/src/sync/syncManagerOnline.ts +6 -2
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +42 -26
- package/src/trackers/types.ts +3 -1
- package/src/utils/EventEmitter.js +444 -0
- package/src/utils/filter/bloomFilter.ts +38 -0
- package/src/utils/inputValidation/definition.ts +27 -0
- package/src/utils/inputValidation/definitionExistence.ts +19 -0
- package/src/utils/inputValidation/definitions.ts +21 -0
- package/src/utils/inputValidation/index.ts +3 -3
- package/src/utils/inputValidation/isOperational.ts +4 -4
- package/src/utils/inputValidation/target.ts +21 -0
- package/src/utils/labels/index.ts +2 -2
- package/src/utils/settingsValidation/splitFilters.ts +3 -3
- package/types/splitio.d.ts +202 -9
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +0 -13
- package/cjs/utils/inputValidation/splits.js +0 -25
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +0 -9
- package/esm/utils/inputValidation/splitExistence.js +0 -15
- package/esm/utils/inputValidation/splits.js +0 -21
- package/src/utils/inputValidation/split.ts +0 -27
- package/src/utils/inputValidation/splitExistence.ts +0 -19
- package/src/utils/inputValidation/splits.ts +0 -21
package/CHANGES.txt
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
-
|
|
1
|
+
3.0.0 (May XX, 2026)
|
|
2
|
+
- Extracted SDK lifecycle methods (`init`, `flush`, and `destroy`) into a reusable `sdkLifecycle` module.
|
|
3
|
+
- Extracted the `track` method into a standalone `trackMethod` factory for reuse across SDKs.
|
|
4
|
+
- Added a bloom filter utility and platform-specific modules (`src/platform/`) for reuse across SDKs.
|
|
5
|
+
- Added support for the Configs SDK:
|
|
6
|
+
- new type declarations,
|
|
7
|
+
- a fallback calculator with sanitizer,
|
|
8
|
+
- default treatment evaluation (without a target),
|
|
9
|
+
- a new `CONFIGS_UPDATE` metadata type for `SDK_UPDATE` event,
|
|
10
|
+
- an optional `entityType` field in the `/testImpressions/bulk` payload,
|
|
11
|
+
- input validation for the target object.
|
|
12
|
+
- BREAKING CHANGES: Renamed some types and modules, and updated the signatures of others for clarity and reusability.
|
|
13
|
+
|
|
14
|
+
2.12.0 (February 24, 2026)
|
|
15
|
+
- Added support for ioredis v5 (Related to issue https://github.com/splitio/javascript-commons/issues/471).
|
|
3
16
|
|
|
4
17
|
2.11.0 (January 28, 2026)
|
|
5
18
|
- Added functionality to provide metadata alongside SDK update and READY events. Read more in our docs.
|
|
@@ -16,10 +16,10 @@ exports.getTreatment = getTreatment;
|
|
|
16
16
|
/**
|
|
17
17
|
* Evaluates the traffic allocation to see if we should apply rollout conditions or not.
|
|
18
18
|
*/
|
|
19
|
-
function shouldApplyRollout(trafficAllocation,
|
|
19
|
+
function shouldApplyRollout(trafficAllocation, bucketingKey, trafficAllocationSeed) {
|
|
20
20
|
// For rollout, if traffic allocation for splits is 100%, we don't need to filter it because everything should evaluate the rollout.
|
|
21
21
|
if (trafficAllocation < 100) {
|
|
22
|
-
var _bucket = (0, murmur3_1.bucket)(
|
|
22
|
+
var _bucket = (0, murmur3_1.bucket)(bucketingKey, trafficAllocationSeed);
|
|
23
23
|
if (_bucket > trafficAllocation) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeFallbacks = exports.isValidConfig = exports.isValidConfigName = void 0;
|
|
4
|
+
var lang_1 = require("../../../utils/lang");
|
|
5
|
+
var CONFIG_NAME_DISCARD_REASON = 'Invalid config name (max 100 chars, no spaces)';
|
|
6
|
+
var VARIANT_DISCARD_REASON = 'Invalid variant (max 100 chars and must match pattern)';
|
|
7
|
+
var VALUE_DISCARD_REASON = 'Invalid value (must be an object)';
|
|
8
|
+
var VARIANT_PATTERN = /^[0-9]+[.a-zA-Z0-9_-]*$|^[a-zA-Z]+[a-zA-Z0-9_-]*$/;
|
|
9
|
+
function isValidConfigName(name) {
|
|
10
|
+
return name.length <= 100 && !name.includes(' ');
|
|
11
|
+
}
|
|
12
|
+
exports.isValidConfigName = isValidConfigName;
|
|
13
|
+
function isValidConfig(config) {
|
|
14
|
+
if (!(0, lang_1.isObject)(config))
|
|
15
|
+
return false;
|
|
16
|
+
if (!(0, lang_1.isString)(config.variant) || config.variant.length > 100 || !VARIANT_PATTERN.test(config.variant))
|
|
17
|
+
return false;
|
|
18
|
+
if (!(0, lang_1.isObject)(config.value))
|
|
19
|
+
return false;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
exports.isValidConfig = isValidConfig;
|
|
23
|
+
function sanitizeGlobal(logger, config) {
|
|
24
|
+
if (config === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (!isValidConfig(config)) {
|
|
27
|
+
if (!(0, lang_1.isObject)(config) || !(0, lang_1.isString)(config.variant) || config.variant.length > 100 || !VARIANT_PATTERN.test(config.variant)) {
|
|
28
|
+
logger.error("Fallback configs - Discarded fallback: ".concat(VARIANT_DISCARD_REASON));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
logger.error("Fallback configs - Discarded fallback: ".concat(VALUE_DISCARD_REASON));
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return config;
|
|
36
|
+
}
|
|
37
|
+
function sanitizeByName(logger, byNameFallbacks) {
|
|
38
|
+
var sanitizedByName = {};
|
|
39
|
+
if (!(0, lang_1.isObject)(byNameFallbacks))
|
|
40
|
+
return sanitizedByName;
|
|
41
|
+
Object.keys(byNameFallbacks).forEach(function (configName) {
|
|
42
|
+
var config = byNameFallbacks[configName];
|
|
43
|
+
if (!isValidConfigName(configName)) {
|
|
44
|
+
logger.error("Fallback configs - Discarded config '".concat(configName, "': ").concat(CONFIG_NAME_DISCARD_REASON));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!isValidConfig(config)) {
|
|
48
|
+
if (!(0, lang_1.isObject)(config) || !(0, lang_1.isString)(config.variant) || config.variant.length > 100 || !VARIANT_PATTERN.test(config.variant)) {
|
|
49
|
+
logger.error("Fallback configs - Discarded config '".concat(configName, "': ").concat(VARIANT_DISCARD_REASON));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
logger.error("Fallback configs - Discarded config '".concat(configName, "': ").concat(VALUE_DISCARD_REASON));
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
sanitizedByName[configName] = config;
|
|
57
|
+
});
|
|
58
|
+
return sanitizedByName;
|
|
59
|
+
}
|
|
60
|
+
function sanitizeFallbacks(logger, fallbacks) {
|
|
61
|
+
if (!(0, lang_1.isObject)(fallbacks)) {
|
|
62
|
+
logger.error('Fallback configs - Discarded configuration: it must be an object with optional `global` and `byName` properties');
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
global: sanitizeGlobal(logger, fallbacks.global),
|
|
67
|
+
byName: sanitizeByName(logger, fallbacks.byName)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
exports.sanitizeFallbacks = sanitizeFallbacks;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FallbackConfigsCalculator = exports.FALLBACK_PREFIX = void 0;
|
|
4
|
+
var constants_1 = require("../../utils/constants");
|
|
5
|
+
exports.FALLBACK_PREFIX = 'fallback - ';
|
|
6
|
+
function FallbackConfigsCalculator(fallbacks) {
|
|
7
|
+
if (fallbacks === void 0) { fallbacks = {}; }
|
|
8
|
+
return function (configName, label) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (label === void 0) { label = ''; }
|
|
11
|
+
var fallback = ((_a = fallbacks.byName) === null || _a === void 0 ? void 0 : _a[configName]) || fallbacks.global;
|
|
12
|
+
return fallback ?
|
|
13
|
+
{
|
|
14
|
+
treatment: fallback.variant,
|
|
15
|
+
config: fallback.value,
|
|
16
|
+
label: "".concat(exports.FALLBACK_PREFIX).concat(label),
|
|
17
|
+
} :
|
|
18
|
+
{
|
|
19
|
+
treatment: constants_1.CONTROL,
|
|
20
|
+
config: null,
|
|
21
|
+
label: label,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.FallbackConfigsCalculator = FallbackConfigsCalculator;
|
|
@@ -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: "
|
|
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 '"
|
|
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 '"
|
|
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;
|
|
@@ -4,40 +4,29 @@ exports.FallbackTreatmentsCalculator = exports.FALLBACK_PREFIX = void 0;
|
|
|
4
4
|
var constants_1 = require("../../utils/constants");
|
|
5
5
|
var lang_1 = require("../../utils/lang");
|
|
6
6
|
exports.FALLBACK_PREFIX = 'fallback - ';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.fallbacks = fallbacks;
|
|
11
|
-
}
|
|
12
|
-
FallbackTreatmentsCalculator.prototype.resolve = function (flagName, label) {
|
|
7
|
+
function FallbackTreatmentsCalculator(fallbacks) {
|
|
8
|
+
if (fallbacks === void 0) { fallbacks = {}; }
|
|
9
|
+
return function (flagName, label) {
|
|
13
10
|
var _a;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
treatment: fallback,
|
|
11
|
+
if (label === void 0) { label = ''; }
|
|
12
|
+
var fallback = ((_a = fallbacks.byFlag) === null || _a === void 0 ? void 0 : _a[flagName]) || fallbacks.global;
|
|
13
|
+
return fallback ?
|
|
14
|
+
(0, lang_1.isString)(fallback) ?
|
|
15
|
+
{
|
|
16
|
+
treatment: fallback,
|
|
17
|
+
config: null,
|
|
18
|
+
label: "".concat(exports.FALLBACK_PREFIX).concat(label),
|
|
19
|
+
} :
|
|
20
|
+
{
|
|
21
|
+
treatment: fallback.treatment,
|
|
22
|
+
config: fallback.config,
|
|
23
|
+
label: "".concat(exports.FALLBACK_PREFIX).concat(label),
|
|
24
|
+
} :
|
|
25
|
+
{
|
|
26
|
+
treatment: constants_1.CONTROL,
|
|
31
27
|
config: null,
|
|
32
|
-
label:
|
|
28
|
+
label: label,
|
|
33
29
|
};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
treatment: fallback.treatment,
|
|
37
|
-
config: fallback.config,
|
|
38
|
-
label: "" + exports.FALLBACK_PREFIX + label,
|
|
39
|
-
};
|
|
40
30
|
};
|
|
41
|
-
|
|
42
|
-
}());
|
|
31
|
+
}
|
|
43
32
|
exports.FallbackTreatmentsCalculator = FallbackTreatmentsCalculator;
|
package/cjs/evaluator/index.js
CHANGED
|
@@ -1,59 +1,64 @@
|
|
|
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 EVALUATION_EXCEPTION = {
|
|
11
11
|
treatment: constants_1.CONTROL,
|
|
12
12
|
label: labels_1.EXCEPTION,
|
|
13
13
|
config: null
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
var EVALUATION_DEFINITION_NOT_FOUND = {
|
|
16
|
+
treatment: constants_1.CONTROL,
|
|
17
|
+
label: labels_1.DEFINITION_NOT_FOUND,
|
|
18
|
+
config: null
|
|
19
|
+
};
|
|
20
|
+
function treatmentsException(definitionNames) {
|
|
16
21
|
var evaluations = {};
|
|
17
|
-
|
|
18
|
-
evaluations[
|
|
22
|
+
definitionNames.forEach(function (definitionName) {
|
|
23
|
+
evaluations[definitionName] = EVALUATION_EXCEPTION;
|
|
19
24
|
});
|
|
20
25
|
return evaluations;
|
|
21
26
|
}
|
|
22
|
-
function evaluateFeature(log, key,
|
|
23
|
-
var
|
|
27
|
+
function evaluateFeature(log, key, definitionName, attributes, storage, options) {
|
|
28
|
+
var definition;
|
|
24
29
|
try {
|
|
25
|
-
|
|
30
|
+
definition = storage.splits.getSplit(definitionName);
|
|
26
31
|
}
|
|
27
32
|
catch (e) {
|
|
28
33
|
// Exception on sync `getSplit` storage. Not possible ATM with InMemory and InLocal storages.
|
|
29
|
-
return
|
|
34
|
+
return EVALUATION_EXCEPTION;
|
|
30
35
|
}
|
|
31
|
-
if ((0, thenable_1.thenable)(
|
|
32
|
-
return
|
|
36
|
+
if ((0, thenable_1.thenable)(definition)) {
|
|
37
|
+
return definition.then(function (definition) { return getEvaluation(log, key, definition, attributes, storage, options); }).catch(
|
|
33
38
|
// Exception on async `getSplit` storage. For example, when the storage is redis or
|
|
34
39
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
35
|
-
function () { return
|
|
40
|
+
function () { return EVALUATION_EXCEPTION; });
|
|
36
41
|
}
|
|
37
|
-
return getEvaluation(log, key,
|
|
42
|
+
return getEvaluation(log, key, definition, attributes, storage, options);
|
|
38
43
|
}
|
|
39
44
|
exports.evaluateFeature = evaluateFeature;
|
|
40
|
-
function evaluateFeatures(log, key,
|
|
41
|
-
var
|
|
45
|
+
function evaluateFeatures(log, key, definitionNames, attributes, storage, options) {
|
|
46
|
+
var definitions;
|
|
42
47
|
try {
|
|
43
|
-
|
|
48
|
+
definitions = storage.splits.getSplits(definitionNames);
|
|
44
49
|
}
|
|
45
50
|
catch (e) {
|
|
46
51
|
// Exception on sync `getSplits` storage. Not possible ATM with InMemory and InLocal storages.
|
|
47
|
-
return treatmentsException(
|
|
52
|
+
return treatmentsException(definitionNames);
|
|
48
53
|
}
|
|
49
|
-
return (0, thenable_1.thenable)(
|
|
50
|
-
|
|
54
|
+
return (0, thenable_1.thenable)(definitions) ?
|
|
55
|
+
definitions.then(function (definitions) { return getEvaluations(log, key, definitionNames, definitions, attributes, storage, options); })
|
|
51
56
|
.catch(function () {
|
|
52
57
|
// Exception on async `getSplits` storage. For example, when the storage is redis or
|
|
53
58
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
54
|
-
return treatmentsException(
|
|
59
|
+
return treatmentsException(definitionNames);
|
|
55
60
|
}) :
|
|
56
|
-
getEvaluations(log, key,
|
|
61
|
+
getEvaluations(log, key, definitionNames, definitions, attributes, storage, options);
|
|
57
62
|
}
|
|
58
63
|
exports.evaluateFeatures = evaluateFeatures;
|
|
59
64
|
function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method, options) {
|
|
@@ -90,47 +95,67 @@ function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, met
|
|
|
90
95
|
evaluate(storedFlagNames);
|
|
91
96
|
}
|
|
92
97
|
exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
|
|
93
|
-
function getEvaluation(log, key,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
config: null
|
|
98
|
-
};
|
|
99
|
-
if (splitJSON) {
|
|
100
|
-
var split = (0, Engine_1.engineParser)(log, splitJSON, storage);
|
|
101
|
-
evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
98
|
+
function getEvaluation(log, key, definition, attributes, storage, options) {
|
|
99
|
+
if (definition) {
|
|
100
|
+
var split = (0, Engine_1.engineParser)(log, definition, storage);
|
|
101
|
+
var evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
102
102
|
// If the storage is async and the evaluated flag uses segments or dependencies, evaluation is thenable
|
|
103
103
|
if ((0, thenable_1.thenable)(evaluation)) {
|
|
104
104
|
return evaluation.then(function (result) {
|
|
105
|
-
result.changeNumber =
|
|
106
|
-
result.config =
|
|
105
|
+
result.changeNumber = definition.changeNumber;
|
|
106
|
+
result.config = definition.configurations && definition.configurations[result.treatment] || null;
|
|
107
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) ||
|
|
108
|
+
result.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || definition.impressionsDisabled;
|
|
109
109
|
return result;
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
evaluation.changeNumber =
|
|
114
|
-
evaluation.config =
|
|
113
|
+
evaluation.changeNumber = definition.changeNumber;
|
|
114
|
+
evaluation.config = definition.configurations && definition.configurations[evaluation.treatment] || null;
|
|
115
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) ||
|
|
116
|
+
evaluation.impressionsDisabled = (options === null || options === void 0 ? void 0 : options.impressionsDisabled) || definition.impressionsDisabled;
|
|
117
117
|
}
|
|
118
|
+
return evaluation;
|
|
118
119
|
}
|
|
119
|
-
return
|
|
120
|
+
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
120
121
|
}
|
|
121
|
-
function getEvaluations(log, key,
|
|
122
|
+
function getEvaluations(log, key, definitionNames, splits, attributes, storage, options) {
|
|
122
123
|
var result = {};
|
|
123
124
|
var thenables = [];
|
|
124
|
-
|
|
125
|
-
var evaluation = getEvaluation(log, key, splits[
|
|
125
|
+
definitionNames.forEach(function (definitionName) {
|
|
126
|
+
var evaluation = getEvaluation(log, key, splits[definitionName], attributes, storage, options);
|
|
126
127
|
if ((0, thenable_1.thenable)(evaluation)) {
|
|
127
128
|
thenables.push(evaluation.then(function (res) {
|
|
128
|
-
result[
|
|
129
|
+
result[definitionName] = res;
|
|
129
130
|
}));
|
|
130
131
|
}
|
|
131
132
|
else {
|
|
132
|
-
result[
|
|
133
|
+
result[definitionName] = evaluation;
|
|
133
134
|
}
|
|
134
135
|
});
|
|
135
136
|
return thenables.length > 0 ? Promise.all(thenables).then(function () { return result; }) : result;
|
|
136
137
|
}
|
|
138
|
+
function evaluateDefaultTreatment(definitionName, storage) {
|
|
139
|
+
var definition;
|
|
140
|
+
try {
|
|
141
|
+
definition = storage.splits.getSplit(definitionName);
|
|
142
|
+
}
|
|
143
|
+
catch (e) {
|
|
144
|
+
return EVALUATION_EXCEPTION;
|
|
145
|
+
}
|
|
146
|
+
return (0, thenable_1.thenable)(definition) ?
|
|
147
|
+
definition.then(getDefaultTreatment).catch(function () { return EVALUATION_EXCEPTION; }) :
|
|
148
|
+
getDefaultTreatment(definition);
|
|
149
|
+
}
|
|
150
|
+
exports.evaluateDefaultTreatment = evaluateDefaultTreatment;
|
|
151
|
+
function getDefaultTreatment(definition) {
|
|
152
|
+
if (definition) {
|
|
153
|
+
return {
|
|
154
|
+
treatment: definition.defaultTreatment,
|
|
155
|
+
label: labels_1.NO_CONDITION_MATCH,
|
|
156
|
+
config: definition.configurations && definition.configurations[definition.defaultTreatment] || null,
|
|
157
|
+
changeNumber: definition.changeNumber
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return EVALUATION_DEFINITION_NOT_FOUND;
|
|
161
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.whitelistMatcherContext = void 0;
|
|
4
4
|
function whitelistMatcherContext(ruleAttr) {
|
|
5
|
-
var whitelistSet = new Set(ruleAttr);
|
|
5
|
+
var whitelistSet = new Set(ruleAttr || []);
|
|
6
6
|
return function whitelistMatcher(runtimeAttr) {
|
|
7
7
|
var isInWhitelist = whitelistSet.has(runtimeAttr);
|
|
8
8
|
return isInWhitelist;
|
|
@@ -16,7 +16,7 @@ function pluggableIntegrationsManagerFactory(integrations, params) {
|
|
|
16
16
|
// No need to check if `settings.integrations` is an array of functions. It was already validated
|
|
17
17
|
integrations.forEach(function (integrationFactory) {
|
|
18
18
|
var integration = integrationFactory(params);
|
|
19
|
-
if (integration
|
|
19
|
+
if (integration)
|
|
20
20
|
listeners.push(integration);
|
|
21
21
|
});
|
|
22
22
|
// If `listeners` is empty, not return a integration manager
|
package/cjs/listeners/browser.js
CHANGED
|
@@ -13,14 +13,15 @@ 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, splitApi = _a.splitApi, entityType = _a.entityType;
|
|
17
18
|
this.syncManager = syncManager;
|
|
18
19
|
this.settings = settings;
|
|
19
20
|
this.storage = storage;
|
|
20
|
-
this.serviceApi =
|
|
21
|
+
this.serviceApi = splitApi;
|
|
21
22
|
this.flushData = this.flushData.bind(this);
|
|
22
23
|
this.flushDataIfHidden = this.flushDataIfHidden.bind(this);
|
|
23
|
-
this.fromImpressionsCollector = impressionsSubmitter_1.fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled);
|
|
24
|
+
this.fromImpressionsCollector = impressionsSubmitter_1.fromImpressionsCollector.bind(undefined, settings.core.labelsEnabled, entityType);
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* start method.
|
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(constants_1.LOG_PREFIX_CLEANUP
|
|
50
|
+
this.settings.log.debug("".concat(constants_1.LOG_PREFIX_CLEANUP, "Split 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(constants_1.LOG_PREFIX_CLEANUP
|
|
56
|
+
this.settings.log.error("".concat(constants_1.LOG_PREFIX_CLEANUP, "Error with Split 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.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_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_NO_LISTENER = 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_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 = exports.CLIENT_NOT_READY_FROM_CACHE = 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 = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* Message codes used to trim string log messages from commons and client-side API modules,
|
|
8
8
|
* in order to reduce the minimal SDK size for Browser and eventually other client-side environments.
|
|
@@ -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;
|
|
@@ -36,14 +35,12 @@ exports.ENGINE_MATCHER_RESULT = 40;
|
|
|
36
35
|
exports.ENGINE_DEFAULT = 41;
|
|
37
36
|
exports.CLIENT_READY_FROM_CACHE = 100;
|
|
38
37
|
exports.CLIENT_READY = 101;
|
|
39
|
-
exports.IMPRESSION = 102;
|
|
40
38
|
exports.IMPRESSION_QUEUEING = 103;
|
|
41
39
|
exports.NEW_SHARED_CLIENT = 104;
|
|
42
40
|
exports.NEW_FACTORY = 105;
|
|
43
41
|
exports.POLLING_SMART_PAUSING = 106;
|
|
44
42
|
exports.POLLING_START = 107;
|
|
45
43
|
exports.POLLING_STOP = 108;
|
|
46
|
-
exports.SYNC_SPLITS_FETCH_RETRY = 109;
|
|
47
44
|
exports.STREAMING_REFRESH_TOKEN = 110;
|
|
48
45
|
exports.STREAMING_RECONNECT = 111;
|
|
49
46
|
exports.STREAMING_CONNECTING = 112;
|
|
@@ -64,8 +61,8 @@ exports.ENGINE_VALUE_INVALID = 200;
|
|
|
64
61
|
exports.ENGINE_VALUE_NO_ATTRIBUTES = 201;
|
|
65
62
|
exports.CLIENT_NO_LISTENER = 202;
|
|
66
63
|
exports.CLIENT_NOT_READY_FROM_CACHE = 203;
|
|
67
|
-
exports.
|
|
68
|
-
exports.
|
|
64
|
+
exports.SYNC_FETCH_RETRY = 204;
|
|
65
|
+
exports.SYNC_FETCH_FAILS = 205;
|
|
69
66
|
exports.STREAMING_PARSING_ERROR_FAILS = 206;
|
|
70
67
|
exports.STREAMING_PARSING_MESSAGE_FAILS = 207;
|
|
71
68
|
exports.STREAMING_FALLBACK = 208;
|
|
@@ -75,7 +72,7 @@ exports.WARN_SETTING_NULL = 211;
|
|
|
75
72
|
exports.WARN_TRIMMING_PROPERTIES = 212;
|
|
76
73
|
exports.WARN_CONVERTING = 213;
|
|
77
74
|
exports.WARN_TRIMMING = 214;
|
|
78
|
-
exports.
|
|
75
|
+
exports.WARN_NOT_EXISTENT_DEFINITION = 215;
|
|
79
76
|
exports.WARN_LOWERCASE_TRAFFIC_TYPE = 216;
|
|
80
77
|
exports.WARN_NOT_EXISTENT_TT = 217;
|
|
81
78
|
exports.WARN_INTEGRATION_INVALID = 218;
|
|
@@ -126,15 +123,12 @@ exports.LOG_PREFIX_ENGINE = 'engine';
|
|
|
126
123
|
exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE + ':combiner: ';
|
|
127
124
|
exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE + ':matcher: ';
|
|
128
125
|
exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE + ':value: ';
|
|
129
|
-
exports.LOG_PREFIX_SYNC = 'sync';
|
|
130
|
-
exports.LOG_PREFIX_SYNC_MANAGER =
|
|
131
|
-
exports.LOG_PREFIX_SYNC_OFFLINE =
|
|
132
|
-
exports.LOG_PREFIX_SYNC_STREAMING =
|
|
133
|
-
exports.
|
|
134
|
-
exports.
|
|
135
|
-
exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC + ':my-segments: ';
|
|
136
|
-
exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC + ':polling-manager: ';
|
|
137
|
-
exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC + ':submitter: ';
|
|
126
|
+
exports.LOG_PREFIX_SYNC = 'sync: ';
|
|
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: ';
|
|
138
132
|
exports.LOG_PREFIX_IMPRESSIONS_TRACKER = 'impressions-tracker: ';
|
|
139
133
|
exports.LOG_PREFIX_EVENTS_TRACKER = 'events-tracker: ';
|
|
140
134
|
exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = 'unique-keys-tracker: ';
|
package/cjs/logger/index.js
CHANGED
|
@@ -91,7 +91,7 @@ var Logger = /** @class */ (function () {
|
|
|
91
91
|
Logger.prototype._log = function (method, msg, args) {
|
|
92
92
|
if (typeof msg === 'number') {
|
|
93
93
|
var format = this.codes.get(msg);
|
|
94
|
-
msg = format ? _sprintf(format, args) : "Message code "
|
|
94
|
+
msg = format ? _sprintf(format, args) : "Message code ".concat(msg).concat(args ? ', with args: ' + args.toString() : '');
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
97
|
if (args)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.codesDebug = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var c =
|
|
5
|
+
var c = tslib_1.__importStar(require("../constants"));
|
|
6
6
|
var info_1 = require("./info");
|
|
7
7
|
exports.codesDebug = info_1.codesInfo.concat([
|
|
8
8
|
// evaluator
|
|
@@ -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 + 'New %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
|
]);
|