@splitsoftware/splitio-commons 2.12.0 → 3.0.0-rc.1
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 +19 -1
- 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 +73 -48
- 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 +15 -21
- 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 -10
- 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 +5 -4
- package/cjs/readiness/readinessManager.js +22 -22
- package/cjs/readiness/sdkReadinessManager.js +0 -16
- 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 +71 -0
- package/cjs/sdkClient/trackMethod.js +56 -0
- package/cjs/sdkFactory/index.js +13 -50
- package/cjs/sdkManager/index.js +5 -5
- package/cjs/services/authProvider.js +67 -0
- package/cjs/services/secureSplitHttpClient.js +39 -0
- package/cjs/services/splitApi.js +24 -14
- package/cjs/services/splitHttpClient.js +1 -1
- package/cjs/storages/AbstractDefinitionsCacheAsync.js +51 -0
- package/cjs/storages/AbstractDefinitionsCacheSync.js +76 -0
- package/cjs/storages/KeyBuilder.js +16 -16
- package/cjs/storages/KeyBuilderCS.js +17 -17
- package/cjs/storages/KeyBuilderSS.js +16 -16
- package/cjs/storages/getRolloutPlan.js +4 -4
- package/cjs/storages/inLocalStorage/DefinitionsCacheInLocal.js +194 -0
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/RBSegmentsCacheInLocal.js +10 -10
- package/cjs/storages/inLocalStorage/index.js +6 -6
- package/cjs/storages/inLocalStorage/validateCache.js +3 -3
- package/cjs/storages/inMemory/DefinitionsCacheInMemory.js +121 -0
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +4 -4
- package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/RBSegmentsCacheInMemory.js +5 -5
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/DefinitionsCacheInRedis.js +243 -0
- 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/TelemetryCacheInRedis.js +7 -7
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/index.js +2 -2
- package/cjs/storages/pluggable/DefinitionsCachePluggable.js +212 -0
- 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/TelemetryCachePluggable.js +7 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
- package/cjs/storages/pluggable/index.js +5 -5
- package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
- package/cjs/storages/setRolloutPlan.js +6 -6
- package/cjs/storages/utils.js +6 -6
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +5 -5
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +24 -15
- package/cjs/sync/polling/pollingManagerCS.js +18 -18
- 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} +72 -64
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/streaming/SSEClient/index.js +2 -2
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +1 -1
- package/cjs/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +18 -18
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/constants.js +3 -3
- package/cjs/sync/streaming/parseUtils.js +12 -12
- package/cjs/sync/streaming/pushManager.js +14 -14
- package/cjs/sync/submitters/impressionsSubmitter.js +6 -6
- package/cjs/sync/submitters/submitter.js +1 -1
- package/cjs/sync/submitters/telemetrySubmitter.js +1 -2
- package/cjs/sync/syncManagerOnline.js +9 -6
- 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/Backoff.js +20 -0
- 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/lang/sets.js +4 -4
- package/cjs/utils/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +4 -4
- package/cjs/utils/settingsValidation/url.js +6 -6
- 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 +72 -48
- 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 +12 -18
- 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 -9
- 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 +4 -3
- package/esm/readiness/readinessManager.js +23 -23
- package/esm/readiness/sdkReadinessManager.js +1 -17
- 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 +67 -0
- package/esm/sdkClient/trackMethod.js +52 -0
- package/esm/sdkFactory/index.js +14 -51
- package/esm/sdkManager/index.js +6 -6
- package/esm/services/authProvider.js +63 -0
- package/esm/services/secureSplitHttpClient.js +35 -0
- package/esm/services/splitApi.js +24 -14
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/AbstractDefinitionsCacheAsync.js +48 -0
- package/esm/storages/AbstractDefinitionsCacheSync.js +71 -0
- package/esm/storages/KeyBuilder.js +16 -16
- package/esm/storages/KeyBuilderCS.js +16 -16
- package/esm/storages/KeyBuilderSS.js +15 -15
- package/esm/storages/getRolloutPlan.js +4 -4
- package/esm/storages/inLocalStorage/DefinitionsCacheInLocal.js +191 -0
- package/esm/storages/inLocalStorage/RBSegmentsCacheInLocal.js +7 -7
- package/esm/storages/inLocalStorage/index.js +6 -6
- package/esm/storages/inLocalStorage/validateCache.js +3 -3
- package/esm/storages/inMemory/DefinitionsCacheInMemory.js +118 -0
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/InMemoryStorage.js +4 -4
- package/esm/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/esm/storages/inMemory/RBSegmentsCacheInMemory.js +2 -2
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +5 -5
- package/esm/storages/inRedis/DefinitionsCacheInRedis.js +240 -0
- 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/TelemetryCacheInRedis.js +7 -7
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/inRedis/index.js +2 -2
- package/esm/storages/pluggable/DefinitionsCachePluggable.js +209 -0
- 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/TelemetryCachePluggable.js +7 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/index.js +4 -4
- package/esm/storages/pluggable/wrapperAdapter.js +1 -1
- package/esm/storages/setRolloutPlan.js +6 -6
- package/esm/storages/utils.js +6 -6
- package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +6 -6
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +25 -16
- package/esm/sync/polling/pollingManagerCS.js +15 -15
- package/esm/sync/polling/pollingManagerSS.js +13 -13
- package/esm/sync/polling/syncTasks/definitionsSyncTask.js +8 -0
- package/esm/sync/polling/updaters/definitionChangesUpdater.js +200 -0
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +7 -7
- package/esm/sync/streaming/SSEClient/index.js +2 -2
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +2 -2
- package/esm/sync/streaming/SSEHandler/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js} +17 -17
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/constants.js +2 -2
- package/esm/sync/streaming/parseUtils.js +10 -10
- package/esm/sync/streaming/pushManager.js +16 -16
- package/esm/sync/submitters/impressionsSubmitter.js +6 -6
- package/esm/sync/submitters/submitter.js +1 -1
- package/esm/sync/submitters/telemetrySubmitter.js +1 -2
- package/esm/sync/syncManagerOnline.js +8 -5
- 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/Backoff.js +20 -0
- 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/lang/sets.js +4 -4
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +4 -4
- package/esm/utils/settingsValidation/url.js +6 -6
- 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 +86 -51
- 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 +12 -18
- 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 -9
- 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 +4 -3
- package/src/readiness/readinessManager.ts +22 -22
- package/src/readiness/sdkReadinessManager.ts +1 -16
- package/src/readiness/types.ts +10 -16
- 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 +79 -0
- package/src/sdkClient/trackMethod.ts +59 -0
- package/src/sdkFactory/index.ts +15 -59
- package/src/sdkFactory/types.ts +19 -16
- package/src/sdkManager/index.ts +15 -15
- package/src/services/authProvider.ts +86 -0
- package/src/services/secureSplitHttpClient.ts +44 -0
- package/src/services/splitApi.ts +14 -2
- package/src/services/types.ts +7 -2
- package/src/storages/AbstractDefinitionsCacheAsync.ts +63 -0
- package/src/storages/AbstractDefinitionsCacheSync.ts +95 -0
- package/src/storages/KeyBuilder.ts +6 -6
- package/src/storages/KeyBuilderCS.ts +6 -6
- package/src/storages/KeyBuilderSS.ts +2 -2
- package/src/storages/getRolloutPlan.ts +3 -3
- package/src/storages/inLocalStorage/DefinitionsCacheInLocal.ts +234 -0
- package/src/storages/inLocalStorage/RBSegmentsCacheInLocal.ts +8 -8
- package/src/storages/inLocalStorage/index.ts +6 -6
- package/src/storages/inLocalStorage/validateCache.ts +4 -4
- package/src/storages/inMemory/DefinitionsCacheInMemory.ts +130 -0
- package/src/storages/inMemory/InMemoryStorage.ts +4 -4
- package/src/storages/inMemory/InMemoryStorageCS.ts +5 -5
- package/src/storages/inMemory/RBSegmentsCacheInMemory.ts +3 -3
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +1 -1
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +5 -5
- package/src/storages/inRedis/{SplitsCacheInRedis.ts → DefinitionsCacheInRedis.ts} +69 -69
- package/src/storages/inRedis/RBSegmentsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/index.ts +2 -2
- package/src/storages/pluggable/DefinitionsCachePluggable.ts +230 -0
- package/src/storages/pluggable/RBSegmentsCachePluggable.ts +2 -2
- package/src/storages/pluggable/index.ts +2 -2
- package/src/storages/setRolloutPlan.ts +7 -7
- package/src/storages/types.ts +34 -29
- 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 +14 -14
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +58 -23
- package/src/sync/polling/fetchers/types.ts +5 -3
- package/src/sync/polling/pollingManagerCS.ts +16 -14
- package/src/sync/polling/pollingManagerSS.ts +15 -13
- package/src/sync/polling/syncTasks/{splitsSyncTask.ts → definitionsSyncTask.ts} +11 -12
- package/src/sync/polling/types.ts +3 -3
- package/src/sync/polling/updaters/definitionChangesUpdater.ts +239 -0
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +3 -3
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +7 -7
- package/src/sync/streaming/AuthClient/index.ts +2 -2
- package/src/sync/streaming/AuthClient/types.ts +14 -11
- package/src/sync/streaming/SSEClient/index.ts +2 -2
- package/src/sync/streaming/SSEClient/types.ts +2 -2
- package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +2 -2
- package/src/sync/streaming/SSEHandler/index.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.ts → DefinitionsUpdateWorker.ts} +21 -21
- package/src/sync/streaming/constants.ts +2 -2
- package/src/sync/streaming/parseUtils.ts +12 -12
- package/src/sync/streaming/pushManager.ts +18 -18
- package/src/sync/streaming/types.ts +2 -2
- package/src/sync/submitters/impressionsSubmitter.ts +9 -9
- package/src/sync/submitters/telemetrySubmitter.ts +1 -2
- package/src/sync/submitters/types.ts +3 -0
- package/src/sync/syncManagerOnline.ts +9 -5
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +42 -26
- package/src/trackers/types.ts +3 -1
- package/src/utils/Backoff.ts +21 -0
- 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/inputValidation/trafficTypeExistence.ts +2 -2
- package/src/utils/jwt/types.ts +1 -1
- package/src/utils/labels/index.ts +2 -2
- package/src/utils/lang/sets.ts +4 -2
- package/src/utils/settingsValidation/splitFilters.ts +3 -3
- package/src/utils/settingsValidation/url.ts +1 -1
- package/types/splitio.d.ts +222 -11
- 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/inRedis/SplitsCacheInRedis.js +0 -243
- package/cjs/storages/pluggable/SplitsCachePluggable.js +0 -212
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +0 -13
- 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/inRedis/SplitsCacheInRedis.js +0 -240
- 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 -192
- package/esm/utils/inputValidation/splitExistence.js +0 -15
- package/esm/utils/inputValidation/splits.js +0 -21
- package/src/storages/AbstractSplitsCacheAsync.ts +0 -63
- package/src/storages/AbstractSplitsCacheSync.ts +0 -95
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +0 -234
- package/src/storages/inMemory/SplitsCacheInMemory.ts +0 -130
- package/src/storages/pluggable/SplitsCachePluggable.ts +0 -230
- package/src/sync/polling/updaters/splitChangesUpdater.ts +0 -230
- package/src/utils/inputValidation/split.ts +0 -27
- package/src/utils/inputValidation/splitExistence.ts +0 -19
- package/src/utils/inputValidation/splits.ts +0 -21
|
@@ -60,11 +60,11 @@ var SSEClient = /** @class */ (function () {
|
|
|
60
60
|
var params = CONTROL_CHANNEL_REGEX.test(channel) ? '[?occupancy=metrics.publishers]' : '';
|
|
61
61
|
return encodeURIComponent(params + channel);
|
|
62
62
|
}).join(',');
|
|
63
|
-
var url = this.settings.urls.streaming
|
|
63
|
+
var url = "".concat(this.settings.urls.streaming, "/sse?channels=").concat(channelsQueryParam, "&accessToken=").concat(authToken.token, "&v=").concat(ABLY_API_VERSION, "&heartbeats=true"); // same results using `&heartbeats=false`
|
|
64
64
|
var isServerSide = (0, key_1.checkIfServerSide)(this.settings);
|
|
65
65
|
this.connection = new this.eventSource(
|
|
66
66
|
// For client-side SDKs, metadata is passed as query param to avoid CORS issues and because native EventSource implementations in browsers do not support headers
|
|
67
|
-
isServerSide ? url : url +
|
|
67
|
+
isServerSide ? url : url + "&SplitSDKVersion=".concat(this.headers.SplitSDKVersion, "&SplitSDKClientKey=").concat(this.headers.SplitSDKClientKey),
|
|
68
68
|
// For server-side SDKs, metadata is passed via headers
|
|
69
69
|
(0, objectAssign_1.objectAssign)(isServerSide ?
|
|
70
70
|
{ headers: (0, decorateHeaders_1.decorateHeaders)(this.settings, this.headers) } :
|
|
@@ -73,7 +73,7 @@ function notificationKeeperFactory(pushEmitter, telemetryTracker) {
|
|
|
73
73
|
c.cTime = timestamp;
|
|
74
74
|
if (controlType === constants_2.ControlType.STREAMING_DISABLED) {
|
|
75
75
|
telemetryTracker.streamingEvent(constants_1.STREAMING_STATUS, constants_1.DISABLED);
|
|
76
|
-
pushEmitter.emit(constants_2.
|
|
76
|
+
pushEmitter.emit(constants_2.PUSH_NON_RETRYABLE_ERROR);
|
|
77
77
|
}
|
|
78
78
|
else if (hasPublishers) {
|
|
79
79
|
if (controlType === constants_2.ControlType.STREAMING_PAUSED && hasResumed) {
|
|
@@ -51,7 +51,7 @@ function SSEHandlerFactory(log, pushEmitter, telemetryTracker) {
|
|
|
51
51
|
pushEmitter.emit(constants_1.PUSH_RETRYABLE_ERROR);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
pushEmitter.emit(constants_1.
|
|
54
|
+
pushEmitter.emit(constants_1.PUSH_NON_RETRYABLE_ERROR);
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
/* NotificationProcessor */
|
package/cjs/sync/streaming/UpdateWorkers/{SplitsUpdateWorker.js → DefinitionsUpdateWorker.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DefinitionsUpdateWorker = void 0;
|
|
4
4
|
var constants_1 = require("../../../logger/constants");
|
|
5
5
|
var constants_2 = require("../../../readiness/constants");
|
|
6
6
|
var Backoff_1 = require("../../../utils/Backoff");
|
|
@@ -9,28 +9,28 @@ var constants_4 = require("../constants");
|
|
|
9
9
|
var parseUtils_1 = require("../parseUtils");
|
|
10
10
|
var constants_5 = require("./constants");
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* DefinitionsUpdateWorker factory
|
|
13
13
|
*/
|
|
14
|
-
function
|
|
15
|
-
var ff =
|
|
16
|
-
var rbs =
|
|
17
|
-
function
|
|
14
|
+
function DefinitionsUpdateWorker(log, storage, definitionsSyncTask, definitionsEventEmitter, telemetryTracker, segmentsSyncTask) {
|
|
15
|
+
var ff = DefinitionsUpdateWorker(storage.definitions);
|
|
16
|
+
var rbs = DefinitionsUpdateWorker(storage.rbSegments);
|
|
17
|
+
function DefinitionsUpdateWorker(cache) {
|
|
18
18
|
var maxChangeNumber = -1;
|
|
19
19
|
var handleNewEvent = false;
|
|
20
20
|
var isHandlingEvent;
|
|
21
21
|
var cdnBypass;
|
|
22
22
|
var instantUpdate;
|
|
23
|
-
var backoff = new Backoff_1.Backoff(
|
|
24
|
-
function
|
|
23
|
+
var backoff = new Backoff_1.Backoff(__handleDefinitionUpdateCall, constants_5.FETCH_BACKOFF_BASE, constants_5.FETCH_BACKOFF_MAX_WAIT);
|
|
24
|
+
function __handleDefinitionUpdateCall() {
|
|
25
25
|
isHandlingEvent = true;
|
|
26
26
|
if (maxChangeNumber > cache.getChangeNumber()) {
|
|
27
27
|
handleNewEvent = false;
|
|
28
28
|
// fetch splits revalidating data if cached
|
|
29
|
-
|
|
29
|
+
definitionsSyncTask.execute(true, cdnBypass ? maxChangeNumber : undefined, instantUpdate).then(function () {
|
|
30
30
|
if (!isHandlingEvent)
|
|
31
31
|
return; // halt if `stop` has been called
|
|
32
32
|
if (handleNewEvent) {
|
|
33
|
-
|
|
33
|
+
__handleDefinitionUpdateCall();
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
if (instantUpdate)
|
|
@@ -40,7 +40,7 @@ function SplitsUpdateWorker(log, storage, splitsSyncTask, splitsEventEmitter, te
|
|
|
40
40
|
segmentsSyncTask.execute(true);
|
|
41
41
|
var attempts = backoff.attempts + 1;
|
|
42
42
|
if (ff.isSync() && rbs.isSync()) {
|
|
43
|
-
log.debug("Refresh completed"
|
|
43
|
+
log.debug("Refresh completed".concat(cdnBypass ? ' bypassing the CDN' : '', " in ").concat(attempts, " attempts."));
|
|
44
44
|
isHandlingEvent = false;
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
@@ -49,13 +49,13 @@ function SplitsUpdateWorker(log, storage, splitsSyncTask, splitsEventEmitter, te
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
if (cdnBypass) {
|
|
52
|
-
log.debug("No changes fetched after "
|
|
52
|
+
log.debug("No changes fetched after ".concat(attempts, " attempts with CDN bypassed."));
|
|
53
53
|
isHandlingEvent = false;
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
56
|
backoff.reset();
|
|
57
57
|
cdnBypass = true;
|
|
58
|
-
|
|
58
|
+
__handleDefinitionUpdateCall();
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
});
|
|
@@ -83,7 +83,7 @@ function SplitsUpdateWorker(log, storage, splitsSyncTask, splitsEventEmitter, te
|
|
|
83
83
|
instantUpdate = { payload: payload, changeNumber: changeNumber, type: type };
|
|
84
84
|
}
|
|
85
85
|
if (backoff.timeoutID || !isHandlingEvent)
|
|
86
|
-
|
|
86
|
+
__handleDefinitionUpdateCall();
|
|
87
87
|
backoff.reset();
|
|
88
88
|
},
|
|
89
89
|
stop: function () {
|
|
@@ -118,11 +118,11 @@ function SplitsUpdateWorker(log, storage, splitsSyncTask, splitsEventEmitter, te
|
|
|
118
118
|
* @param splitName - name of split to kill
|
|
119
119
|
* @param defaultTreatment - default treatment value
|
|
120
120
|
*/
|
|
121
|
-
|
|
121
|
+
killDefinition: function (_a) {
|
|
122
122
|
var changeNumber = _a.changeNumber, splitName = _a.splitName, defaultTreatment = _a.defaultTreatment;
|
|
123
|
-
if (storage.
|
|
123
|
+
if (storage.definitions.killLocally(splitName, defaultTreatment, changeNumber)) {
|
|
124
124
|
// trigger an SDK_UPDATE if Split was killed locally
|
|
125
|
-
|
|
125
|
+
definitionsEventEmitter.emit(constants_2.SDK_DEFINITIONS_ARRIVED, true);
|
|
126
126
|
}
|
|
127
127
|
// queues the SplitChanges fetch (only if changeNumber is newer)
|
|
128
128
|
ff.put({ changeNumber: changeNumber });
|
|
@@ -133,4 +133,4 @@ function SplitsUpdateWorker(log, storage, splitsSyncTask, splitsEventEmitter, te
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
exports.
|
|
136
|
+
exports.DefinitionsUpdateWorker = DefinitionsUpdateWorker;
|
|
@@ -51,7 +51,7 @@ function MySegmentsUpdateWorker(log, storage, mySegmentsSyncTask, telemetryTrack
|
|
|
51
51
|
telemetryTracker.trackUpdatesFromSSE(constants_1.MEMBERSHIPS);
|
|
52
52
|
var attempts = backoff.attempts + 1;
|
|
53
53
|
if (maxChangeNumber <= currentChangeNumber) {
|
|
54
|
-
log.debug("Refresh completed"
|
|
54
|
+
log.debug("Refresh completed".concat(cdnBypass ? ' bypassing the CDN' : '', " in ").concat(attempts, " attempts."));
|
|
55
55
|
isHandlingEvent = false;
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
@@ -60,7 +60,7 @@ function MySegmentsUpdateWorker(log, storage, mySegmentsSyncTask, telemetryTrack
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
if (cdnBypass) {
|
|
63
|
-
log.debug("No changes fetched after "
|
|
63
|
+
log.debug("No changes fetched after ".concat(attempts, " attempts with CDN bypassed."));
|
|
64
64
|
isHandlingEvent = false;
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
@@ -28,7 +28,7 @@ function SegmentsUpdateWorker(log, segmentsSyncTask, segmentsCache) {
|
|
|
28
28
|
else {
|
|
29
29
|
var attempts = backoff.attempts + 1;
|
|
30
30
|
if (maxChangeNumber <= (segmentsCache.getChangeNumber(segment) || -1)) {
|
|
31
|
-
log.debug("Refresh completed"
|
|
31
|
+
log.debug("Refresh completed".concat(cdnBypass ? ' bypassing the CDN' : '', " in ").concat(attempts, " attempts."));
|
|
32
32
|
isHandlingEvent = false;
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -37,7 +37,7 @@ function SegmentsUpdateWorker(log, segmentsSyncTask, segmentsCache) {
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
if (cdnBypass) {
|
|
40
|
-
log.debug("No changes fetched after "
|
|
40
|
+
log.debug("No changes fetched after ".concat(attempts, " attempts with CDN bypassed."));
|
|
41
41
|
isHandlingEvent = false;
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ControlType = exports.OCCUPANCY = exports.CONTROL = exports.RB_SEGMENT_UPDATE = exports.SPLIT_UPDATE = exports.SPLIT_KILL = exports.SEGMENT_UPDATE = exports.MEMBERSHIPS_LS_UPDATE = exports.MEMBERSHIPS_MS_UPDATE = exports.PUSH_SUBSYSTEM_DOWN = exports.PUSH_SUBSYSTEM_UP = exports.PUSH_RETRYABLE_ERROR = exports.
|
|
3
|
+
exports.ControlType = exports.OCCUPANCY = exports.CONTROL = exports.RB_SEGMENT_UPDATE = exports.SPLIT_UPDATE = exports.SPLIT_KILL = exports.SEGMENT_UPDATE = exports.MEMBERSHIPS_LS_UPDATE = exports.MEMBERSHIPS_MS_UPDATE = exports.PUSH_SUBSYSTEM_DOWN = exports.PUSH_SUBSYSTEM_UP = exports.PUSH_RETRYABLE_ERROR = exports.PUSH_NON_RETRYABLE_ERROR = exports.SECONDS_BEFORE_EXPIRATION = void 0;
|
|
4
4
|
// time for refresh token
|
|
5
5
|
exports.SECONDS_BEFORE_EXPIRATION = 600;
|
|
6
6
|
// Internal SDK events, subscribed by SyncManager and PushManager
|
|
@@ -8,7 +8,7 @@ exports.SECONDS_BEFORE_EXPIRATION = 600;
|
|
|
8
8
|
* emitted on SSE and Authenticate non-recoverable errors, STREAMING_DISABLED control notification and authentication with pushEnabled false
|
|
9
9
|
* triggers `handleNonRetryableError` call
|
|
10
10
|
*/
|
|
11
|
-
exports.
|
|
11
|
+
exports.PUSH_NON_RETRYABLE_ERROR = 'PUSH_NON_RETRYABLE_ERROR';
|
|
12
12
|
/**
|
|
13
13
|
* emitted on SSE and Authenticate recoverable errors
|
|
14
14
|
* triggers `handleRetryableError` call
|
|
@@ -20,7 +20,7 @@ exports.PUSH_RETRYABLE_ERROR = 'PUSH_RETRYABLE_ERROR';
|
|
|
20
20
|
*/
|
|
21
21
|
exports.PUSH_SUBSYSTEM_UP = 'PUSH_SUBSYSTEM_UP';
|
|
22
22
|
/**
|
|
23
|
-
* emitted on STREAMING_PAUSED control notification, OCCUPANCY equal to 0,
|
|
23
|
+
* emitted on STREAMING_PAUSED control notification, OCCUPANCY equal to 0, PUSH_NON_RETRYABLE_ERROR and PUSH_RETRYABLE_ERROR events.
|
|
24
24
|
* triggers `startPolling` and `stopWorkers` calls
|
|
25
25
|
*/
|
|
26
26
|
exports.PUSH_SUBSYSTEM_DOWN = 'PUSH_SUBSYSTEM_DOWN';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDelay = exports.parseFFUpdatePayload = exports.isInBitmap = exports.parseBitmap = exports.
|
|
3
|
+
exports.getDelay = exports.parseFFUpdatePayload = exports.isInBitmap = exports.parseBitmap = exports.parseCompressedData = void 0;
|
|
4
4
|
var decompress_1 = require("../../utils/decompress");
|
|
5
5
|
var base64_1 = require("../../utils/base64");
|
|
6
6
|
var murmur3_1 = require("../../utils/murmur3/murmur3");
|
|
@@ -30,27 +30,27 @@ function decompress(data, compression) {
|
|
|
30
30
|
return decompress_1.algorithms.gunzipSync(binData);
|
|
31
31
|
if (compression === ZLIB)
|
|
32
32
|
return decompress_1.algorithms.unzlibSync(binData);
|
|
33
|
-
throw new Error("Invalid compression algorithm #"
|
|
33
|
+
throw new Error("Invalid compression algorithm #".concat(compression));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* Decode, decompress and parse the provided 'data' into
|
|
36
|
+
* Decode, decompress and parse the provided 'data' into an object of type T
|
|
37
37
|
*
|
|
38
38
|
* @param data - base64 encoded string
|
|
39
39
|
* @param compression - 1 GZIP, 2 ZLIB
|
|
40
40
|
* @param avoidPrecisionLoss - true as default, set it as false if dont need to avoid precission loss
|
|
41
|
-
* @returns
|
|
41
|
+
* @returns parsed object
|
|
42
42
|
* @throws if data string cannot be decoded, decompressed or parsed
|
|
43
43
|
*/
|
|
44
|
-
function
|
|
44
|
+
function parseCompressedData(data, compression, avoidPrecisionLoss) {
|
|
45
45
|
if (avoidPrecisionLoss === void 0) { avoidPrecisionLoss = true; }
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
// replace numbers to strings, to avoid losing precision
|
|
46
|
+
var binData = decompress(data, compression);
|
|
47
|
+
var str = Uint8ArrayToString(binData);
|
|
48
|
+
// replace numbers to strings, to avoid losing precision (e.g., 64-bit IDs in KeyList)
|
|
49
49
|
if (avoidPrecisionLoss)
|
|
50
|
-
|
|
51
|
-
return JSON.parse(
|
|
50
|
+
str = str.replace(/\d+/g, '"$&"');
|
|
51
|
+
return JSON.parse(str);
|
|
52
52
|
}
|
|
53
|
-
exports.
|
|
53
|
+
exports.parseCompressedData = parseCompressedData;
|
|
54
54
|
/**
|
|
55
55
|
* Decode, decompress and parse the provided 'data' into a Bitmap object
|
|
56
56
|
*
|
|
@@ -83,7 +83,7 @@ exports.isInBitmap = isInBitmap;
|
|
|
83
83
|
*/
|
|
84
84
|
function parseFFUpdatePayload(compression, data) {
|
|
85
85
|
return compression > 0 ?
|
|
86
|
-
|
|
86
|
+
parseCompressedData(data, compression, false) :
|
|
87
87
|
JSON.parse((0, base64_1.decodeFromBase64)(data));
|
|
88
88
|
}
|
|
89
89
|
exports.parseFFUpdatePayload = parseFFUpdatePayload;
|
|
@@ -6,7 +6,7 @@ var Backoff_1 = require("../../utils/Backoff");
|
|
|
6
6
|
var SSEHandler_1 = require("./SSEHandler");
|
|
7
7
|
var MySegmentsUpdateWorker_1 = require("./UpdateWorkers/MySegmentsUpdateWorker");
|
|
8
8
|
var SegmentsUpdateWorker_1 = require("./UpdateWorkers/SegmentsUpdateWorker");
|
|
9
|
-
var
|
|
9
|
+
var DefinitionsUpdateWorker_1 = require("./UpdateWorkers/DefinitionsUpdateWorker");
|
|
10
10
|
var AuthClient_1 = require("./AuthClient");
|
|
11
11
|
var lang_1 = require("../../utils/lang");
|
|
12
12
|
var SSEClient_1 = require("./SSEClient");
|
|
@@ -45,8 +45,8 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
45
45
|
// init workers
|
|
46
46
|
// MySegmentsUpdateWorker (client-side) are initiated in `add` method
|
|
47
47
|
var segmentsUpdateWorker = userKey ? undefined : (0, SegmentsUpdateWorker_1.SegmentsUpdateWorker)(log, pollingManager.segmentsSyncTask, storage.segments);
|
|
48
|
-
// For server-side we pass the segmentsSyncTask, used by
|
|
49
|
-
var
|
|
48
|
+
// For server-side we pass the segmentsSyncTask, used by DefinitionsUpdateWorker to fetch new segments
|
|
49
|
+
var definitionsUpdateWorker = (0, DefinitionsUpdateWorker_1.DefinitionsUpdateWorker)(log, storage, pollingManager.definitionsSyncTask, readiness.definitions, telemetryTracker, userKey ? undefined : pollingManager.segmentsSyncTask);
|
|
50
50
|
// [Only for client-side] map of hashes to user keys, to dispatch membership update events to the corresponding MySegmentsUpdateWorker
|
|
51
51
|
var userKeyHashes = {};
|
|
52
52
|
// [Only for client-side] map of user keys to their corresponding hash64 and MySegmentsUpdateWorkers.
|
|
@@ -54,10 +54,10 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
54
54
|
var clients = {};
|
|
55
55
|
// [Only for client-side] variable to flag that a new client was added. It is needed to reconnect streaming.
|
|
56
56
|
var connectForNewClient = false;
|
|
57
|
-
// flag that indicates if `stop/disconnectPush` was called, either by the SyncManager, when the client is destroyed, or due to a
|
|
57
|
+
// flag that indicates if `stop/disconnectPush` was called, either by the SyncManager, when the client is destroyed, or due to a PUSH_NON_RETRYABLE_ERROR error.
|
|
58
58
|
// It is used to halt the `connectPush` process if it was in progress.
|
|
59
59
|
var disconnected;
|
|
60
|
-
// flag that indicates a
|
|
60
|
+
// flag that indicates a PUSH_NON_RETRYABLE_ERROR, condition with which starting pushManager again is ignored.
|
|
61
61
|
// true if STREAMING_DISABLED control event, or 'pushEnabled: false', or non-recoverable SSE or Auth errors.
|
|
62
62
|
var disabled; // `disabled` implies `disconnected === true`
|
|
63
63
|
/** PushManager functions related to initialization */
|
|
@@ -96,11 +96,11 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
96
96
|
authenticate(userKeys).then(function (authData) {
|
|
97
97
|
if (disconnected)
|
|
98
98
|
return;
|
|
99
|
-
// 'pushEnabled: false' is handled as a
|
|
99
|
+
// 'pushEnabled: false' is handled as a PUSH_NON_RETRYABLE_ERROR instead of PUSH_SUBSYSTEM_DOWN, in order to
|
|
100
100
|
// close the sseClient in case the org has been bloqued while the instance was connected to streaming
|
|
101
101
|
if (!authData.pushEnabled) {
|
|
102
102
|
log.info(constants_2.STREAMING_DISABLED);
|
|
103
|
-
pushEmitter.emit(constants_1.
|
|
103
|
+
pushEmitter.emit(constants_1.PUSH_NON_RETRYABLE_ERROR);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
// [Only for client-side] don't open SSE connection if a new shared client was added, since it means that a new authentication is taking place
|
|
@@ -115,7 +115,7 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
115
115
|
// Handle 4XX HTTP errors: 401 (invalid SDK Key) or 400 (using incorrect SDK Key, i.e., client-side SDK Key on server-side)
|
|
116
116
|
if (error.statusCode >= 400 && error.statusCode < 500) {
|
|
117
117
|
telemetryTracker.streamingEvent(constants_3.AUTH_REJECTION);
|
|
118
|
-
pushEmitter.emit(constants_1.
|
|
118
|
+
pushEmitter.emit(constants_1.PUSH_NON_RETRYABLE_ERROR);
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
// Handle other HTTP and network errors as recoverable errors
|
|
@@ -139,7 +139,7 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
139
139
|
}
|
|
140
140
|
// cancel scheduled fetch retries of Splits, Segments, and MySegments Update Workers
|
|
141
141
|
function stopWorkers() {
|
|
142
|
-
|
|
142
|
+
definitionsUpdateWorker.stop();
|
|
143
143
|
if (userKey)
|
|
144
144
|
(0, lang_1.forOwn)(clients, function (_a) {
|
|
145
145
|
var worker = _a.worker;
|
|
@@ -155,7 +155,7 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
155
155
|
connectPushRetryBackoff.reset();
|
|
156
156
|
});
|
|
157
157
|
/** Fallback to polling without retry due to: STREAMING_DISABLED control event, or 'pushEnabled: false', or non-recoverable SSE and Authentication errors */
|
|
158
|
-
pushEmitter.on(constants_1.
|
|
158
|
+
pushEmitter.on(constants_1.PUSH_NON_RETRYABLE_ERROR, function handleNonRetryableError() {
|
|
159
159
|
disabled = true;
|
|
160
160
|
// Note: `stopWorkers` is been called twice, but it is not harmful
|
|
161
161
|
disconnectPush();
|
|
@@ -181,9 +181,9 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
181
181
|
connectPush();
|
|
182
182
|
});
|
|
183
183
|
/** Functions related to synchronization (Queues and Workers in the spec) */
|
|
184
|
-
pushEmitter.on(constants_1.SPLIT_KILL,
|
|
185
|
-
pushEmitter.on(constants_1.SPLIT_UPDATE,
|
|
186
|
-
pushEmitter.on(constants_1.RB_SEGMENT_UPDATE,
|
|
184
|
+
pushEmitter.on(constants_1.SPLIT_KILL, definitionsUpdateWorker.killDefinition);
|
|
185
|
+
pushEmitter.on(constants_1.SPLIT_UPDATE, definitionsUpdateWorker.put);
|
|
186
|
+
pushEmitter.on(constants_1.RB_SEGMENT_UPDATE, definitionsUpdateWorker.put);
|
|
187
187
|
function handleMySegmentsUpdate(parsedData) {
|
|
188
188
|
switch (parsedData.u) {
|
|
189
189
|
case types_1.UpdateStrategy.BoundedFetchRequest: {
|
|
@@ -206,7 +206,7 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
206
206
|
case types_1.UpdateStrategy.KeyList: {
|
|
207
207
|
var keyList = void 0, added_1, removed_1;
|
|
208
208
|
try {
|
|
209
|
-
keyList = (0, parseUtils_1.
|
|
209
|
+
keyList = (0, parseUtils_1.parseCompressedData)(parsedData.d, parsedData.c);
|
|
210
210
|
added_1 = new Set(keyList.a);
|
|
211
211
|
removed_1 = new Set(keyList.r);
|
|
212
212
|
}
|
|
@@ -7,14 +7,14 @@ var constants_1 = require("../../logger/constants");
|
|
|
7
7
|
/**
|
|
8
8
|
* Converts `impressions` data from cache into request payload.
|
|
9
9
|
*/
|
|
10
|
-
function fromImpressionsCollector(sendLabels, data) {
|
|
10
|
+
function fromImpressionsCollector(sendLabels, entityType, data) {
|
|
11
11
|
var groupedByFeature = (0, lang_1.groupBy)(data, 'feature');
|
|
12
12
|
var dto = [];
|
|
13
13
|
(0, lang_1.forOwn)(groupedByFeature, function (value, name) {
|
|
14
14
|
dto.push({
|
|
15
15
|
f: name,
|
|
16
16
|
i: value.map(function (entry) {
|
|
17
|
-
|
|
17
|
+
return {
|
|
18
18
|
k: entry.keyName,
|
|
19
19
|
t: entry.treatment,
|
|
20
20
|
m: entry.time,
|
|
@@ -22,9 +22,9 @@ function fromImpressionsCollector(sendLabels, data) {
|
|
|
22
22
|
r: sendLabels ? entry.label : undefined,
|
|
23
23
|
b: entry.bucketingKey,
|
|
24
24
|
pt: entry.pt,
|
|
25
|
-
properties: entry.properties
|
|
25
|
+
properties: entry.properties,
|
|
26
|
+
et: entityType, // Definition type
|
|
26
27
|
};
|
|
27
|
-
return keyImpression;
|
|
28
28
|
})
|
|
29
29
|
});
|
|
30
30
|
});
|
|
@@ -35,9 +35,9 @@ exports.fromImpressionsCollector = fromImpressionsCollector;
|
|
|
35
35
|
* Submitter that periodically posts impressions data
|
|
36
36
|
*/
|
|
37
37
|
function impressionsSubmitterFactory(params) {
|
|
38
|
-
var _a = params.settings, log = _a.log, impressionsRefreshRate = _a.scheduler.impressionsRefreshRate, labelsEnabled = _a.core.labelsEnabled, postTestImpressionsBulk = params.splitApi.postTestImpressionsBulk, impressions = params.storage.impressions;
|
|
38
|
+
var _a = params.settings, log = _a.log, impressionsRefreshRate = _a.scheduler.impressionsRefreshRate, labelsEnabled = _a.core.labelsEnabled, postTestImpressionsBulk = params.splitApi.postTestImpressionsBulk, impressions = params.storage.impressions, entityType = params.entityType;
|
|
39
39
|
// retry impressions only once.
|
|
40
|
-
var syncTask = (0, submitter_1.submitterFactory)(log, postTestImpressionsBulk, impressions, impressionsRefreshRate, fromImpressionsCollector.bind(undefined, labelsEnabled), 1);
|
|
40
|
+
var syncTask = (0, submitter_1.submitterFactory)(log, postTestImpressionsBulk, impressions, impressionsRefreshRate, fromImpressionsCollector.bind(undefined, labelsEnabled, entityType), 1);
|
|
41
41
|
// register impressions submitter to be executed when impressions cache is full
|
|
42
42
|
impressions.setOnFullQueueCb(function () {
|
|
43
43
|
if (syncTask.isRunning()) {
|
|
@@ -16,7 +16,7 @@ function submitterFactory(log, postClient, sourceCache, postRate, fromCacheToPay
|
|
|
16
16
|
if (sourceCache.isEmpty() && !data)
|
|
17
17
|
return Promise.resolve();
|
|
18
18
|
data = sourceCache.pop(data);
|
|
19
|
-
var dataCountMessage = typeof data.length === 'number' ? data.length
|
|
19
|
+
var dataCountMessage = typeof data.length === 'number' ? "".concat(data.length, " ").concat(dataName) : dataName;
|
|
20
20
|
log[debugLogs ? 'debug' : 'info'](constants_1.SUBMITTERS_PUSH, [dataCountMessage]);
|
|
21
21
|
var jsonPayload = JSON.stringify(fromCacheToPayload ? fromCacheToPayload(data) : data);
|
|
22
22
|
if (!maxRetries)
|
|
@@ -107,13 +107,12 @@ function telemetrySubmitterFactory(params) {
|
|
|
107
107
|
var telemetry = params.storage.telemetry, now = params.platform.now;
|
|
108
108
|
if (!telemetry || !now)
|
|
109
109
|
return; // No submitter created if telemetry cache is not defined
|
|
110
|
-
var settings = params.settings, _a = params.settings, log = _a.log, telemetryRefreshRate = _a.scheduler.telemetryRefreshRate, splitApi = params.splitApi, readiness = params.readiness
|
|
110
|
+
var settings = params.settings, _a = params.settings, log = _a.log, telemetryRefreshRate = _a.scheduler.telemetryRefreshRate, splitApi = params.splitApi, readiness = params.readiness;
|
|
111
111
|
var stopTimer = (0, timer_1.timer)(now);
|
|
112
112
|
var submitter = (0, submitter_1.firstPushWindowDecorator)((0, submitter_1.submitterFactory)(log, splitApi.postMetricsUsage, telemetry, telemetryRefreshRate, undefined, 0, true), telemetryRefreshRate);
|
|
113
113
|
readiness.gate.once(constants_2.SDK_READY_FROM_CACHE, function () {
|
|
114
114
|
telemetry.recordTimeUntilReadyFromCache(stopTimer());
|
|
115
115
|
});
|
|
116
|
-
sdkReadinessManager.incInternalReadyCbCount();
|
|
117
116
|
readiness.gate.once(constants_2.SDK_READY, function () {
|
|
118
117
|
telemetry.recordTimeUntilReady(stopTimer());
|
|
119
118
|
// Post config data when the SDK is ready and if the telemetry submitter was started
|
|
@@ -7,7 +7,8 @@ var constants_2 = require("../logger/constants");
|
|
|
7
7
|
var consent_1 = require("../consent");
|
|
8
8
|
var constants_3 = require("../utils/constants");
|
|
9
9
|
var constants_4 = require("../readiness/constants");
|
|
10
|
-
var
|
|
10
|
+
var AbstractDefinitionsCacheSync_1 = require("../storages/AbstractDefinitionsCacheSync");
|
|
11
|
+
var splitChangesFetcher_1 = require("./polling/fetchers/splitChangesFetcher");
|
|
11
12
|
/**
|
|
12
13
|
* Online SyncManager factory.
|
|
13
14
|
* Can be used for server-side API, and client-side API with or without multiple clients.
|
|
@@ -15,15 +16,17 @@ var AbstractSplitsCacheSync_1 = require("../storages/AbstractSplitsCacheSync");
|
|
|
15
16
|
* @param pollingManagerFactory - allows to specialize the SyncManager for server-side or client-side API by passing
|
|
16
17
|
* `pollingManagerSSFactory` or `pollingManagerCSFactory` respectively.
|
|
17
18
|
* @param pushManagerFactory - optional to build a SyncManager with or without streaming support
|
|
19
|
+
* @param definitionChangesFetcherFactory - optional to replace the default split changes fetcher
|
|
18
20
|
*/
|
|
19
|
-
function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFactory) {
|
|
21
|
+
function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFactory, definitionChangesFetcherFactory) {
|
|
22
|
+
if (definitionChangesFetcherFactory === void 0) { definitionChangesFetcherFactory = splitChangesFetcher_1.splitChangesFetcherFactory; }
|
|
20
23
|
/**
|
|
21
24
|
* SyncManager factory for modular SDK
|
|
22
25
|
*/
|
|
23
26
|
return function (params) {
|
|
24
27
|
var settings = params.settings, _a = params.settings, log = _a.log, streamingEnabled = _a.streamingEnabled, syncEnabled = _a.sync.enabled, telemetryTracker = params.telemetryTracker, storage = params.storage, readiness = params.readiness;
|
|
25
28
|
/** Polling Manager */
|
|
26
|
-
var pollingManager = pollingManagerFactory && pollingManagerFactory(params);
|
|
29
|
+
var pollingManager = pollingManagerFactory && pollingManagerFactory(params, definitionChangesFetcherFactory(params));
|
|
27
30
|
/** Push Manager */
|
|
28
31
|
var pushManager = syncEnabled && streamingEnabled && pollingManager && pushManagerFactory ?
|
|
29
32
|
pushManagerFactory(params, pollingManager) :
|
|
@@ -77,7 +80,7 @@ function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFactory) {
|
|
|
77
80
|
if (startFirstTime) {
|
|
78
81
|
// Emits SDK_READY_FROM_CACHE
|
|
79
82
|
if (!cacheMetadata.initialCacheLoad) {
|
|
80
|
-
readiness.
|
|
83
|
+
readiness.definitions.emit(constants_4.SDK_DEFINITIONS_CACHE_LOADED, cacheMetadata);
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
// start syncing splits and segments
|
|
@@ -136,7 +139,7 @@ function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFactory) {
|
|
|
136
139
|
if (pushManager) {
|
|
137
140
|
if (pollingManager.isRunning()) {
|
|
138
141
|
// if doing polling, we must start the periodic fetch of data
|
|
139
|
-
if ((0,
|
|
142
|
+
if ((0, AbstractDefinitionsCacheSync_1.usesSegmentsSync)(storage))
|
|
140
143
|
mySegmentsSyncTask.start();
|
|
141
144
|
}
|
|
142
145
|
else {
|
|
@@ -146,7 +149,7 @@ function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFactory) {
|
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
151
|
else {
|
|
149
|
-
if ((0,
|
|
152
|
+
if ((0, AbstractDefinitionsCacheSync_1.usesSegmentsSync)(storage))
|
|
150
153
|
mySegmentsSyncTask.start();
|
|
151
154
|
}
|
|
152
155
|
}
|
|
@@ -12,26 +12,24 @@ var mode_1 = require("../utils/settingsValidation/mode");
|
|
|
12
12
|
* @param eventsCache - cache to save events
|
|
13
13
|
* @param integrationsManager - optional event handler used for integrations
|
|
14
14
|
*/
|
|
15
|
-
function eventTrackerFactory(settings, eventsCache,
|
|
15
|
+
function eventTrackerFactory(settings, eventsCache, integrationsManager, telemetryCache) {
|
|
16
16
|
var log = settings.log, mode = settings.mode;
|
|
17
17
|
var isAsync = (0, mode_1.isConsumerMode)(mode);
|
|
18
18
|
function queueEventsCallback(eventData, tracked) {
|
|
19
19
|
var eventTypeId = eventData.eventTypeId, trafficTypeName = eventData.trafficTypeName, key = eventData.key, value = eventData.value, timestamp = eventData.timestamp, properties = eventData.properties;
|
|
20
20
|
// Logging every prop would be too much.
|
|
21
|
-
var msg = "event of type \""
|
|
21
|
+
var msg = "event of type \"".concat(eventTypeId, "\" for traffic type \"").concat(trafficTypeName, "\". Key: ").concat(key, ". Value: ").concat(value, ". Timestamp: ").concat(timestamp, ". ").concat(properties ? 'With properties.' : 'With no properties.');
|
|
22
22
|
if (tracked) {
|
|
23
23
|
log.info(constants_1.EVENTS_TRACKER_SUCCESS, [msg]);
|
|
24
24
|
if (integrationsManager) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
integrationsManager.handleEvent(eventDataCopy);
|
|
34
|
-
});
|
|
25
|
+
// Wrap in a timeout because we don't want it to be blocking.
|
|
26
|
+
setTimeout(function () {
|
|
27
|
+
// copy of event, to avoid unexpected behavior if modified by integrations
|
|
28
|
+
var eventDataCopy = (0, objectAssign_1.objectAssign)({}, eventData);
|
|
29
|
+
if (properties)
|
|
30
|
+
eventDataCopy.properties = (0, objectAssign_1.objectAssign)({}, properties);
|
|
31
|
+
// integrationsManager does not throw errors (they are internally handled by each integration module)
|
|
32
|
+
integrationsManager.handleEvent(eventDataCopy);
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildKey = void 0;
|
|
4
4
|
function buildKey(impression) {
|
|
5
|
-
return impression.keyName
|
|
5
|
+
return "".concat(impression.keyName, ":").concat(impression.feature, ":").concat(impression.treatment, ":").concat(impression.label, ":").concat(impression.changeNumber);
|
|
6
6
|
}
|
|
7
7
|
exports.buildKey = buildKey;
|
|
@@ -5,12 +5,31 @@ var objectAssign_1 = require("../utils/lang/objectAssign");
|
|
|
5
5
|
var thenable_1 = require("../utils/promise/thenable");
|
|
6
6
|
var constants_1 = require("../logger/constants");
|
|
7
7
|
var constants_2 = require("../utils/constants");
|
|
8
|
+
var strategyDebug_1 = require("./strategy/strategyDebug");
|
|
9
|
+
var strategyNone_1 = require("./strategy/strategyNone");
|
|
10
|
+
var strategyOptimized_1 = require("./strategy/strategyOptimized");
|
|
11
|
+
var uniqueKeysTracker_1 = require("./uniqueKeysTracker");
|
|
8
12
|
/**
|
|
9
13
|
* Impressions tracker stores impressions in cache and pass them to the listener and integrations manager if provided.
|
|
10
14
|
*/
|
|
11
|
-
function impressionsTrackerFactory(
|
|
12
|
-
var
|
|
15
|
+
function impressionsTrackerFactory(params, storage, integrationsManager) {
|
|
16
|
+
var settings = params.settings, impressionsObserverFactory = params.impressionsObserverFactory, filterAdapterFactory = params.filterAdapterFactory;
|
|
17
|
+
var log = settings.log, impressionListener = settings.impressionListener, _a = settings.runtime, ip = _a.ip, hostname = _a.hostname, version = settings.version, impressionsMode = settings.sync.impressionsMode;
|
|
18
|
+
var observer = impressionsObserverFactory();
|
|
19
|
+
var uniqueKeysTracker = (0, uniqueKeysTracker_1.uniqueKeysTrackerFactory)(log, storage.uniqueKeys, filterAdapterFactory && filterAdapterFactory());
|
|
20
|
+
var noneStrategy = (0, strategyNone_1.strategyNoneFactory)(storage.impressionCounts, uniqueKeysTracker);
|
|
21
|
+
var strategy = impressionsMode === constants_2.OPTIMIZED ?
|
|
22
|
+
(0, strategyOptimized_1.strategyOptimizedFactory)(observer, storage.impressionCounts) :
|
|
23
|
+
impressionsMode === constants_2.DEBUG ?
|
|
24
|
+
(0, strategyDebug_1.strategyDebugFactory)(observer) :
|
|
25
|
+
noneStrategy;
|
|
13
26
|
return {
|
|
27
|
+
start: function () {
|
|
28
|
+
uniqueKeysTracker.start();
|
|
29
|
+
},
|
|
30
|
+
stop: function () {
|
|
31
|
+
uniqueKeysTracker.stop();
|
|
32
|
+
},
|
|
14
33
|
track: function (impressions, attributes) {
|
|
15
34
|
if (settings.userConsent === constants_2.CONSENT_DECLINED)
|
|
16
35
|
return;
|
|
@@ -23,7 +42,7 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
|
|
|
23
42
|
var impressionsLength = impressions.length;
|
|
24
43
|
var impressionsToStoreLength = impressionsToStore.length;
|
|
25
44
|
if (impressionsToStoreLength) {
|
|
26
|
-
var res =
|
|
45
|
+
var res = storage.impressions.track(impressionsToStore.map(function (item) { return item.imp; }));
|
|
27
46
|
// If we're on an async storage, handle error and log it.
|
|
28
47
|
if ((0, thenable_1.thenable)(res)) {
|
|
29
48
|
res.then(function () {
|
|
@@ -35,9 +54,9 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
|
|
|
35
54
|
else {
|
|
36
55
|
// Record when impressionsCache is sync only (standalone mode)
|
|
37
56
|
// @TODO we are not dropping impressions on full queue yet, so DROPPED stats are not recorded
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
if (storage.telemetry) {
|
|
58
|
+
storage.telemetry.recordImpressionStats(constants_2.QUEUED, impressionsToStoreLength);
|
|
59
|
+
storage.telemetry.recordImpressionStats(constants_2.DEDUPED, impressionsLength - impressionsToStoreLength);
|
|
41
60
|
}
|
|
42
61
|
}
|
|
43
62
|
}
|
|
@@ -52,20 +71,18 @@ function impressionsTrackerFactory(settings, impressionsCache, noneStrategy, str
|
|
|
52
71
|
hostname: hostname,
|
|
53
72
|
sdkLanguageVersion: version
|
|
54
73
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
});
|
|
74
|
+
// Wrap in a timeout because we don't want it to be blocking.
|
|
75
|
+
setTimeout(function () {
|
|
76
|
+
// integrationsManager.handleImpression does not throw errors
|
|
77
|
+
if (integrationsManager)
|
|
78
|
+
integrationsManager.handleImpression(impressionData);
|
|
79
|
+
try { // @ts-ignore. An exception on the listeners should not break the SDK.
|
|
80
|
+
if (impressionListener)
|
|
81
|
+
impressionListener.logImpression(impressionData);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
log.error(constants_1.ERROR_IMPRESSIONS_LISTENER, [err]);
|
|
85
|
+
}
|
|
69
86
|
});
|
|
70
87
|
};
|
|
71
88
|
for (var i = 0; i < impressionsLength; i++) {
|