@splitsoftware/splitio-commons 1.2.0 → 1.2.1-rc.10
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/cjs/evaluator/Engine.js +6 -6
- package/cjs/evaluator/combiners/and.js +1 -1
- package/cjs/evaluator/combiners/ifelseif.js +2 -2
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/condition/index.js +4 -4
- package/cjs/evaluator/index.js +5 -5
- package/cjs/evaluator/matchers/cont_all.js +1 -1
- package/cjs/evaluator/matchers/cont_any.js +1 -1
- package/cjs/evaluator/matchers/cont_str.js +1 -1
- package/cjs/evaluator/matchers/dependency.js +1 -1
- package/cjs/evaluator/matchers/eq_set.js +1 -1
- package/cjs/evaluator/matchers/ew.js +3 -3
- package/cjs/evaluator/matchers/part_of.js +1 -1
- package/cjs/evaluator/matchers/segment.js +1 -1
- package/cjs/evaluator/matchers/sw.js +1 -1
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/evaluator/matchersTransform/index.js +12 -12
- package/cjs/evaluator/parser/index.js +6 -6
- package/cjs/evaluator/treatments/index.js +1 -1
- package/cjs/evaluator/value/index.js +1 -1
- package/cjs/evaluator/value/sanitize.js +4 -4
- package/cjs/integrations/browser.js +3 -3
- package/cjs/integrations/ga/GaToSplit.js +14 -14
- package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +5 -3
- package/cjs/integrations/ga/SplitToGa.js +1 -1
- package/cjs/integrations/ga/SplitToGoogleAnalytics.js +4 -2
- package/cjs/listeners/browser.js +15 -11
- package/cjs/listeners/node.js +1 -1
- package/cjs/logger/constants.js +8 -3
- package/cjs/logger/index.js +2 -2
- package/cjs/logger/messages/debug.js +4 -4
- package/cjs/logger/messages/error.js +5 -4
- package/cjs/logger/messages/info.js +10 -8
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/logger/sdkLogger.js +1 -1
- package/cjs/readiness/readinessManager.js +2 -2
- package/cjs/readiness/sdkReadinessManager.js +4 -4
- package/cjs/sdkClient/client.js +13 -11
- package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
- package/cjs/sdkClient/clientCS.js +4 -3
- package/cjs/sdkClient/clientInputValidation.js +20 -22
- package/cjs/sdkClient/sdkClient.js +3 -6
- package/cjs/sdkClient/sdkClientMethod.js +1 -1
- package/cjs/sdkClient/sdkClientMethodCS.js +6 -10
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +7 -15
- package/cjs/sdkFactory/index.js +14 -12
- package/cjs/sdkFactory/userConsentProps.js +37 -0
- package/cjs/sdkManager/index.js +11 -11
- package/cjs/services/splitApi.js +3 -2
- package/cjs/services/splitHttpClient.js +3 -3
- package/cjs/storages/KeyBuilder.js +2 -6
- package/cjs/storages/KeyBuilderCS.js +13 -3
- package/cjs/storages/KeyBuilderSS.js +1 -1
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +24 -4
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
- package/cjs/storages/inLocalStorage/index.js +4 -4
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/cjs/storages/inMemory/LatenciesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -2
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/LatenciesCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +24 -11
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/index.js +1 -1
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/cjs/storages/pluggable/inMemoryWrapper.js +4 -4
- package/cjs/storages/pluggable/index.js +6 -6
- package/cjs/sync/offline/LocalhostFromFile.js +1 -1
- package/cjs/sync/offline/LocalhostFromObject.js +1 -1
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +13 -13
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +3 -3
- package/cjs/sync/offline/syncManagerOffline.js +1 -1
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerCS.js +8 -7
- package/cjs/sync/polling/pollingManagerSS.js +5 -4
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -2
- package/cjs/sync/streaming/AuthClient/index.js +4 -5
- package/cjs/sync/streaming/SSEClient/index.js +2 -1
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +3 -3
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/cjs/sync/streaming/mySegmentsV2utils.js +1 -1
- package/cjs/sync/streaming/pushManager.js +46 -35
- package/cjs/sync/submitters/eventsSyncTask.js +17 -5
- package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionsSyncTask.js +15 -3
- package/cjs/sync/submitters/metricsSyncTask.js +3 -3
- package/cjs/sync/submitters/submitterManager.js +6 -5
- package/cjs/sync/submitters/submitterSyncTask.js +1 -1
- package/cjs/sync/syncManagerOnline.js +21 -17
- package/cjs/trackers/eventTracker.js +11 -4
- package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
- package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
- package/cjs/trackers/impressionObserver/utils.js +8 -1
- package/cjs/trackers/impressionsTracker.js +9 -8
- package/cjs/utils/MinEvents.js +2 -1
- package/cjs/utils/consent.js +10 -0
- package/cjs/utils/constants/index.js +5 -1
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +4 -4
- package/cjs/utils/inputValidation/attributes.js +2 -2
- package/cjs/utils/inputValidation/event.js +1 -1
- package/cjs/utils/inputValidation/eventProperties.js +7 -5
- package/cjs/utils/inputValidation/eventValue.js +1 -1
- package/cjs/utils/inputValidation/key.js +6 -5
- package/cjs/utils/inputValidation/preloadedData.js +8 -8
- package/cjs/utils/inputValidation/split.js +1 -1
- package/cjs/utils/inputValidation/splits.js +2 -2
- package/cjs/utils/inputValidation/trafficType.js +1 -1
- package/cjs/utils/inputValidation/trafficTypeExistance.js +1 -1
- package/cjs/utils/jwt/index.js +1 -1
- package/cjs/utils/key/index.js +3 -3
- package/cjs/utils/lang/index.js +13 -16
- package/cjs/utils/lang/maps.js +16 -2
- package/cjs/utils/murmur3/common.js +1 -1
- package/cjs/utils/murmur3/legacy.js +44 -0
- package/cjs/utils/murmur3/murmur3.js +10 -10
- package/cjs/utils/murmur3/murmur3_128.js +1 -1
- package/cjs/utils/murmur3/murmur3_128_x86.js +37 -37
- package/cjs/utils/murmur3/murmur3_64.js +1 -1
- package/cjs/utils/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/consent.js +16 -0
- package/cjs/utils/settingsValidation/impressionsMode.js +6 -6
- package/cjs/utils/settingsValidation/index.js +32 -14
- package/cjs/utils/settingsValidation/integrations/configurable.js +1 -1
- package/cjs/utils/settingsValidation/integrations/pluggable.js +1 -1
- package/cjs/utils/settingsValidation/localhost/builtin.js +2 -2
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +3 -3
- package/cjs/utils/settingsValidation/logger/commons.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/cjs/utils/settingsValidation/runtime.js +11 -0
- package/cjs/utils/settingsValidation/splitFilters.js +1 -1
- package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
- package/cjs/utils/timeTracker/index.js +3 -3
- package/esm/evaluator/matchers/ew.js +4 -4
- package/esm/integrations/ga/GoogleAnalyticsToSplit.js +4 -2
- package/esm/integrations/ga/SplitToGoogleAnalytics.js +4 -2
- package/esm/listeners/browser.js +14 -10
- package/esm/logger/constants.js +5 -2
- package/esm/logger/messages/debug.js +3 -3
- package/esm/logger/messages/error.js +4 -3
- package/esm/logger/messages/info.js +9 -7
- package/esm/sdkClient/client.js +4 -2
- package/esm/sdkClient/clientCS.js +2 -1
- package/esm/sdkClient/clientInputValidation.js +6 -8
- package/esm/sdkClient/sdkClient.js +1 -4
- package/esm/sdkClient/sdkClientMethodCS.js +1 -5
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +1 -9
- package/esm/sdkFactory/index.js +8 -6
- package/esm/sdkFactory/userConsentProps.js +33 -0
- package/esm/services/splitApi.js +2 -1
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/KeyBuilder.js +2 -6
- package/esm/storages/KeyBuilderCS.js +11 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +23 -3
- package/esm/storages/inLocalStorage/index.js +1 -1
- package/esm/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
- package/esm/storages/inMemory/InMemoryStorage.js +1 -1
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +15 -2
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +2 -2
- package/esm/sync/polling/pollingManagerCS.js +2 -1
- package/esm/sync/polling/pollingManagerSS.js +2 -1
- package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/streaming/AuthClient/index.js +1 -2
- package/esm/sync/streaming/SSEClient/index.js +2 -1
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/esm/sync/streaming/pushManager.js +34 -23
- package/esm/sync/submitters/eventsSyncTask.js +18 -6
- package/esm/sync/submitters/impressionsSyncTask.js +13 -1
- package/esm/sync/submitters/submitterManager.js +2 -1
- package/esm/sync/syncManagerOnline.js +21 -17
- package/esm/trackers/eventTracker.js +8 -1
- package/esm/trackers/impressionObserver/utils.js +7 -1
- package/esm/trackers/impressionsTracker.js +6 -5
- package/esm/utils/consent.js +6 -0
- package/esm/utils/constants/index.js +4 -0
- package/esm/utils/inputValidation/attributes.js +1 -1
- package/esm/utils/inputValidation/eventProperties.js +4 -2
- package/esm/utils/inputValidation/key.js +2 -1
- package/esm/utils/lang/index.js +12 -15
- package/esm/utils/lang/maps.js +14 -1
- package/esm/utils/murmur3/legacy.js +39 -0
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/consent.js +12 -0
- package/esm/utils/settingsValidation/impressionsMode.js +7 -7
- package/esm/utils/settingsValidation/index.js +28 -10
- package/esm/utils/settingsValidation/runtime.js +7 -0
- package/package.json +7 -7
- package/src/evaluator/matchers/ew.ts +4 -4
- package/src/evaluator/parser/index.ts +1 -1
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +2 -2
- package/src/integrations/ga/GoogleAnalyticsToSplit.ts +7 -4
- package/src/integrations/ga/SplitToGoogleAnalytics.ts +7 -4
- package/src/integrations/pluggable.ts +2 -2
- package/src/integrations/types.ts +5 -0
- package/src/listeners/browser.ts +13 -9
- package/src/logger/.DS_Store +0 -0
- package/src/logger/constants.ts +5 -2
- package/src/logger/messages/debug.ts +3 -3
- package/src/logger/messages/error.ts +4 -3
- package/src/logger/messages/info.ts +9 -7
- package/src/logger/types.ts +4 -0
- package/src/sdkClient/client.ts +4 -2
- package/src/sdkClient/clientCS.ts +3 -1
- package/src/sdkClient/clientInputValidation.ts +8 -7
- package/src/sdkClient/sdkClient.ts +2 -5
- package/src/sdkClient/sdkClientMethodCS.ts +1 -6
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +2 -11
- package/src/sdkFactory/index.ts +9 -7
- package/src/sdkFactory/types.ts +2 -1
- package/src/sdkFactory/userConsentProps.ts +40 -0
- package/src/services/splitHttpClient.ts +1 -1
- package/src/storages/KeyBuilder.ts +2 -6
- package/src/storages/KeyBuilderCS.ts +13 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +23 -3
- package/src/storages/inLocalStorage/index.ts +1 -1
- package/src/storages/inMemory/ImpressionsCacheInMemory.ts +22 -1
- package/src/storages/inMemory/InMemoryStorage.ts +1 -1
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
- package/src/storages/inRedis/RedisAdapter.ts +8 -2
- package/src/storages/pluggable/index.ts +2 -2
- package/src/storages/types.ts +6 -2
- package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -1
- package/src/sync/polling/fetchers/types.ts +1 -0
- package/src/sync/polling/pollingManagerCS.ts +3 -6
- package/src/sync/polling/pollingManagerSS.ts +3 -8
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +2 -1
- package/src/sync/polling/types.ts +0 -12
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -1
- package/src/sync/streaming/AuthClient/index.ts +1 -2
- package/src/sync/streaming/SSEClient/index.ts +2 -1
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
- package/src/sync/streaming/pushManager.ts +39 -37
- package/src/sync/streaming/types.ts +5 -25
- package/src/sync/submitters/eventsSyncTask.ts +19 -6
- package/src/sync/submitters/impressionsSyncTask.ts +16 -1
- package/src/sync/submitters/submitterManager.ts +4 -8
- package/src/sync/syncManagerOnline.ts +27 -27
- package/src/sync/types.ts +4 -1
- package/src/trackers/eventTracker.ts +11 -3
- package/src/trackers/impressionObserver/utils.ts +8 -1
- package/src/trackers/impressionsTracker.ts +7 -8
- package/src/types.ts +26 -1
- package/src/utils/consent.ts +8 -0
- package/src/utils/constants/index.ts +5 -0
- package/src/utils/inputValidation/attributes.ts +1 -2
- package/src/utils/inputValidation/eventProperties.ts +4 -2
- package/src/utils/lang/index.ts +15 -18
- package/src/utils/lang/maps.ts +15 -1
- package/src/utils/murmur3/legacy.ts +48 -0
- package/src/utils/promise/timeout.ts +1 -1
- package/src/utils/settingsValidation/consent.ts +16 -0
- package/src/utils/settingsValidation/impressionsMode.ts +8 -8
- package/src/utils/settingsValidation/index.ts +29 -10
- package/src/utils/settingsValidation/runtime.ts +9 -0
- package/src/utils/settingsValidation/types.ts +12 -6
- package/types/evaluator/types.d.ts +2 -2
- package/types/evaluator/value/index.d.ts +1 -1
- package/types/evaluator/value/sanitize.d.ts +1 -1
- package/types/integrations/ga/GaToSplitPlugin.d.ts +3 -0
- package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +2 -2
- package/types/integrations/ga/SplitToGaPlugin.d.ts +4 -0
- package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +2 -3
- package/types/integrations/types.d.ts +4 -0
- package/types/logger/browser/{DebugLogger.d.ts → debugLogger.d.ts} +0 -0
- package/types/logger/browser/{ErrorLogger.d.ts → errorLogger.d.ts} +0 -0
- package/types/logger/browser/{InfoLogger.d.ts → infoLogger.d.ts} +0 -0
- package/types/logger/browser/{WarnLogger.d.ts → warnLogger.d.ts} +0 -0
- package/types/logger/codes.d.ts +2 -0
- package/types/logger/codesConstants.d.ts +117 -0
- package/types/logger/codesConstantsBrowser.d.ts +2 -0
- package/types/logger/codesConstantsNode.d.ts +14 -0
- package/types/logger/codesDebug.d.ts +1 -0
- package/types/logger/codesDebugBrowser.d.ts +1 -0
- package/types/logger/codesDebugNode.d.ts +1 -0
- package/types/logger/codesError.d.ts +1 -0
- package/types/logger/codesErrorNode.d.ts +1 -0
- package/types/logger/codesInfo.d.ts +1 -0
- package/types/logger/codesWarn.d.ts +1 -0
- package/types/logger/codesWarnNode.d.ts +1 -0
- package/types/logger/constants.d.ts +5 -2
- package/types/logger/debugLogger.d.ts +2 -0
- package/types/logger/errorLogger.d.ts +2 -0
- package/types/logger/infoLogger.d.ts +2 -0
- package/types/logger/messages/debugBrowser.d.ts +1 -0
- package/types/logger/messages/debugNode.d.ts +1 -0
- package/types/logger/messages/errorNode.d.ts +1 -0
- package/types/logger/messages/warnNode.d.ts +1 -0
- package/types/logger/noopLogger.d.ts +2 -0
- package/types/logger/types.d.ts +4 -0
- package/types/logger/warnLogger.d.ts +2 -0
- package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
- package/types/sdkClient/clientInputValidation.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +1 -1
- package/types/sdkFactory/userConsentProps.d.ts +6 -0
- package/types/sdkManager/sdkManagerMethod.d.ts +6 -0
- package/types/storages/KeyBuilderCS.d.ts +2 -0
- package/types/storages/getRegisteredSegments.d.ts +10 -0
- package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +9 -0
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +51 -0
- package/types/storages/inMemory/index.d.ts +10 -0
- package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
- package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +0 -0
- package/types/storages/parseSegments.d.ts +6 -0
- package/types/storages/pluggable/TelemetryCachePluggable.d.ts +2 -0
- package/types/storages/types.d.ts +3 -1
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +1 -1
- package/types/sync/polling/fetchers/types.d.ts +1 -1
- package/types/sync/polling/pollingManagerCS.d.ts +2 -5
- package/types/sync/polling/pollingManagerSS.d.ts +2 -5
- package/types/sync/polling/syncTasks/splitsSyncTask.copy.d.ts +35 -0
- package/types/sync/polling/syncTasks/splitsSyncTask.morelikeoriginal.d.ts +35 -0
- package/types/sync/polling/types.d.ts +0 -11
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
- package/types/sync/streaming/AuthClient/indexV1.d.ts +12 -0
- package/types/sync/streaming/AuthClient/indexV2.d.ts +8 -0
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
- package/types/sync/streaming/pushManager.d.ts +3 -7
- package/types/sync/streaming/pushManagerCS.d.ts +1 -0
- package/types/sync/streaming/pushManagerNoUsers.d.ts +13 -0
- package/types/sync/streaming/pushManagerSS.d.ts +1 -0
- package/types/sync/streaming/types.d.ts +3 -23
- package/types/sync/submitters/submitterManager.d.ts +2 -4
- package/types/sync/submitters/telemetrySyncTask.d.ts +17 -0
- package/types/sync/syncManagerFromFile.d.ts +2 -0
- package/types/sync/syncManagerFromObject.d.ts +2 -0
- package/types/sync/syncManagerOffline.d.ts +9 -0
- package/types/sync/syncManagerOnline.d.ts +3 -3
- package/types/sync/types.d.ts +3 -0
- package/types/trackers/eventTracker.d.ts +2 -2
- package/types/trackers/impressionObserver/utils.d.ts +4 -0
- package/types/trackers/impressionsTracker.d.ts +2 -3
- package/types/trackers/telemetryRecorder.d.ts +0 -0
- package/types/types.d.ts +22 -0
- package/types/utils/EventEmitter.d.ts +4 -0
- package/types/utils/consent.d.ts +2 -0
- package/types/utils/constants/index.d.ts +3 -0
- package/types/utils/lang/errors.d.ts +10 -0
- package/types/utils/lang/index.d.ts +6 -5
- package/types/utils/lang/maps.d.ts +7 -0
- package/types/utils/murmur3/commons.d.ts +12 -0
- package/types/utils/murmur3/legacy.d.ts +2 -0
- package/types/utils/settingsValidation/buildMetadata.d.ts +3 -0
- package/types/utils/settingsValidation/consent.d.ts +6 -0
- package/types/utils/settingsValidation/impressionsMode.d.ts +1 -1
- package/types/utils/settingsValidation/localhost/index.d.ts +9 -0
- package/types/utils/settingsValidation/logger.d.ts +11 -0
- package/types/utils/settingsValidation/runtime/browser.d.ts +2 -0
- package/types/utils/settingsValidation/runtime/node.d.ts +2 -0
- package/types/utils/settingsValidation/runtime.d.ts +2 -0
- package/types/utils/settingsValidation/types.d.ts +12 -6
- package/types/utils/settingsValidation/userConsent.d.ts +5 -0
package/src/sdkFactory/index.ts
CHANGED
|
@@ -12,14 +12,15 @@ import { createLoggerAPI } from '../logger/sdkLogger';
|
|
|
12
12
|
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
13
13
|
import { metadataBuilder } from '../storages/metadataBuilder';
|
|
14
14
|
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
15
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Modular SDK factory
|
|
18
19
|
*/
|
|
19
20
|
export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.ISDK | SplitIO.IAsyncSDK {
|
|
20
21
|
|
|
21
|
-
const { settings, platform, storageFactory, splitApiFactory,
|
|
22
|
-
syncManagerFactory, SignalListener, impressionsObserverFactory,
|
|
22
|
+
const { settings, platform, storageFactory, splitApiFactory, extraProps,
|
|
23
|
+
syncManagerFactory, SignalListener, impressionsObserverFactory,
|
|
23
24
|
integrationsManagerFactory, sdkManagerFactory, sdkClientMethodFactory } = params;
|
|
24
25
|
const log = settings.log;
|
|
25
26
|
|
|
@@ -33,6 +34,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
33
34
|
|
|
34
35
|
// @TODO consider passing the settings object, so that each storage access only what it needs
|
|
35
36
|
const storageFactoryParams: IStorageFactoryParams = {
|
|
37
|
+
impressionsQueueSize: settings.scheduler.impressionsQueueSize,
|
|
36
38
|
eventsQueueSize: settings.scheduler.eventsQueueSize,
|
|
37
39
|
optimize: shouldBeOptimized(settings),
|
|
38
40
|
|
|
@@ -72,8 +74,8 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
72
74
|
|
|
73
75
|
// trackers
|
|
74
76
|
const observer = impressionsObserverFactory && impressionsObserverFactory();
|
|
75
|
-
const impressionsTracker = impressionsTrackerFactory(
|
|
76
|
-
const eventTracker = eventTrackerFactory(
|
|
77
|
+
const impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, integrationsManager, observer, storage.impressionCounts);
|
|
78
|
+
const eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager);
|
|
77
79
|
|
|
78
80
|
// signal listener
|
|
79
81
|
const signalListener = SignalListener && new SignalListener(syncManager, settings, storage, splitApi);
|
|
@@ -87,12 +89,12 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
87
89
|
|
|
88
90
|
log.info(NEW_FACTORY);
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
return objectAssign({
|
|
91
94
|
// Split evaluation and event tracking engine
|
|
92
95
|
client: clientMethod,
|
|
93
96
|
|
|
94
97
|
// Manager API to explore available information
|
|
95
|
-
// @ts-ignore
|
|
96
98
|
manager() {
|
|
97
99
|
log.debug(RETRIEVE_MANAGER);
|
|
98
100
|
return managerInstance;
|
|
@@ -102,5 +104,5 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
102
104
|
Logger: createLoggerAPI(settings.log),
|
|
103
105
|
|
|
104
106
|
settings,
|
|
105
|
-
};
|
|
107
|
+
}, extraProps && extraProps(settings, syncManager));
|
|
106
108
|
}
|
package/src/sdkFactory/types.ts
CHANGED
|
@@ -64,10 +64,11 @@ export interface ISdkFactoryParams {
|
|
|
64
64
|
serviceApi: ISplitApi | undefined) => ISignalListener, // Used by BrowserSignalListener
|
|
65
65
|
|
|
66
66
|
// @TODO review impressionListener and integrations interfaces. What about handling impressionListener as an integration ?
|
|
67
|
-
impressionListener?: SplitIO.IImpressionListener,
|
|
68
67
|
integrationsManagerFactory?: (params: IIntegrationFactoryParams) => IIntegrationManager | undefined,
|
|
69
68
|
|
|
70
69
|
// Impression observer factory. If provided, will be used for impressions dedupe
|
|
71
70
|
impressionsObserverFactory?: () => IImpressionObserver
|
|
72
71
|
|
|
72
|
+
// Optional function to assign additional properties to the factory instance
|
|
73
|
+
extraProps?: (settings: ISettings, syncManager?: ISyncManager) => object
|
|
73
74
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
|
|
2
|
+
import { ISyncManager } from '../sync/types';
|
|
3
|
+
import { ISettings } from '../types';
|
|
4
|
+
import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
|
|
5
|
+
import { isBoolean } from '../utils/lang';
|
|
6
|
+
|
|
7
|
+
// Extend client-side factory instances with user consent getter/setter
|
|
8
|
+
export function userConsentProps(settings: ISettings, syncManager?: ISyncManager) {
|
|
9
|
+
|
|
10
|
+
const log = settings.log;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
setUserConsent(consent: unknown) {
|
|
14
|
+
// validate input param
|
|
15
|
+
if (!isBoolean(consent)) {
|
|
16
|
+
log.warn(ERROR_NOT_BOOLEAN, ['setUserConsent']);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
|
|
21
|
+
|
|
22
|
+
if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
|
|
23
|
+
settings.userConsent = newConsentStatus;
|
|
24
|
+
|
|
25
|
+
if (consent) syncManager?.submitter?.start(); // resumes submitters if transitioning to GRANTED
|
|
26
|
+
else syncManager?.submitter?.stop(); // pauses submitters if transitioning to DECLINED
|
|
27
|
+
|
|
28
|
+
log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
|
|
29
|
+
} else {
|
|
30
|
+
log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return true;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
getUserConsent() {
|
|
37
|
+
return settings.userConsent;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { startsWith } from '../utils/lang';
|
|
2
2
|
|
|
3
3
|
const everythingAtTheEnd = /[^.]+$/;
|
|
4
4
|
|
|
5
5
|
const DEFAULT_PREFIX = 'SPLITIO';
|
|
6
6
|
|
|
7
7
|
export function validatePrefix(prefix: unknown) {
|
|
8
|
-
return prefix
|
|
9
|
-
endsWith(prefix, '.' + DEFAULT_PREFIX) ?
|
|
10
|
-
prefix : // suffix already appended
|
|
11
|
-
prefix + '.' + DEFAULT_PREFIX : // append suffix
|
|
12
|
-
DEFAULT_PREFIX; // use default prefix if none is provided
|
|
8
|
+
return prefix ? prefix + '.SPLITIO' : 'SPLITIO';
|
|
13
9
|
}
|
|
14
10
|
|
|
15
11
|
export class KeyBuilder {
|
|
@@ -16,10 +16,22 @@ export class KeyBuilderCS extends KeyBuilder {
|
|
|
16
16
|
* @override
|
|
17
17
|
*/
|
|
18
18
|
buildSegmentNameKey(segmentName: string) {
|
|
19
|
-
return `${this.
|
|
19
|
+
return `${this.prefix}.${this.matchingKey}.segment.${segmentName}`;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
extractSegmentName(builtSegmentKeyName: string) {
|
|
23
|
+
const prefix = `${this.prefix}.${this.matchingKey}.segment.`;
|
|
24
|
+
|
|
25
|
+
if (startsWith(builtSegmentKeyName, prefix))
|
|
26
|
+
return builtSegmentKeyName.substr(prefix.length);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// @BREAKING: The key used to start with the matching key instead of the prefix, this was changed on version 10.17.3
|
|
30
|
+
buildOldSegmentNameKey(segmentName: string) {
|
|
31
|
+
return `${this.matchingKey}.${this.prefix}.segment.${segmentName}`;
|
|
32
|
+
}
|
|
33
|
+
// @BREAKING: The key used to start with the matching key instead of the prefix, this was changed on version 10.17.3
|
|
34
|
+
extractOldSegmentKey(builtSegmentKeyName: string) {
|
|
23
35
|
const prefix = `${this.matchingKey}.${this.prefix}.segment.`;
|
|
24
36
|
|
|
25
37
|
if (startsWith(builtSegmentKeyName, prefix))
|
|
@@ -67,9 +67,29 @@ export class MySegmentsCacheInLocal extends AbstractSegmentsCacheSync {
|
|
|
67
67
|
|
|
68
68
|
// Scan current values from localStorage
|
|
69
69
|
const storedSegmentNames = Object.keys(localStorage).reduce((accum, key) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (
|
|
70
|
+
let segmentName = this.keys.extractSegmentName(key);
|
|
71
|
+
|
|
72
|
+
if (segmentName) {
|
|
73
|
+
accum.push(segmentName);
|
|
74
|
+
} else {
|
|
75
|
+
// @BREAKING: This is only to clean up "old" keys. Remove this whole else code block.
|
|
76
|
+
segmentName = this.keys.extractOldSegmentKey(key);
|
|
77
|
+
|
|
78
|
+
if (segmentName) { // this was an old segment key, let's clean up.
|
|
79
|
+
const newSegmentKey = this.keys.buildSegmentNameKey(segmentName);
|
|
80
|
+
try {
|
|
81
|
+
// If the new format key is not there, create it.
|
|
82
|
+
if (!localStorage.getItem(newSegmentKey) && names.indexOf(segmentName) > -1) {
|
|
83
|
+
localStorage.setItem(newSegmentKey, DEFINED);
|
|
84
|
+
// we are migrating a segment, let's track it.
|
|
85
|
+
accum.push(segmentName);
|
|
86
|
+
}
|
|
87
|
+
localStorage.removeItem(key); // we migrated the current key, let's delete it.
|
|
88
|
+
} catch (e) {
|
|
89
|
+
this.log.error(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
73
93
|
|
|
74
94
|
return accum;
|
|
75
95
|
}, [] as string[]);
|
|
@@ -40,7 +40,7 @@ export function InLocalStorage(options: InLocalStorageOptions = {}): IStorageSyn
|
|
|
40
40
|
return {
|
|
41
41
|
splits: new SplitsCacheInLocal(log, keys, expirationTimestamp, params.splitFiltersValidation),
|
|
42
42
|
segments: new MySegmentsCacheInLocal(log, keys),
|
|
43
|
-
impressions: new ImpressionsCacheInMemory(),
|
|
43
|
+
impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
44
44
|
impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
|
|
45
45
|
events: new EventsCacheInMemory(params.eventsQueueSize),
|
|
46
46
|
|
|
@@ -3,13 +3,34 @@ import { ImpressionDTO } from '../../types';
|
|
|
3
3
|
|
|
4
4
|
export class ImpressionsCacheInMemory implements IImpressionsCacheSync {
|
|
5
5
|
|
|
6
|
-
private
|
|
6
|
+
private onFullQueue?: () => void;
|
|
7
|
+
private readonly maxQueue: number;
|
|
8
|
+
private queue: ImpressionDTO[];
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param impressionsQueueSize number of queued impressions to call onFullQueueCb.
|
|
13
|
+
* Default value is 0, that means no maximum value, in case we want to avoid this being triggered.
|
|
14
|
+
*/
|
|
15
|
+
constructor(impressionsQueueSize: number = 0) {
|
|
16
|
+
this.maxQueue = impressionsQueueSize;
|
|
17
|
+
this.queue = [];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setOnFullQueueCb(cb: () => void) {
|
|
21
|
+
this.onFullQueue = cb;
|
|
22
|
+
}
|
|
7
23
|
|
|
8
24
|
/**
|
|
9
25
|
* Store impressions in sequential order
|
|
10
26
|
*/
|
|
11
27
|
track(data: ImpressionDTO[]) {
|
|
12
28
|
this.queue.push(...data);
|
|
29
|
+
|
|
30
|
+
// Check if the cache queue is full and we need to flush it.
|
|
31
|
+
if (this.maxQueue > 0 && this.queue.length >= this.maxQueue && this.onFullQueue) {
|
|
32
|
+
this.onFullQueue();
|
|
33
|
+
}
|
|
13
34
|
}
|
|
14
35
|
|
|
15
36
|
/**
|
|
@@ -16,7 +16,7 @@ export function InMemoryStorageFactory(params: IStorageFactoryParams): IStorageS
|
|
|
16
16
|
return {
|
|
17
17
|
splits: new SplitsCacheInMemory(),
|
|
18
18
|
segments: new SegmentsCacheInMemory(),
|
|
19
|
-
impressions: new ImpressionsCacheInMemory(),
|
|
19
|
+
impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
20
20
|
impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
|
|
21
21
|
events: new EventsCacheInMemory(params.eventsQueueSize),
|
|
22
22
|
|
|
@@ -16,7 +16,7 @@ export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorag
|
|
|
16
16
|
return {
|
|
17
17
|
splits: new SplitsCacheInMemory(),
|
|
18
18
|
segments: new MySegmentsCacheInMemory(),
|
|
19
|
-
impressions: new ImpressionsCacheInMemory(),
|
|
19
|
+
impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
20
20
|
impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
|
|
21
21
|
events: new EventsCacheInMemory(params.eventsQueueSize),
|
|
22
22
|
|
|
@@ -164,6 +164,12 @@ export class RedisAdapter extends ioredis {
|
|
|
164
164
|
} else { // If it IS the string URL, that'll be the first param for ioredis.
|
|
165
165
|
result.unshift(options.url);
|
|
166
166
|
}
|
|
167
|
+
if (options.connectionTimeout) {
|
|
168
|
+
merge(opts, { connectTimeout: options.connectionTimeout });
|
|
169
|
+
}
|
|
170
|
+
if (options.tls) {
|
|
171
|
+
merge(opts, { tls: options.tls });
|
|
172
|
+
}
|
|
167
173
|
|
|
168
174
|
return result;
|
|
169
175
|
}
|
|
@@ -171,9 +177,9 @@ export class RedisAdapter extends ioredis {
|
|
|
171
177
|
/**
|
|
172
178
|
* Parses the options into what we care about.
|
|
173
179
|
*/
|
|
174
|
-
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass }: Record<string, any>) {
|
|
180
|
+
static _defineOptions({ connectionTimeout, operationTimeout, url, host, port, db, pass, tls }: Record<string, any>) {
|
|
175
181
|
const parsedOptions = {
|
|
176
|
-
connectionTimeout, operationTimeout, url, host, port, db, pass
|
|
182
|
+
connectionTimeout, operationTimeout, url, host, port, db, pass, tls
|
|
177
183
|
};
|
|
178
184
|
|
|
179
185
|
return merge({}, DEFAULT_OPTIONS, parsedOptions);
|
|
@@ -63,7 +63,7 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
|
|
|
63
63
|
|
|
64
64
|
const prefix = validatePrefix(options.prefix);
|
|
65
65
|
|
|
66
|
-
function PluggableStorageFactory({ log, metadata, onReadyCb, mode, eventsQueueSize, optimize }: IStorageFactoryParams): IStorageAsync {
|
|
66
|
+
function PluggableStorageFactory({ log, metadata, onReadyCb, mode, eventsQueueSize, impressionsQueueSize, optimize }: IStorageFactoryParams): IStorageAsync {
|
|
67
67
|
const keys = new KeyBuilderSS(prefix, metadata);
|
|
68
68
|
const wrapper = wrapperAdapter(log, options.wrapper);
|
|
69
69
|
const isPartialConsumer = mode === CONSUMER_PARTIAL_MODE;
|
|
@@ -74,7 +74,7 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
|
|
|
74
74
|
return {
|
|
75
75
|
splits: new SplitsCachePluggable(log, keys, wrapper),
|
|
76
76
|
segments: new SegmentsCachePluggable(log, keys, wrapper),
|
|
77
|
-
impressions: isPartialConsumer ? new ImpressionsCacheInMemory() : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
|
|
77
|
+
impressions: isPartialConsumer ? new ImpressionsCacheInMemory(impressionsQueueSize) : new ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
|
|
78
78
|
impressionCounts: optimize ? new ImpressionCountsCacheInMemory() : undefined,
|
|
79
79
|
events: isPartialConsumer ? promisifyEventsTrack(new EventsCacheInMemory(eventsQueueSize)) : new EventsCachePluggable(log, keys.buildEventsKey(), wrapper, metadata),
|
|
80
80
|
// @TODO add telemetry cache when required
|
package/src/storages/types.ts
CHANGED
|
@@ -298,7 +298,7 @@ export interface IRecorderCacheProducerSync<T> {
|
|
|
298
298
|
// @TODO names are inconsistent with spec
|
|
299
299
|
/* Checks if cache is empty. Returns true if the cache was just created or cleared */
|
|
300
300
|
isEmpty(): boolean
|
|
301
|
-
/*
|
|
301
|
+
/* Clears cache data */
|
|
302
302
|
clear(): void
|
|
303
303
|
/* Gets cache data */
|
|
304
304
|
state(): T
|
|
@@ -307,10 +307,13 @@ export interface IRecorderCacheProducerSync<T> {
|
|
|
307
307
|
|
|
308
308
|
export interface IImpressionsCacheSync extends IImpressionsCacheBase, IRecorderCacheProducerSync<ImpressionDTO[]> {
|
|
309
309
|
track(data: ImpressionDTO[]): void
|
|
310
|
+
/* Registers callback for full queue */
|
|
311
|
+
setOnFullQueueCb(cb: () => void): void
|
|
310
312
|
}
|
|
311
313
|
|
|
312
314
|
export interface IEventsCacheSync extends IEventsCacheBase, IRecorderCacheProducerSync<SplitIO.EventData[]> {
|
|
313
315
|
track(data: SplitIO.EventData, size?: number): boolean
|
|
316
|
+
/* Registers callback for full queue */
|
|
314
317
|
setOnFullQueueCb(cb: () => void): void
|
|
315
318
|
}
|
|
316
319
|
|
|
@@ -423,6 +426,7 @@ export type DataLoader = (storage: IStorageSync, matchingKey: string) => void
|
|
|
423
426
|
|
|
424
427
|
export interface IStorageFactoryParams {
|
|
425
428
|
log: ILogger,
|
|
429
|
+
impressionsQueueSize?: number,
|
|
426
430
|
eventsQueueSize?: number,
|
|
427
431
|
optimize?: boolean /* whether create the `impressionCounts` cache (OPTIMIZED impression mode) or not (DEBUG impression mode) */,
|
|
428
432
|
|
|
@@ -443,7 +447,7 @@ export interface IStorageFactoryParams {
|
|
|
443
447
|
export type StorageType = 'MEMORY' | 'LOCALSTORAGE' | 'REDIS' | 'PLUGGABLE';
|
|
444
448
|
|
|
445
449
|
export type IStorageSyncFactory = {
|
|
446
|
-
type: StorageType,
|
|
450
|
+
readonly type: StorageType,
|
|
447
451
|
(params: IStorageFactoryParams): IStorageSync
|
|
448
452
|
}
|
|
449
453
|
|
|
@@ -6,9 +6,10 @@ import { IMySegmentsFetcher } from './types';
|
|
|
6
6
|
* Factory of MySegments fetcher.
|
|
7
7
|
* MySegments fetcher is a wrapper around `mySegments` API service that parses the response and handle errors.
|
|
8
8
|
*/
|
|
9
|
-
export function mySegmentsFetcherFactory(fetchMySegments: IFetchMySegments
|
|
9
|
+
export function mySegmentsFetcherFactory(fetchMySegments: IFetchMySegments): IMySegmentsFetcher {
|
|
10
10
|
|
|
11
11
|
return function mySegmentsFetcher(
|
|
12
|
+
userMatchingKey: string,
|
|
12
13
|
noCache?: boolean,
|
|
13
14
|
// Optional decorator for `fetchMySegments` promise, such as timeout or time tracker
|
|
14
15
|
decorator?: (promise: Promise<IResponse>) => Promise<IResponse>
|
|
@@ -15,6 +15,7 @@ export type ISegmentChangesFetcher = (
|
|
|
15
15
|
) => Promise<ISegmentChangesResponse[]>
|
|
16
16
|
|
|
17
17
|
export type IMySegmentsFetcher = (
|
|
18
|
+
userMatchingKey: string,
|
|
18
19
|
noCache?: boolean,
|
|
19
20
|
decorator?: (promise: Promise<IResponse>) => Promise<IResponse>
|
|
20
21
|
) => Promise<string[]>
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { ISegmentsSyncTask, ISplitsSyncTask, IPollingManagerCS } from './types';
|
|
2
2
|
import { forOwn } from '../../utils/lang';
|
|
3
3
|
import { IReadinessManager } from '../../readiness/types';
|
|
4
|
-
import { ISplitApi } from '../../services/types';
|
|
5
4
|
import { IStorageSync } from '../../storages/types';
|
|
6
5
|
import { mySegmentsSyncTaskFactory } from './syncTasks/mySegmentsSyncTask';
|
|
7
6
|
import { splitsSyncTaskFactory } from './syncTasks/splitsSyncTask';
|
|
8
|
-
import { ISettings } from '../../types';
|
|
9
7
|
import { getMatching } from '../../utils/key';
|
|
10
8
|
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../../readiness/constants';
|
|
11
9
|
import { POLLING_SMART_PAUSING, POLLING_START, POLLING_STOP } from '../../logger/constants';
|
|
10
|
+
import { ISyncManagerFactoryParams } from '../types';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Expose start / stop mechanism for polling data from services.
|
|
15
14
|
* For client-side API with multiple clients.
|
|
16
15
|
*/
|
|
17
16
|
export function pollingManagerCSFactory(
|
|
18
|
-
|
|
19
|
-
storage: IStorageSync,
|
|
20
|
-
readiness: IReadinessManager,
|
|
21
|
-
settings: ISettings,
|
|
17
|
+
params: ISyncManagerFactoryParams
|
|
22
18
|
): IPollingManagerCS {
|
|
23
19
|
|
|
20
|
+
const { splitApi, storage, readiness, settings } = params;
|
|
24
21
|
const log = settings.log;
|
|
25
22
|
|
|
26
23
|
const splitsSyncTask: ISplitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { splitsSyncTaskFactory } from './syncTasks/splitsSyncTask';
|
|
2
2
|
import { segmentsSyncTaskFactory } from './syncTasks/segmentsSyncTask';
|
|
3
|
-
import { IStorageSync } from '../../storages/types';
|
|
4
|
-
import { IReadinessManager } from '../../readiness/types';
|
|
5
|
-
import { ISplitApi } from '../../services/types';
|
|
6
|
-
import { ISettings } from '../../types';
|
|
7
3
|
import { IPollingManager, ISegmentsSyncTask, ISplitsSyncTask } from './types';
|
|
8
4
|
import { thenable } from '../../utils/promise/thenable';
|
|
9
5
|
import { POLLING_START, POLLING_STOP, LOG_PREFIX_SYNC_POLLING } from '../../logger/constants';
|
|
6
|
+
import { ISyncManagerFactoryParams } from '../types';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* Expose start / stop mechanism for pulling data from services.
|
|
13
10
|
*/
|
|
14
11
|
export function pollingManagerSSFactory(
|
|
15
|
-
|
|
16
|
-
storage: IStorageSync,
|
|
17
|
-
readiness: IReadinessManager,
|
|
18
|
-
settings: ISettings
|
|
12
|
+
params: ISyncManagerFactoryParams
|
|
19
13
|
): IPollingManager {
|
|
20
14
|
|
|
15
|
+
const { splitApi, storage, readiness, settings } = params;
|
|
21
16
|
const log = settings.log;
|
|
22
17
|
|
|
23
18
|
const splitsSyncTask: ISplitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
|
|
@@ -21,12 +21,13 @@ export function mySegmentsSyncTaskFactory(
|
|
|
21
21
|
settings.log,
|
|
22
22
|
mySegmentsUpdaterFactory(
|
|
23
23
|
settings.log,
|
|
24
|
-
mySegmentsFetcherFactory(fetchMySegments
|
|
24
|
+
mySegmentsFetcherFactory(fetchMySegments),
|
|
25
25
|
storage.splits,
|
|
26
26
|
storage.segments,
|
|
27
27
|
readiness.segments,
|
|
28
28
|
settings.startup.requestTimeoutBeforeReady,
|
|
29
29
|
settings.startup.retriesOnFailureBeforeReady,
|
|
30
|
+
matchingKey
|
|
30
31
|
),
|
|
31
32
|
settings.scheduler.segmentsRefreshRate,
|
|
32
33
|
'mySegmentsUpdater',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { IReadinessManager } from '../../readiness/types';
|
|
2
|
-
import { ISplitApi } from '../../services/types';
|
|
3
2
|
import { IStorageSync } from '../../storages/types';
|
|
4
|
-
import { ISettings } from '../../types';
|
|
5
3
|
import { SegmentsData } from '../streaming/SSEHandler/types';
|
|
6
4
|
import { ITask, ISyncTask } from '../types';
|
|
7
5
|
|
|
@@ -23,13 +21,3 @@ export interface IPollingManagerCS extends IPollingManager {
|
|
|
23
21
|
remove(matchingKey: string): void;
|
|
24
22
|
get(matchingKey: string): ISegmentsSyncTask | undefined
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Signature of polling manager factory/constructor
|
|
29
|
-
*/
|
|
30
|
-
export type IPollingManagerFactoryParams = [
|
|
31
|
-
splitApi: ISplitApi,
|
|
32
|
-
storage: IStorageSync,
|
|
33
|
-
readiness: IReadinessManager,
|
|
34
|
-
settings: ISettings,
|
|
35
|
-
]
|
|
@@ -23,6 +23,7 @@ export function mySegmentsUpdaterFactory(
|
|
|
23
23
|
segmentsEventEmitter: ISegmentsEventEmitter,
|
|
24
24
|
requestTimeoutBeforeReady: number,
|
|
25
25
|
retriesOnFailureBeforeReady: number,
|
|
26
|
+
matchingKey: string
|
|
26
27
|
): IMySegmentsUpdater {
|
|
27
28
|
|
|
28
29
|
let readyOnAlreadyExistentState = true;
|
|
@@ -69,7 +70,7 @@ export function mySegmentsUpdaterFactory(
|
|
|
69
70
|
// If segmentsData is provided, there is no need to fetch mySegments
|
|
70
71
|
new Promise((res) => { updateSegments(segmentsData); res(true); }) :
|
|
71
72
|
// If not provided, fetch mySegments
|
|
72
|
-
mySegmentsFetcher(noCache, _promiseDecorator).then(segments => {
|
|
73
|
+
mySegmentsFetcher(matchingKey, noCache, _promiseDecorator).then(segments => {
|
|
73
74
|
// Only when we have downloaded segments completely, we should not keep retrying anymore
|
|
74
75
|
startingUp = false;
|
|
75
76
|
|
|
@@ -17,8 +17,7 @@ export function authenticateFactory(fetchAuth: IFetchAuth): IAuthenticate {
|
|
|
17
17
|
* @param {string[] | undefined} userKeys set of user Keys to track MY_SEGMENTS_CHANGES. It is undefined for server-side API.
|
|
18
18
|
*/
|
|
19
19
|
return function authenticate(userKeys?: string[]): Promise<IAuthToken> {
|
|
20
|
-
|
|
21
|
-
return authPromise
|
|
20
|
+
return fetchAuth(userKeys)
|
|
22
21
|
.then(resp => resp.json())
|
|
23
22
|
.then(json => {
|
|
24
23
|
if (json.token) { // empty token when `"pushEnabled": false`
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IEventSourceConstructor } from '../../../services/types';
|
|
2
2
|
import { ISettings } from '../../../types';
|
|
3
|
+
import { isString } from '../../../utils/lang';
|
|
3
4
|
import { IAuthTokenPushEnabled } from '../AuthClient/types';
|
|
4
5
|
import { ISSEClient, ISseEventHandler } from './types';
|
|
5
6
|
|
|
@@ -15,7 +16,7 @@ const CONTROL_CHANNEL_REGEX = /^control_/;
|
|
|
15
16
|
*/
|
|
16
17
|
function buildSSEHeaders(settings: ISettings) {
|
|
17
18
|
const headers: Record<string, string> = {
|
|
18
|
-
SplitSDKClientKey: settings.core.authorizationKey.slice(-4),
|
|
19
|
+
SplitSDKClientKey: isString(settings.core.authorizationKey) ? settings.core.authorizationKey.slice(-4) : '',
|
|
19
20
|
SplitSDKVersion: settings.version,
|
|
20
21
|
};
|
|
21
22
|
|
|
@@ -19,7 +19,7 @@ export class SegmentsUpdateWorker implements IUpdateWorker {
|
|
|
19
19
|
* @param {Object} segmentsCache segments data cache
|
|
20
20
|
* @param {Object} segmentsSyncTask task for syncing segments data
|
|
21
21
|
*/
|
|
22
|
-
constructor(
|
|
22
|
+
constructor(segmentsSyncTask: ISegmentsSyncTask, segmentsCache: ISegmentsCacheSync) {
|
|
23
23
|
this.segmentsCache = segmentsCache;
|
|
24
24
|
this.segmentsSyncTask = segmentsSyncTask;
|
|
25
25
|
this.maxChangeNumbers = {};
|