@splitsoftware/splitio-commons 1.0.1-rc.4 → 1.1.1-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.txt +13 -3
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/cjs/evaluator/Engine.js +6 -5
- package/cjs/evaluator/combiners/and.js +4 -4
- package/cjs/evaluator/combiners/ifelseif.js +4 -3
- package/cjs/evaluator/condition/index.js +4 -3
- package/cjs/evaluator/index.js +10 -11
- package/cjs/evaluator/matchers/all.js +2 -1
- package/cjs/evaluator/matchers/between.js +2 -1
- package/cjs/evaluator/matchers/boolean.js +2 -1
- package/cjs/evaluator/matchers/cont_all.js +3 -2
- package/cjs/evaluator/matchers/cont_any.js +3 -2
- package/cjs/evaluator/matchers/cont_str.js +2 -1
- package/cjs/evaluator/matchers/dependency.js +4 -4
- package/cjs/evaluator/matchers/eq.js +2 -1
- package/cjs/evaluator/matchers/eq_set.js +2 -1
- package/cjs/evaluator/matchers/ew.js +2 -1
- package/cjs/evaluator/matchers/gte.js +2 -1
- package/cjs/evaluator/matchers/index.js +36 -36
- package/cjs/evaluator/matchers/lte.js +2 -1
- package/cjs/evaluator/matchers/part_of.js +3 -2
- package/cjs/evaluator/matchers/segment.js +5 -5
- package/cjs/evaluator/matchers/string.js +2 -1
- package/cjs/evaluator/matchers/sw.js +2 -1
- package/cjs/evaluator/matchers/whitelist.js +2 -1
- package/cjs/evaluator/matchersTransform/index.js +12 -12
- package/cjs/evaluator/matchersTransform/segment.js +3 -2
- package/cjs/evaluator/matchersTransform/set.js +3 -2
- package/cjs/evaluator/matchersTransform/unaryNumeric.js +3 -2
- package/cjs/evaluator/matchersTransform/whitelist.js +3 -2
- package/cjs/evaluator/parser/index.js +16 -16
- package/cjs/evaluator/treatments/index.js +2 -1
- package/cjs/evaluator/value/index.js +5 -5
- package/cjs/evaluator/value/sanitize.js +2 -1
- package/cjs/integrations/browser.js +4 -4
- package/cjs/integrations/ga/GaToSplit.js +3 -4
- package/cjs/integrations/pluggable.js +3 -2
- package/cjs/listeners/browser.js +4 -4
- package/cjs/listeners/node.js +4 -4
- package/cjs/logger/index.js +2 -3
- package/cjs/logger/messages/info.js +1 -1
- package/cjs/logger/messages/warn.js +2 -2
- package/cjs/readiness/readinessManager.js +3 -4
- package/cjs/readiness/sdkReadinessManager.js +7 -7
- package/cjs/sdkClient/client.js +5 -5
- package/cjs/sdkClient/clientAttributesDecoration.js +108 -0
- package/cjs/sdkClient/clientCS.js +12 -10
- package/cjs/sdkClient/clientInputValidation.js +5 -5
- package/cjs/sdkClient/sdkClient.js +5 -6
- package/cjs/sdkClient/sdkClientMethodCS.js +4 -5
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +4 -5
- package/cjs/sdkFactory/index.js +9 -10
- package/cjs/sdkManager/index.js +6 -7
- package/cjs/services/splitApi.js +2 -3
- package/cjs/services/splitHttpClient.js +3 -4
- package/cjs/storages/AbstractSegmentsCacheSync.js +2 -1
- package/cjs/storages/AbstractSplitsCacheAsync.js +2 -1
- package/cjs/storages/AbstractSplitsCacheSync.js +2 -2
- package/cjs/storages/KeyBuilder.js +2 -2
- package/cjs/storages/KeyBuilderCS.js +4 -3
- package/cjs/storages/KeyBuilderSS.js +4 -3
- package/cjs/storages/findLatencyIndex.js +2 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +4 -3
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +4 -3
- package/cjs/storages/inLocalStorage/index.js +20 -21
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +70 -0
- package/cjs/storages/inMemory/CountsCacheInMemory.js +2 -1
- package/cjs/storages/inMemory/EventsCacheInMemory.js +2 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +2 -1
- package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +2 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +10 -11
- package/cjs/storages/inMemory/InMemoryStorageCS.js +12 -13
- package/cjs/storages/inMemory/LatenciesCacheInMemory.js +4 -4
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +4 -3
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +4 -3
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +4 -3
- package/cjs/storages/inRedis/CountsCacheInRedis.js +2 -1
- package/cjs/storages/inRedis/EventsCacheInRedis.js +2 -1
- package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +2 -1
- package/cjs/storages/inRedis/LatenciesCacheInRedis.js +4 -4
- package/cjs/storages/inRedis/RedisAdapter.js +6 -5
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +2 -1
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +4 -3
- package/cjs/storages/inRedis/index.js +16 -17
- package/cjs/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/cjs/storages/pluggable/index.js +8 -8
- package/cjs/sync/offline/splitsParser/parseCondition.js +2 -1
- package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +3 -3
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +2 -3
- package/cjs/sync/offline/syncManagerOffline.js +3 -4
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +4 -5
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -1
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +2 -1
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +2 -1
- package/cjs/sync/polling/pollingManagerCS.js +6 -6
- package/cjs/sync/polling/pollingManagerSS.js +8 -8
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +5 -5
- package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +5 -5
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +5 -5
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +2 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -3
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +8 -6
- package/cjs/sync/streaming/AuthClient/index.js +2 -3
- package/cjs/sync/streaming/SSEClient/index.js +2 -1
- package/cjs/sync/streaming/SSEHandler/NotificationKeeper.js +2 -1
- package/cjs/sync/streaming/SSEHandler/index.js +4 -4
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +4 -4
- package/cjs/sync/streaming/pushManager.js +18 -17
- package/cjs/sync/submitters/submitterSyncTask.js +2 -3
- package/cjs/sync/syncTask.js +2 -1
- package/cjs/trackers/eventTracker.js +7 -7
- package/cjs/trackers/impressionObserver/ImpressionObserver.js +4 -4
- package/cjs/trackers/impressionObserver/impressionObserverCS.js +2 -3
- package/cjs/trackers/impressionObserver/impressionObserverSS.js +2 -3
- package/cjs/trackers/impressionsTracker.js +6 -6
- package/cjs/utils/Backoff.js +2 -1
- package/cjs/utils/LRUCache/index.js +2 -1
- package/cjs/utils/MinEventEmitter.js +2 -1
- package/cjs/utils/MinEvents.js +13 -15
- package/cjs/utils/inputValidation/attribute.js +20 -0
- package/cjs/utils/inputValidation/attributes.js +13 -1
- package/cjs/utils/inputValidation/trafficTypeExistance.js +2 -3
- package/cjs/utils/lang/binarySearch.js +2 -1
- package/cjs/utils/lang/objectAssign.js +85 -0
- package/cjs/utils/promise/thenable.js +5 -1
- package/cjs/utils/promise/timeout.js +2 -1
- package/cjs/utils/promise/wrapper.js +2 -1
- package/cjs/utils/settingsValidation/impressionsMode.js +2 -1
- package/cjs/utils/settingsValidation/index.js +5 -6
- package/cjs/utils/settingsValidation/mode.js +2 -1
- package/cjs/utils/timeTracker/index.js +7 -8
- package/cjs/utils/timeTracker/now/browser.js +2 -2
- package/cjs/utils/timeTracker/now/node.js +2 -1
- package/cjs/utils/timeTracker/timer.js +3 -2
- package/esm/evaluator/Engine.js +3 -3
- package/esm/evaluator/combiners/and.js +2 -2
- package/esm/evaluator/combiners/ifelseif.js +2 -2
- package/esm/evaluator/condition/index.js +2 -2
- package/esm/evaluator/index.js +5 -6
- package/esm/evaluator/matchers/all.js +1 -1
- package/esm/evaluator/matchers/between.js +1 -1
- package/esm/evaluator/matchers/boolean.js +1 -1
- package/esm/evaluator/matchers/cont_all.js +1 -1
- package/esm/evaluator/matchers/cont_any.js +1 -1
- package/esm/evaluator/matchers/cont_str.js +1 -1
- package/esm/evaluator/matchers/dependency.js +2 -2
- package/esm/evaluator/matchers/eq.js +1 -1
- package/esm/evaluator/matchers/eq_set.js +1 -1
- package/esm/evaluator/matchers/ew.js +1 -1
- package/esm/evaluator/matchers/gte.js +1 -1
- package/esm/evaluator/matchers/index.js +35 -35
- package/esm/evaluator/matchers/lte.js +1 -1
- package/esm/evaluator/matchers/part_of.js +1 -1
- package/esm/evaluator/matchers/segment.js +2 -2
- package/esm/evaluator/matchers/string.js +1 -1
- package/esm/evaluator/matchers/sw.js +1 -1
- package/esm/evaluator/matchers/whitelist.js +1 -1
- package/esm/evaluator/matchersTransform/index.js +5 -5
- package/esm/evaluator/matchersTransform/segment.js +1 -1
- package/esm/evaluator/matchersTransform/set.js +1 -1
- package/esm/evaluator/matchersTransform/unaryNumeric.js +1 -1
- package/esm/evaluator/matchersTransform/whitelist.js +1 -1
- package/esm/evaluator/parser/index.js +11 -11
- package/esm/evaluator/treatments/index.js +1 -1
- package/esm/evaluator/value/index.js +3 -3
- package/esm/evaluator/value/sanitize.js +1 -1
- package/esm/integrations/browser.js +2 -2
- package/esm/integrations/ga/GaToSplit.js +1 -1
- package/esm/integrations/pluggable.js +1 -1
- package/esm/listeners/browser.js +2 -2
- package/esm/listeners/node.js +2 -2
- package/esm/logger/index.js +1 -1
- package/esm/logger/messages/info.js +1 -1
- package/esm/logger/messages/warn.js +2 -2
- package/esm/readiness/readinessManager.js +1 -1
- package/esm/readiness/sdkReadinessManager.js +3 -3
- package/esm/sdkClient/client.js +2 -2
- package/esm/sdkClient/clientAttributesDecoration.js +104 -0
- package/esm/sdkClient/clientCS.js +10 -8
- package/esm/sdkClient/clientInputValidation.js +2 -2
- package/esm/sdkClient/sdkClient.js +3 -3
- package/esm/sdkClient/sdkClientMethodCS.js +4 -4
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +4 -4
- package/esm/sdkFactory/index.js +6 -6
- package/esm/sdkManager/index.js +2 -2
- package/esm/services/splitApi.js +1 -1
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/AbstractSegmentsCacheSync.js +1 -1
- package/esm/storages/AbstractSplitsCacheAsync.js +1 -1
- package/esm/storages/AbstractSplitsCacheSync.js +1 -1
- package/esm/storages/KeyBuilder.js +1 -1
- package/esm/storages/KeyBuilderCS.js +2 -2
- package/esm/storages/KeyBuilderSS.js +2 -2
- package/esm/storages/findLatencyIndex.js +1 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +2 -2
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +2 -2
- package/esm/storages/inLocalStorage/index.js +8 -8
- package/esm/storages/inMemory/AttributesCacheInMemory.js +67 -0
- package/esm/storages/inMemory/CountsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/EventsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/ImpressionsCacheInMemory.js +1 -1
- package/esm/storages/inMemory/InMemoryStorage.js +5 -5
- package/esm/storages/inMemory/InMemoryStorageCS.js +5 -5
- package/esm/storages/inMemory/LatenciesCacheInMemory.js +2 -2
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +2 -2
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +2 -2
- package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -2
- package/esm/storages/inRedis/CountsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/LatenciesCacheInRedis.js +2 -2
- package/esm/storages/inRedis/RedisAdapter.js +3 -3
- package/esm/storages/inRedis/SegmentsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -2
- package/esm/storages/inRedis/index.js +8 -8
- package/esm/storages/pluggable/SplitsCachePluggable.js +1 -1
- package/esm/storages/pluggable/index.js +4 -4
- package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
- package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
- package/esm/sync/offline/splitsParser/splitsParserFromSettings.js +1 -1
- package/esm/sync/offline/syncManagerOffline.js +2 -2
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +1 -1
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +1 -1
- package/esm/sync/polling/pollingManagerCS.js +3 -3
- package/esm/sync/polling/pollingManagerSS.js +4 -4
- package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +3 -3
- package/esm/sync/polling/syncTasks/segmentsSyncTask.js +3 -3
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +3 -3
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +1 -1
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +7 -4
- package/esm/sync/streaming/AuthClient/index.js +1 -1
- package/esm/sync/streaming/SSEClient/index.js +1 -1
- package/esm/sync/streaming/SSEHandler/NotificationKeeper.js +1 -1
- package/esm/sync/streaming/SSEHandler/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +2 -2
- package/esm/sync/streaming/pushManager.js +10 -9
- package/esm/sync/submitters/submitterSyncTask.js +1 -1
- package/esm/sync/syncTask.js +1 -1
- package/esm/trackers/eventTracker.js +3 -3
- package/esm/trackers/impressionObserver/ImpressionObserver.js +2 -2
- package/esm/trackers/impressionObserver/impressionObserverCS.js +1 -1
- package/esm/trackers/impressionObserver/impressionObserverSS.js +1 -1
- package/esm/trackers/impressionsTracker.js +3 -3
- package/esm/utils/Backoff.js +1 -1
- package/esm/utils/LRUCache/index.js +1 -1
- package/esm/utils/MinEventEmitter.js +1 -1
- package/esm/utils/MinEvents.js +2 -5
- package/esm/utils/inputValidation/attribute.js +16 -0
- package/esm/utils/inputValidation/attributes.js +11 -0
- package/esm/utils/inputValidation/trafficTypeExistance.js +1 -1
- package/esm/utils/lang/binarySearch.js +1 -1
- package/esm/utils/lang/objectAssign.js +82 -0
- package/esm/utils/promise/thenable.js +3 -1
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/promise/wrapper.js +1 -1
- package/esm/utils/settingsValidation/impressionsMode.js +1 -1
- package/esm/utils/settingsValidation/index.js +3 -3
- package/esm/utils/settingsValidation/mode.js +1 -1
- package/esm/utils/timeTracker/index.js +4 -5
- package/esm/utils/timeTracker/now/browser.js +1 -2
- package/esm/utils/timeTracker/now/node.js +1 -1
- package/esm/utils/timeTracker/timer.js +1 -1
- package/package.json +2 -3
- package/src/evaluator/Engine.ts +3 -3
- package/src/evaluator/combiners/and.ts +2 -2
- package/src/evaluator/combiners/ifelseif.ts +2 -2
- package/src/evaluator/condition/index.ts +2 -2
- package/src/evaluator/index.ts +5 -6
- package/src/evaluator/matchers/all.ts +1 -1
- package/src/evaluator/matchers/between.ts +1 -1
- package/src/evaluator/matchers/boolean.ts +1 -1
- package/src/evaluator/matchers/cont_all.ts +1 -1
- package/src/evaluator/matchers/cont_any.ts +1 -1
- package/src/evaluator/matchers/cont_str.ts +1 -1
- package/src/evaluator/matchers/dependency.ts +2 -2
- package/src/evaluator/matchers/eq.ts +1 -1
- package/src/evaluator/matchers/eq_set.ts +1 -1
- package/src/evaluator/matchers/ew.ts +1 -1
- package/src/evaluator/matchers/gte.ts +1 -1
- package/src/evaluator/matchers/index.ts +35 -35
- package/src/evaluator/matchers/lte.ts +1 -1
- package/src/evaluator/matchers/part_of.ts +1 -1
- package/src/evaluator/matchers/segment.ts +2 -2
- package/src/evaluator/matchers/string.ts +1 -1
- package/src/evaluator/matchers/sw.ts +1 -1
- package/src/evaluator/matchers/whitelist.ts +1 -1
- package/src/evaluator/matchersTransform/index.ts +5 -5
- package/src/evaluator/matchersTransform/segment.ts +1 -1
- package/src/evaluator/matchersTransform/set.ts +1 -1
- package/src/evaluator/matchersTransform/unaryNumeric.ts +1 -1
- package/src/evaluator/matchersTransform/whitelist.ts +1 -1
- package/src/evaluator/parser/index.ts +12 -12
- package/src/evaluator/treatments/index.ts +1 -1
- package/src/evaluator/value/index.ts +3 -3
- package/src/evaluator/value/sanitize.ts +1 -1
- package/src/integrations/browser.ts +2 -2
- package/src/integrations/ga/GaToSplit.ts +1 -1
- package/src/integrations/pluggable.ts +1 -1
- package/src/listeners/browser.ts +2 -2
- package/src/listeners/node.ts +2 -2
- package/src/logger/index.ts +1 -1
- package/src/logger/messages/info.ts +1 -1
- package/src/logger/messages/warn.ts +2 -2
- package/src/readiness/readinessManager.ts +2 -2
- package/src/readiness/sdkReadinessManager.ts +3 -3
- package/src/sdkClient/client.ts +2 -2
- package/src/sdkClient/clientAttributesDecoration.ts +122 -0
- package/src/sdkClient/clientCS.ts +13 -8
- package/src/sdkClient/clientInputValidation.ts +2 -2
- package/src/sdkClient/sdkClient.ts +3 -3
- package/src/sdkClient/sdkClientMethodCS.ts +4 -2
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +4 -2
- package/src/sdkFactory/index.ts +6 -6
- package/src/sdkManager/index.ts +2 -2
- package/src/services/splitApi.ts +1 -1
- package/src/services/splitHttpClient.ts +1 -1
- package/src/storages/AbstractSegmentsCacheSync.ts +1 -1
- package/src/storages/AbstractSplitsCacheAsync.ts +1 -1
- package/src/storages/AbstractSplitsCacheSync.ts +1 -1
- package/src/storages/KeyBuilder.ts +1 -1
- package/src/storages/KeyBuilderCS.ts +2 -2
- package/src/storages/KeyBuilderSS.ts +2 -2
- package/src/storages/findLatencyIndex.ts +1 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +3 -3
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +3 -3
- package/src/storages/inLocalStorage/index.ts +8 -8
- package/src/storages/inMemory/AttributesCacheInMemory.ts +73 -0
- package/src/storages/inMemory/CountsCacheInMemory.ts +1 -1
- package/src/storages/inMemory/EventsCacheInMemory.ts +1 -1
- package/src/storages/inMemory/ImpressionCountsCacheInMemory.ts +1 -1
- package/src/storages/inMemory/ImpressionsCacheInMemory.ts +1 -1
- package/src/storages/inMemory/InMemoryStorage.ts +5 -5
- package/src/storages/inMemory/InMemoryStorageCS.ts +5 -5
- package/src/storages/inMemory/LatenciesCacheInMemory.ts +2 -2
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +2 -2
- package/src/storages/inMemory/SplitsCacheInMemory.ts +2 -2
- package/src/storages/inRedis/CountsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/EventsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/ImpressionsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/LatenciesCacheInRedis.ts +3 -3
- package/src/storages/inRedis/RedisAdapter.ts +3 -3
- package/src/storages/inRedis/SegmentsCacheInRedis.ts +2 -2
- package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
- package/src/storages/inRedis/index.ts +8 -8
- package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +2 -2
- package/src/storages/pluggable/index.ts +4 -4
- package/src/storages/types.ts +2 -2
- package/src/sync/offline/splitsParser/parseCondition.ts +1 -1
- package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +1 -1
- package/src/sync/offline/syncManagerOffline.ts +2 -2
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +2 -2
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +1 -1
- package/src/sync/polling/fetchers/segmentChangesFetcher.ts +1 -1
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +1 -1
- package/src/sync/polling/pollingManagerCS.ts +3 -3
- package/src/sync/polling/pollingManagerSS.ts +4 -4
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +3 -3
- package/src/sync/polling/syncTasks/segmentsSyncTask.ts +3 -3
- package/src/sync/polling/syncTasks/splitsSyncTask.ts +3 -3
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +1 -1
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +6 -3
- package/src/sync/streaming/AuthClient/index.ts +1 -1
- package/src/sync/streaming/SSEClient/index.ts +1 -1
- package/src/sync/streaming/SSEHandler/NotificationKeeper.ts +1 -1
- package/src/sync/streaming/SSEHandler/index.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +2 -2
- package/src/sync/streaming/UpdateWorkers/types.ts +1 -1
- package/src/sync/streaming/pushManager.ts +10 -9
- package/src/sync/submitters/submitterSyncTask.ts +1 -1
- package/src/sync/syncTask.ts +1 -1
- package/src/trackers/eventTracker.ts +3 -3
- package/src/trackers/impressionObserver/ImpressionObserver.ts +2 -2
- package/src/trackers/impressionObserver/impressionObserverCS.ts +1 -1
- package/src/trackers/impressionObserver/impressionObserverSS.ts +1 -1
- package/src/trackers/impressionsTracker.ts +3 -3
- package/src/types.ts +39 -0
- package/src/utils/Backoff.ts +1 -1
- package/src/utils/LRUCache/index.ts +1 -1
- package/src/utils/MinEventEmitter.ts +1 -1
- package/src/utils/MinEvents.ts +2 -7
- package/src/utils/inputValidation/attribute.ts +21 -0
- package/src/utils/inputValidation/attributes.ts +14 -0
- package/src/utils/inputValidation/trafficTypeExistance.ts +1 -1
- package/src/utils/lang/binarySearch.ts +1 -1
- package/src/utils/lang/objectAssign.ts +104 -0
- package/src/utils/promise/thenable.ts +3 -1
- package/src/utils/promise/timeout.ts +1 -1
- package/src/utils/promise/wrapper.ts +1 -1
- package/src/utils/settingsValidation/impressionsMode.ts +1 -1
- package/src/utils/settingsValidation/index.ts +3 -3
- package/src/utils/settingsValidation/mode.ts +1 -1
- package/src/utils/timeTracker/index.ts +4 -6
- package/src/utils/timeTracker/now/browser.ts +1 -3
- package/src/utils/timeTracker/now/node.ts +1 -1
- package/src/utils/timeTracker/timer.ts +1 -1
- package/types/evaluator/Engine.d.ts +1 -1
- package/types/evaluator/combiners/and.d.ts +1 -1
- package/types/evaluator/combiners/ifelseif.d.ts +1 -1
- package/types/evaluator/condition/index.d.ts +1 -1
- package/types/evaluator/matchers/all.d.ts +1 -1
- package/types/evaluator/matchers/between.d.ts +1 -1
- package/types/evaluator/matchers/boolean.d.ts +1 -1
- package/types/evaluator/matchers/cont_all.d.ts +1 -1
- package/types/evaluator/matchers/cont_any.d.ts +1 -1
- package/types/evaluator/matchers/cont_str.d.ts +1 -1
- package/types/evaluator/matchers/dependency.d.ts +1 -1
- package/types/evaluator/matchers/eq.d.ts +1 -1
- package/types/evaluator/matchers/eq_set.d.ts +1 -1
- package/types/evaluator/matchers/ew.d.ts +1 -1
- package/types/evaluator/matchers/gte.d.ts +1 -1
- package/types/evaluator/matchers/index.d.ts +1 -1
- package/types/evaluator/matchers/lte.d.ts +1 -1
- package/types/evaluator/matchers/part_of.d.ts +1 -1
- package/types/evaluator/matchers/segment.d.ts +1 -1
- package/types/evaluator/matchers/string.d.ts +1 -1
- package/types/evaluator/matchers/sw.d.ts +1 -1
- package/types/evaluator/matchers/whitelist.d.ts +1 -1
- package/types/evaluator/matchersTransform/index.d.ts +1 -1
- package/types/evaluator/matchersTransform/segment.d.ts +1 -1
- package/types/evaluator/matchersTransform/set.d.ts +1 -1
- package/types/evaluator/matchersTransform/unaryNumeric.d.ts +1 -1
- package/types/evaluator/matchersTransform/whitelist.d.ts +1 -1
- package/types/evaluator/parser/index.d.ts +1 -1
- package/types/evaluator/treatments/index.d.ts +1 -1
- package/types/evaluator/value/index.d.ts +1 -1
- package/types/evaluator/value/sanitize.d.ts +1 -1
- package/types/integrations/browser.d.ts +1 -1
- package/types/integrations/pluggable.d.ts +1 -1
- package/types/listeners/browser.d.ts +1 -1
- package/types/listeners/node.d.ts +1 -1
- 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/readiness/sdkReadinessManager.d.ts +1 -1
- package/types/sdkClient/client.d.ts +1 -1
- package/types/sdkClient/clientAttributesDecoration.d.ts +51 -0
- package/types/sdkClient/clientCS.d.ts +2 -1
- package/types/sdkClient/clientInputValidation.d.ts +1 -1
- package/types/storages/AbstractSegmentsCacheSync.d.ts +1 -1
- package/types/storages/AbstractSplitsCacheAsync.d.ts +1 -1
- package/types/storages/AbstractSplitsCacheSync.d.ts +1 -1
- package/types/storages/KeyBuilder.d.ts +1 -1
- package/types/storages/KeyBuilderCS.d.ts +2 -2
- package/types/storages/KeyBuilderSS.d.ts +2 -2
- package/types/storages/findLatencyIndex.d.ts +1 -1
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +3 -3
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +3 -3
- package/types/storages/inMemory/AttributesCacheInMemory.d.ts +43 -0
- package/types/storages/inMemory/CountsCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/EventsCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +1 -1
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +2 -2
- package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +2 -2
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +2 -2
- package/types/storages/inRedis/CountsCacheInRedis.d.ts +2 -2
- package/types/storages/inRedis/EventsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +2 -2
- package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +2 -2
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +3 -3
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +2 -2
- package/types/storages/types.d.ts +2 -2
- package/types/sync/offline/splitsParser/parseCondition.d.ts +1 -1
- package/types/sync/offline/syncTasks/fromObjectSyncTask.d.ts +1 -1
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +1 -1
- package/types/sync/polling/fetchers/segmentChangesFetcher.d.ts +1 -1
- package/types/sync/polling/fetchers/splitChangesFetcher.d.ts +1 -1
- package/types/sync/polling/pollingManagerCS.d.ts +1 -1
- package/types/sync/polling/pollingManagerSS.d.ts +1 -1
- package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +1 -1
- package/types/sync/polling/syncTasks/segmentsSyncTask.d.ts +1 -1
- package/types/sync/polling/syncTasks/splitsSyncTask.d.ts +1 -1
- package/types/sync/streaming/SSEClient/index.d.ts +1 -1
- package/types/sync/streaming/SSEHandler/NotificationKeeper.d.ts +1 -1
- package/types/sync/streaming/SSEHandler/index.d.ts +1 -1
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +2 -2
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +2 -2
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +2 -2
- package/types/sync/streaming/UpdateWorkers/types.d.ts +1 -1
- package/types/sync/streaming/pushManager.d.ts +1 -1
- package/types/sync/syncTask.d.ts +1 -1
- package/types/trackers/eventTracker.d.ts +1 -1
- package/types/trackers/impressionObserver/ImpressionObserver.d.ts +1 -1
- package/types/trackers/impressionObserver/impressionObserverCS.d.ts +1 -1
- package/types/trackers/impressionObserver/impressionObserverSS.d.ts +1 -1
- package/types/trackers/impressionsTracker.d.ts +1 -1
- package/types/types.d.ts +39 -0
- package/types/utils/Backoff.d.ts +1 -1
- package/types/utils/LRUCache/index.d.ts +1 -1
- package/types/utils/MinEventEmitter.d.ts +1 -1
- package/types/utils/MinEvents.d.ts +3 -2
- package/types/utils/inputValidation/attribute.d.ts +2 -0
- package/types/utils/inputValidation/attributes.d.ts +1 -0
- package/types/utils/lang/binarySearch.d.ts +1 -1
- package/types/utils/lang/objectAssign.d.ts +3 -0
- package/types/utils/promise/thenable.d.ts +1 -2
- package/types/utils/promise/timeout.d.ts +1 -1
- package/types/utils/promise/wrapper.d.ts +1 -1
- package/types/utils/settingsValidation/impressionsMode.d.ts +1 -1
- package/types/utils/settingsValidation/mode.d.ts +1 -1
- package/types/utils/timeTracker/index.d.ts +2 -2
- package/types/utils/timeTracker/now/browser.d.ts +1 -2
- package/types/utils/timeTracker/now/node.d.ts +1 -1
- package/types/utils/timeTracker/timer.d.ts +1 -1
- package/src/logger/.DS_Store +0 -0
- package/types/integrations/ga/GaToSplitPlugin.d.ts +0 -3
- package/types/integrations/ga/SplitToGaPlugin.d.ts +0 -4
- package/types/logger/codes.d.ts +0 -2
- package/types/logger/codesConstants.d.ts +0 -117
- package/types/logger/codesConstantsBrowser.d.ts +0 -2
- package/types/logger/codesConstantsNode.d.ts +0 -14
- package/types/logger/codesDebug.d.ts +0 -1
- package/types/logger/codesDebugBrowser.d.ts +0 -1
- package/types/logger/codesDebugNode.d.ts +0 -1
- package/types/logger/codesError.d.ts +0 -1
- package/types/logger/codesErrorNode.d.ts +0 -1
- package/types/logger/codesInfo.d.ts +0 -1
- package/types/logger/codesWarn.d.ts +0 -1
- package/types/logger/codesWarnNode.d.ts +0 -1
- package/types/logger/debugLogger.d.ts +0 -2
- package/types/logger/errorLogger.d.ts +0 -2
- package/types/logger/infoLogger.d.ts +0 -2
- package/types/logger/messages/debugBrowser.d.ts +0 -1
- package/types/logger/messages/debugNode.d.ts +0 -1
- package/types/logger/messages/errorNode.d.ts +0 -1
- package/types/logger/messages/warnNode.d.ts +0 -1
- package/types/logger/noopLogger.d.ts +0 -2
- package/types/logger/warnLogger.d.ts +0 -2
- package/types/sdkManager/sdkManagerMethod.d.ts +0 -6
- package/types/storages/getRegisteredSegments.d.ts +0 -10
- package/types/sync/polling/syncTasks/splitsSyncTask.copy.d.ts +0 -35
- package/types/sync/polling/syncTasks/splitsSyncTask.morelikeoriginal.d.ts +0 -35
- package/types/sync/streaming/AuthClient/indexV1.d.ts +0 -12
- package/types/sync/streaming/AuthClient/indexV2.d.ts +0 -8
- package/types/sync/streaming/pushManagerCS.d.ts +0 -12
- package/types/sync/streaming/pushManagerNoUsers.d.ts +0 -13
- package/types/sync/streaming/pushManagerSS.d.ts +0 -11
- package/types/sync/syncManagerFromFile.d.ts +0 -2
- package/types/sync/syncManagerFromObject.d.ts +0 -2
- package/types/sync/syncManagerOffline.d.ts +0 -9
- package/types/utils/lang/errors.d.ts +0 -10
- package/types/utils/murmur3/commons.d.ts +0 -12
- package/types/utils/settingsValidation/buildMetadata.d.ts +0 -3
- package/types/utils/settingsValidation/localhost/index.d.ts +0 -9
- package/types/utils/settingsValidation/logger.d.ts +0 -11
|
@@ -21,9 +21,9 @@ export const codesWarn: [number, string][] = codesError.concat([
|
|
|
21
21
|
[c.WARN_TRIMMING_PROPERTIES, '%s: Event has more than 300 properties. Some of them will be trimmed when processed.'],
|
|
22
22
|
[c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
|
|
23
23
|
[c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
|
|
24
|
-
[c.WARN_NOT_EXISTENT_SPLIT, '%s: split "%s" does not exist in this environment, please double check what splits exist in the web console.'],
|
|
24
|
+
[c.WARN_NOT_EXISTENT_SPLIT, '%s: split "%s" does not exist in this environment, please double check what splits exist in the Split web console.'],
|
|
25
25
|
[c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
|
|
26
|
-
[c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding split in this environment, make sure you\'re tracking your events to a valid traffic type defined in the web console.'],
|
|
26
|
+
[c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding split in this environment, make sure you\'re tracking your events to a valid traffic type defined in the Split web console.'],
|
|
27
27
|
// initialization / settings validation
|
|
28
28
|
[c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS+': %s integration item(s) at settings is invalid. %s'],
|
|
29
29
|
[c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS+': split filters have been configured but will have no effect if mode is not "%s", since synchronization is being deferred to an external tool.'],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import objectAssign from '
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
2
|
import { IEventEmitter } from '../types';
|
|
3
3
|
import { SDK_SPLITS_ARRIVED, SDK_SPLITS_CACHE_LOADED, SDK_SEGMENTS_ARRIVED, SDK_READY_TIMED_OUT, SDK_READY_FROM_CACHE, SDK_UPDATE, SDK_READY } from './constants';
|
|
4
4
|
import { IReadinessEventEmitter, IReadinessManager, ISegmentsEventEmitter, ISplitsEventEmitter } from './types';
|
|
@@ -12,7 +12,7 @@ function splitsEventEmitterFactory(EventEmitter: new () => IEventEmitter): ISpli
|
|
|
12
12
|
// `isSplitKill` condition avoids an edge-case of wrongly emitting SDK_READY if:
|
|
13
13
|
// - `/mySegments` fetch and SPLIT_KILL occurs before `/splitChanges` fetch, and
|
|
14
14
|
// - storage has cached splits (for which case `splitsStorage.killLocally` can return true)
|
|
15
|
-
splitsEventEmitter.on(SDK_SPLITS_ARRIVED, (isSplitKill) => { if (!isSplitKill) splitsEventEmitter.splitsArrived = true; });
|
|
15
|
+
splitsEventEmitter.on(SDK_SPLITS_ARRIVED, (isSplitKill: boolean) => { if (!isSplitKill) splitsEventEmitter.splitsArrived = true; });
|
|
16
16
|
splitsEventEmitter.once(SDK_SPLITS_CACHE_LOADED, () => { splitsEventEmitter.splitsCacheLoaded = true; });
|
|
17
17
|
|
|
18
18
|
return splitsEventEmitter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import objectAssign from '
|
|
2
|
-
import promiseWrapper from '../utils/promise/wrapper';
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
|
+
import { promiseWrapper } from '../utils/promise/wrapper';
|
|
3
3
|
import { readinessManagerFactory } from './readinessManager';
|
|
4
4
|
import { ISdkReadinessManager } from './types';
|
|
5
5
|
import { IEventEmitter } from '../types';
|
|
@@ -19,7 +19,7 @@ const REMOVE_LISTENER_EVENT = 'removeListener';
|
|
|
19
19
|
* by the SDK. It is required to properly log the warning 'No listeners for SDK Readiness detected'
|
|
20
20
|
* @param readinessManager optional readinessManager to use. only used internally for `shared` method
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
22
|
+
export function sdkReadinessManagerFactory(
|
|
23
23
|
log: ILogger,
|
|
24
24
|
EventEmitter: new () => IEventEmitter,
|
|
25
25
|
readyTimeout = 0,
|
package/src/sdkClient/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { evaluateFeature, evaluateFeatures } from '../evaluator';
|
|
2
|
-
import thenable from '../utils/promise/thenable';
|
|
2
|
+
import { thenable } from '../utils/promise/thenable';
|
|
3
3
|
import { getMatching, getBucketing } from '../utils/key';
|
|
4
4
|
import { validateSplitExistance } from '../utils/inputValidation/splitExistance';
|
|
5
5
|
import { validateTrafficTypeExistance } from '../utils/inputValidation/trafficTypeExistance';
|
|
@@ -15,7 +15,7 @@ import { IMPRESSION, IMPRESSION_QUEUEING } from '../logger/constants';
|
|
|
15
15
|
* Creator of base client with getTreatments and track methods.
|
|
16
16
|
*/
|
|
17
17
|
// @TODO missing time tracking to collect telemetry
|
|
18
|
-
export
|
|
18
|
+
export function clientFactory(params: IClientFactoryParams): SplitIO.IClient | SplitIO.IAsyncClient {
|
|
19
19
|
const { sdkReadinessManager: { readinessManager }, storage, settings: { log, mode }, impressionsTracker, eventTracker } = params;
|
|
20
20
|
|
|
21
21
|
function getTreatment(key: SplitIO.SplitKey, splitName: string, attributes: SplitIO.Attributes | undefined, withConfig = false) {
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { AttributesCacheInMemory } from '../storages/inMemory/AttributesCacheInMemory';
|
|
2
|
+
import { validateAttributesDeep } from '../utils/inputValidation/attributes';
|
|
3
|
+
import { SplitIO } from '../types';
|
|
4
|
+
import { ILogger } from '../logger/types';
|
|
5
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Add in memory attributes storage methods and combine them with any attribute received from the getTreatment/s call
|
|
9
|
+
*/
|
|
10
|
+
export function clientAttributesDecoration<TClient extends SplitIO.IClient | SplitIO.IAsyncClient>(log: ILogger, client: TClient) {
|
|
11
|
+
|
|
12
|
+
const attributeStorage = new AttributesCacheInMemory();
|
|
13
|
+
|
|
14
|
+
// Keep a reference to the original methods
|
|
15
|
+
const clientGetTreatment = client.getTreatment;
|
|
16
|
+
const clientGetTreatmentWithConfig = client.getTreatmentWithConfig;
|
|
17
|
+
const clientGetTreatments = client.getTreatments;
|
|
18
|
+
const clientGetTreatmentsWithConfig = client.getTreatmentsWithConfig;
|
|
19
|
+
const clientTrack = client.track;
|
|
20
|
+
|
|
21
|
+
function getTreatment(maybeKey: SplitIO.SplitKey, maybeSplit: string, maybeAttributes?: SplitIO.Attributes) {
|
|
22
|
+
return clientGetTreatment(maybeKey, maybeSplit, combineAttributes(maybeAttributes));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getTreatmentWithConfig(maybeKey: SplitIO.SplitKey, maybeSplit: string, maybeAttributes?: SplitIO.Attributes) {
|
|
26
|
+
return clientGetTreatmentWithConfig(maybeKey, maybeSplit, combineAttributes(maybeAttributes));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getTreatments(maybeKey: SplitIO.SplitKey, maybeSplits: string[], maybeAttributes?: SplitIO.Attributes) {
|
|
30
|
+
return clientGetTreatments(maybeKey, maybeSplits, combineAttributes(maybeAttributes));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getTreatmentsWithConfig(maybeKey: SplitIO.SplitKey, maybeSplits: string[], maybeAttributes?: SplitIO.Attributes) {
|
|
34
|
+
return clientGetTreatmentsWithConfig(maybeKey, maybeSplits, combineAttributes(maybeAttributes));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function track(maybeKey: SplitIO.SplitKey, maybeTT: string, maybeEvent: string, maybeEventValue?: number, maybeProperties?: SplitIO.Properties) {
|
|
38
|
+
return clientTrack(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function combineAttributes(maybeAttributes: SplitIO.Attributes | undefined): SplitIO.Attributes | undefined{
|
|
42
|
+
const storedAttributes = attributeStorage.getAll();
|
|
43
|
+
if (Object.keys(storedAttributes).length > 0) {
|
|
44
|
+
return objectAssign({}, storedAttributes, maybeAttributes);
|
|
45
|
+
}
|
|
46
|
+
return maybeAttributes;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return objectAssign(client, {
|
|
50
|
+
getTreatment: getTreatment,
|
|
51
|
+
getTreatmentWithConfig: getTreatmentWithConfig,
|
|
52
|
+
getTreatments: getTreatments,
|
|
53
|
+
getTreatmentsWithConfig: getTreatmentsWithConfig,
|
|
54
|
+
track: track,
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Add an attribute to client's in memory attributes storage
|
|
58
|
+
*
|
|
59
|
+
* @param {string} attributeName Attrinute name
|
|
60
|
+
* @param {string, number, boolean, list} attributeValue Attribute value
|
|
61
|
+
* @returns {boolean} true if the attribute was stored and false otherways
|
|
62
|
+
*/
|
|
63
|
+
setAttribute(attributeName: string, attributeValue: Object) {
|
|
64
|
+
const attribute: Record<string, Object> = {};
|
|
65
|
+
attribute[attributeName] = attributeValue;
|
|
66
|
+
if (!validateAttributesDeep(log, attribute, 'setAttribute')) return false;
|
|
67
|
+
log.debug(`stored ${attributeValue} for attribute ${attributeName}`);
|
|
68
|
+
return attributeStorage.setAttribute(attributeName, attributeValue);
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns the attribute with the given key
|
|
73
|
+
*
|
|
74
|
+
* @param {string} attributeName Attribute name
|
|
75
|
+
* @returns {Object} Attribute with the given key
|
|
76
|
+
*/
|
|
77
|
+
getAttribute(attributeName: string) {
|
|
78
|
+
log.debug(`retrieved attribute ${attributeName}`);
|
|
79
|
+
return attributeStorage.getAttribute(attributeName + '');
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Add to client's in memory attributes storage the attributes in 'attributes'
|
|
84
|
+
*
|
|
85
|
+
* @param {Object} attributes Object with attributes to store
|
|
86
|
+
* @returns true if attributes were stored an false otherways
|
|
87
|
+
*/
|
|
88
|
+
setAttributes(attributes: Record<string, Object>) {
|
|
89
|
+
if (!validateAttributesDeep(log, attributes, 'setAttributes')) return false;
|
|
90
|
+
return attributeStorage.setAttributes(attributes);
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Return all the attributes stored in client's in memory attributes storage
|
|
95
|
+
*
|
|
96
|
+
* @returns {Object} returns all the stored attributes
|
|
97
|
+
*/
|
|
98
|
+
getAttributes(): Record<string, Object> {
|
|
99
|
+
return attributeStorage.getAll();
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Removes from client's in memory attributes storage the attribute with the given key
|
|
104
|
+
*
|
|
105
|
+
* @param {string} attributeName
|
|
106
|
+
* @returns {boolean} true if attribute was removed and false otherways
|
|
107
|
+
*/
|
|
108
|
+
removeAttribute(attributeName: string) {
|
|
109
|
+
log.debug(`removed attribute ${attributeName}`);
|
|
110
|
+
return attributeStorage.removeAttribute(attributeName + '');
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Remove all the stored attributes in the client's in memory attribute storage
|
|
115
|
+
*/
|
|
116
|
+
clearAttributes() {
|
|
117
|
+
return attributeStorage.clear();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import objectAssign from '
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
|
+
import { ILogger } from '../logger/types';
|
|
2
3
|
import { SplitIO } from '../types';
|
|
4
|
+
import { clientAttributesDecoration } from './clientAttributesDecoration';
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -9,15 +11,18 @@ import { SplitIO } from '../types';
|
|
|
9
11
|
* @param key validated split key
|
|
10
12
|
* @param trafficType validated traffic type
|
|
11
13
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
+
export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: SplitIO.SplitKey, trafficType?: string): SplitIO.ICsClient {
|
|
15
|
+
|
|
16
|
+
let clientCS = clientAttributesDecoration(log, client);
|
|
17
|
+
|
|
18
|
+
return objectAssign(clientCS, {
|
|
14
19
|
// In the client-side API, we bind a key to the client `getTreatment*` methods
|
|
15
|
-
getTreatment:
|
|
16
|
-
getTreatmentWithConfig:
|
|
17
|
-
getTreatments:
|
|
18
|
-
getTreatmentsWithConfig:
|
|
20
|
+
getTreatment: clientCS.getTreatment.bind(clientCS, key),
|
|
21
|
+
getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key),
|
|
22
|
+
getTreatments: clientCS.getTreatments.bind(clientCS, key),
|
|
23
|
+
getTreatmentsWithConfig: clientCS.getTreatmentsWithConfig.bind(clientCS, key),
|
|
19
24
|
|
|
20
25
|
// Key is bound to the `track` method. Same thing happens with trafficType but only if provided
|
|
21
|
-
track: trafficType ?
|
|
26
|
+
track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key)
|
|
22
27
|
}) as SplitIO.ICsClient;
|
|
23
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import objectAssign from '
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
2
|
import {
|
|
3
3
|
validateAttributes,
|
|
4
4
|
validateEvent,
|
|
@@ -22,7 +22,7 @@ import { ILogger } from '../logger/types';
|
|
|
22
22
|
* Decorator that validates the input before actually executing the client methods.
|
|
23
23
|
* We should "guard" the client here, while not polluting the "real" implementation of those methods.
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export function clientInputValidationDecorator<TClient extends SplitIO.IClient | SplitIO.IAsyncClient>(log: ILogger, client: TClient, readinessManager: IReadinessManager, isStorageSync = false): TClient {
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Avoid repeating this validations code
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import objectAssign from '
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
2
|
import { IStatusInterface, SplitIO } from '../types';
|
|
3
3
|
import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE } from '../utils/constants';
|
|
4
4
|
import { releaseApiKey } from '../utils/inputValidation/apiKey';
|
|
5
|
-
import clientFactory from './client';
|
|
6
|
-
import clientInputValidationDecorator from './clientInputValidation';
|
|
5
|
+
import { clientFactory } from './client';
|
|
6
|
+
import { clientInputValidationDecorator } from './clientInputValidation';
|
|
7
7
|
import { ISdkClientFactoryParams } from './types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import clientCSDecorator from './clientCS';
|
|
1
|
+
import { clientCSDecorator } from './clientCS';
|
|
2
2
|
import { ISdkClientFactoryParams } from './types';
|
|
3
3
|
import { SplitIO } from '../types';
|
|
4
4
|
import { validateKey } from '../utils/inputValidation/key';
|
|
5
5
|
import { getMatching, keyParser } from '../utils/key';
|
|
6
6
|
import { sdkClientFactory } from './sdkClient';
|
|
7
7
|
import { ISyncManagerCS } from '../sync/types';
|
|
8
|
-
import objectAssign from '
|
|
8
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
9
9
|
import { RETRIEVE_CLIENT_DEFAULT, NEW_SHARED_CLIENT, RETRIEVE_CLIENT_EXISTING } from '../logger/constants';
|
|
10
10
|
import { SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
11
11
|
|
|
@@ -29,6 +29,7 @@ export function sdkClientMethodCSFactory(params: ISdkClientFactoryParams): (key?
|
|
|
29
29
|
const validKey = validateKey(log, key, method);
|
|
30
30
|
|
|
31
31
|
const mainClientInstance = clientCSDecorator(
|
|
32
|
+
log,
|
|
32
33
|
sdkClientFactory(params) as SplitIO.IClient, // @ts-ignore
|
|
33
34
|
validKey
|
|
34
35
|
);
|
|
@@ -74,6 +75,7 @@ export function sdkClientMethodCSFactory(params: ISdkClientFactoryParams): (key?
|
|
|
74
75
|
// As shared clients reuse all the storage information, we don't need to check here if we
|
|
75
76
|
// will use offline or online mode. We should stick with the original decision.
|
|
76
77
|
clientInstances[instanceId] = clientCSDecorator(
|
|
78
|
+
log,
|
|
77
79
|
sdkClientFactory(objectAssign({}, params, {
|
|
78
80
|
sdkReadinessManager: sharedSdkReadiness,
|
|
79
81
|
storage: sharedStorage || storage,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import clientCSDecorator from './clientCS';
|
|
1
|
+
import { clientCSDecorator } from './clientCS';
|
|
2
2
|
import { ISdkClientFactoryParams } from './types';
|
|
3
3
|
import { SplitIO } from '../types';
|
|
4
4
|
import { validateKey } from '../utils/inputValidation/key';
|
|
@@ -6,7 +6,7 @@ import { validateTrafficType } from '../utils/inputValidation/trafficType';
|
|
|
6
6
|
import { getMatching, keyParser } from '../utils/key';
|
|
7
7
|
import { sdkClientFactory } from './sdkClient';
|
|
8
8
|
import { ISyncManagerCS } from '../sync/types';
|
|
9
|
-
import objectAssign from '
|
|
9
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
10
10
|
import { RETRIEVE_CLIENT_DEFAULT, NEW_SHARED_CLIENT, RETRIEVE_CLIENT_EXISTING } from '../logger/constants';
|
|
11
11
|
import { SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
12
12
|
|
|
@@ -35,6 +35,7 @@ export function sdkClientMethodCSFactory(params: ISdkClientFactoryParams): (key?
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const mainClientInstance = clientCSDecorator(
|
|
38
|
+
log,
|
|
38
39
|
sdkClientFactory(params) as SplitIO.IClient, // @ts-ignore
|
|
39
40
|
validKey,
|
|
40
41
|
validTrafficType
|
|
@@ -88,6 +89,7 @@ export function sdkClientMethodCSFactory(params: ISdkClientFactoryParams): (key?
|
|
|
88
89
|
// As shared clients reuse all the storage information, we don't need to check here if we
|
|
89
90
|
// will use offline or online mode. We should stick with the original decision.
|
|
90
91
|
clientInstances[instanceId] = clientCSDecorator(
|
|
92
|
+
log,
|
|
91
93
|
sdkClientFactory(objectAssign({}, params, {
|
|
92
94
|
sdkReadinessManager: sharedSdkReadiness,
|
|
93
95
|
storage: sharedStorage || storage,
|
package/src/sdkFactory/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ISdkFactoryParams } from './types';
|
|
2
|
-
import sdkReadinessManagerFactory from '../readiness/sdkReadinessManager';
|
|
3
|
-
import impressionsTrackerFactory from '../trackers/impressionsTracker';
|
|
4
|
-
import eventTrackerFactory from '../trackers/eventTracker';
|
|
2
|
+
import { sdkReadinessManagerFactory } from '../readiness/sdkReadinessManager';
|
|
3
|
+
import { impressionsTrackerFactory } from '../trackers/impressionsTracker';
|
|
4
|
+
import { eventTrackerFactory } from '../trackers/eventTracker';
|
|
5
5
|
import { IStorageFactoryParams, IStorageSync } from '../storages/types';
|
|
6
6
|
import { SplitIO } from '../types';
|
|
7
7
|
import { ISplitApi } from '../services/types';
|
|
@@ -43,10 +43,10 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
43
43
|
// ATM, only used by PluggableStorage
|
|
44
44
|
mode: settings.mode,
|
|
45
45
|
|
|
46
|
-
// Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined
|
|
47
|
-
// or only
|
|
46
|
+
// Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined,
|
|
47
|
+
// or partial consumer mode, where it only has submitters, and therefore it doesn't emit readiness events.
|
|
48
48
|
onReadyCb: (error) => {
|
|
49
|
-
if (error) return; //
|
|
49
|
+
if (error) return; // Don't emit SDK_READY if storage failed to connect. Error message is logged by wrapperAdapter
|
|
50
50
|
readinessManager.splits.emit(SDK_SPLITS_ARRIVED);
|
|
51
51
|
readinessManager.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
52
52
|
},
|
package/src/sdkManager/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import objectAssign from '
|
|
2
|
-
import thenable from '../utils/promise/thenable';
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
|
+
import { thenable } from '../utils/promise/thenable';
|
|
3
3
|
import { find } from '../utils/lang';
|
|
4
4
|
import { validateSplit, validateSplitExistance, validateIfNotDestroyed, validateIfOperational } from '../utils/inputValidation';
|
|
5
5
|
import { ISplitsCacheAsync, ISplitsCacheSync } from '../storages/types';
|
package/src/services/splitApi.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { IPlatform } from '../sdkFactory/types';
|
|
|
2
2
|
import { ISettings } from '../types';
|
|
3
3
|
import { splitHttpClientFactory } from './splitHttpClient';
|
|
4
4
|
import { ISplitApi } from './types';
|
|
5
|
-
import objectAssign from '
|
|
5
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
6
6
|
|
|
7
7
|
const noCacheHeaderOptions = { headers: { 'Cache-Control': 'no-cache' } };
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFetch, IRequestOptions, IResponse, ISplitHttpClient } from './types';
|
|
2
|
-
import objectAssign from '
|
|
2
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
3
3
|
import { ERROR_HTTP, ERROR_CLIENT_CANNOT_GET_READY } from '../logger/constants';
|
|
4
4
|
import { ISettings } from '../types';
|
|
5
5
|
|
|
@@ -6,7 +6,7 @@ import { ISegmentsCacheSync } from './types';
|
|
|
6
6
|
* This class provides a skeletal implementation of the ISegmentsCacheSync interface
|
|
7
7
|
* to minimize the effort required to implement this interface.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export abstract class AbstractSegmentsCacheSync implements ISegmentsCacheSync {
|
|
10
10
|
/**
|
|
11
11
|
* For server-side synchronizer: add `segmentKeys` list of keys to `name` segment.
|
|
12
12
|
* For client-side synchronizer: add `name` segment to the cache. `segmentKeys` is undefined.
|
|
@@ -5,7 +5,7 @@ import { ISplit } from '../dtos/types';
|
|
|
5
5
|
* This class provides a skeletal implementation of the ISplitsCacheAsync interface
|
|
6
6
|
* to minimize the effort required to implement this interface.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync {
|
|
9
9
|
|
|
10
10
|
abstract addSplit(name: string, split: string): Promise<boolean>
|
|
11
11
|
abstract addSplits(entries: [string, string][]): Promise<boolean[] | void>
|
|
@@ -5,7 +5,7 @@ import { ISplit } from '../dtos/types';
|
|
|
5
5
|
* This class provides a skeletal implementation of the ISplitsCacheSync interface
|
|
6
6
|
* to minimize the effort required to implement this interface.
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
9
9
|
|
|
10
10
|
abstract addSplit(name: string, split: string): boolean;
|
|
11
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { startsWith } from '../utils/lang';
|
|
2
|
-
import KeyBuilder from './KeyBuilder';
|
|
2
|
+
import { KeyBuilder } from './KeyBuilder';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export class KeyBuilderCS extends KeyBuilder {
|
|
5
5
|
|
|
6
6
|
protected readonly regexSplitsCacheKey: RegExp;
|
|
7
7
|
protected readonly matchingKey: string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import KeyBuilder from './KeyBuilder';
|
|
1
|
+
import { KeyBuilder } from './KeyBuilder';
|
|
2
2
|
import { IMetadata } from '../dtos/types';
|
|
3
3
|
|
|
4
4
|
// NOT USED
|
|
5
5
|
// const everythingAfterCount = /count\.([^/]+)$/;
|
|
6
6
|
// const latencyMetricNameAndBucket = /latency\.([^/]+)\.bucket\.([0-9]+)$/;
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export class KeyBuilderSS extends KeyBuilder {
|
|
9
9
|
|
|
10
10
|
protected readonly metadata: IMetadata;
|
|
11
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNaNNumber } from '../utils/lang';
|
|
2
2
|
|
|
3
3
|
// @TODO add unit tests
|
|
4
|
-
export
|
|
4
|
+
export function findLatencyIndex(latency: number, min = 0, max = 23, base = 1.5): number {
|
|
5
5
|
const index = Math.min(max, Math.max(min, Math.floor(Math.log(latency) / Math.log(base))));
|
|
6
6
|
return isNaNNumber(index) ? 0 : index; // index is NaN if latency is not a positive number
|
|
7
7
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ILogger } from '../../logger/types';
|
|
2
|
-
import AbstractSegmentsCacheSync from '../AbstractSegmentsCacheSync';
|
|
3
|
-
import KeyBuilderCS from '../KeyBuilderCS';
|
|
2
|
+
import { AbstractSegmentsCacheSync } from '../AbstractSegmentsCacheSync';
|
|
3
|
+
import { KeyBuilderCS } from '../KeyBuilderCS';
|
|
4
4
|
import { LOG_PREFIX, DEFINED } from './constants';
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export class MySegmentsCacheInLocal extends AbstractSegmentsCacheSync {
|
|
7
7
|
|
|
8
8
|
private readonly keys: KeyBuilderCS;
|
|
9
9
|
private readonly log: ILogger;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ISplit, ISplitFiltersValidation } from '../../dtos/types';
|
|
2
|
-
import AbstractSplitsCacheSync,
|
|
2
|
+
import { AbstractSplitsCacheSync, usesSegments } from '../AbstractSplitsCacheSync';
|
|
3
3
|
import { isFiniteNumber, toNumber, isNaNNumber } from '../../utils/lang';
|
|
4
|
-
import KeyBuilderCS from '../KeyBuilderCS';
|
|
4
|
+
import { KeyBuilderCS } from '../KeyBuilderCS';
|
|
5
5
|
import { ILogger } from '../../logger/types';
|
|
6
6
|
import { LOG_PREFIX } from './constants';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
12
12
|
|
|
13
13
|
private readonly keys: KeyBuilderCS;
|
|
14
14
|
private readonly splitFiltersValidation: ISplitFiltersValidation;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import ImpressionsCacheInMemory from '../inMemory/ImpressionsCacheInMemory';
|
|
2
|
-
import ImpressionCountsCacheInMemory from '../inMemory/ImpressionCountsCacheInMemory';
|
|
3
|
-
import EventsCacheInMemory from '../inMemory/EventsCacheInMemory';
|
|
1
|
+
import { ImpressionsCacheInMemory } from '../inMemory/ImpressionsCacheInMemory';
|
|
2
|
+
import { ImpressionCountsCacheInMemory } from '../inMemory/ImpressionCountsCacheInMemory';
|
|
3
|
+
import { EventsCacheInMemory } from '../inMemory/EventsCacheInMemory';
|
|
4
4
|
import { IStorageFactoryParams, IStorageSync, IStorageSyncFactory } from '../types';
|
|
5
5
|
import { validatePrefix } from '../KeyBuilder';
|
|
6
|
-
import KeyBuilderCS from '../KeyBuilderCS';
|
|
6
|
+
import { KeyBuilderCS } from '../KeyBuilderCS';
|
|
7
7
|
import { isLocalStorageAvailable } from '../../utils/env/isLocalStorageAvailable';
|
|
8
|
-
import SplitsCacheInLocal from './SplitsCacheInLocal';
|
|
9
|
-
import MySegmentsCacheInLocal from './MySegmentsCacheInLocal';
|
|
10
|
-
import MySegmentsCacheInMemory from '../inMemory/MySegmentsCacheInMemory';
|
|
11
|
-
import SplitsCacheInMemory from '../inMemory/SplitsCacheInMemory';
|
|
8
|
+
import { SplitsCacheInLocal } from './SplitsCacheInLocal';
|
|
9
|
+
import { MySegmentsCacheInLocal } from './MySegmentsCacheInLocal';
|
|
10
|
+
import { MySegmentsCacheInMemory } from '../inMemory/MySegmentsCacheInMemory';
|
|
11
|
+
import { SplitsCacheInMemory } from '../inMemory/SplitsCacheInMemory';
|
|
12
12
|
import { DEFAULT_CACHE_EXPIRATION_IN_MILLIS } from '../../utils/constants/browser';
|
|
13
13
|
import { InMemoryStorageCSFactory } from '../inMemory/InMemoryStorageCS';
|
|
14
14
|
import { LOG_PREFIX } from './constants';
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { objectAssign } from '../../utils/lang/objectAssign';
|
|
2
|
+
|
|
3
|
+
export class AttributesCacheInMemory {
|
|
4
|
+
|
|
5
|
+
private attributesCache: Record<string, Object> = {};
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create or update the value for the given attribute
|
|
10
|
+
*
|
|
11
|
+
* @param {string} attributeName attribute name
|
|
12
|
+
* @param {Object} attributeValue attribute value
|
|
13
|
+
* @returns {boolean} the attribute was stored
|
|
14
|
+
*/
|
|
15
|
+
setAttribute(attributeName: string, attributeValue: Object): boolean {
|
|
16
|
+
this.attributesCache[attributeName] = attributeValue;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the value of a given attribute
|
|
22
|
+
*
|
|
23
|
+
* @param {string} attributeName attribute name
|
|
24
|
+
* @returns {Object?} stored attribute value
|
|
25
|
+
*/
|
|
26
|
+
getAttribute(attributeName: string): Object {
|
|
27
|
+
return this.attributesCache[attributeName];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Create or update all the given attributes
|
|
32
|
+
*
|
|
33
|
+
* @param {[string, Object]} attributes attributes to create or update
|
|
34
|
+
* @returns {boolean} attributes were stored
|
|
35
|
+
*/
|
|
36
|
+
setAttributes(attributes: Record<string, Object>): boolean {
|
|
37
|
+
this.attributesCache = objectAssign(this.attributesCache, attributes);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve the full attributes map
|
|
43
|
+
*
|
|
44
|
+
* @returns {Map<string, Object>} stored attributes
|
|
45
|
+
*/
|
|
46
|
+
getAll(): Record<string, Object> {
|
|
47
|
+
return this.attributesCache;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Removes a given attribute from the map
|
|
52
|
+
*
|
|
53
|
+
* @param {string} attributeName attribute to remove
|
|
54
|
+
* @returns {boolean} attribute removed
|
|
55
|
+
*/
|
|
56
|
+
removeAttribute(attributeName: string): boolean {
|
|
57
|
+
if (Object.keys(this.attributesCache).indexOf(attributeName) >= 0) {
|
|
58
|
+
delete this.attributesCache[attributeName];
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Clears all attributes stored in the SDK
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
68
|
+
clear() {
|
|
69
|
+
this.attributesCache = {};
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}
|
|
@@ -3,7 +3,7 @@ import { IEventsCacheSync } from '../types';
|
|
|
3
3
|
|
|
4
4
|
const MAX_QUEUE_BYTE_SIZE = 5 * 1024 * 1024; // 5M
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export class EventsCacheInMemory implements IEventsCacheSync {
|
|
7
7
|
|
|
8
8
|
private onFullQueue?: () => void;
|
|
9
9
|
private readonly maxQueue: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { truncateTimeFrame } from '../../utils/time';
|
|
2
2
|
import { IImpressionCountsCacheSync } from '../types';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export class ImpressionCountsCacheInMemory implements IImpressionCountsCacheSync {
|
|
5
5
|
private cache: Record<string, number> = {};
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IImpressionsCacheSync } from '../types';
|
|
2
2
|
import { ImpressionDTO } from '../../types';
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export class ImpressionsCacheInMemory implements IImpressionsCacheSync {
|
|
5
5
|
|
|
6
6
|
private queue: ImpressionDTO[] = [];
|
|
7
7
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import SplitsCacheInMemory from './SplitsCacheInMemory';
|
|
2
|
-
import SegmentsCacheInMemory from './SegmentsCacheInMemory';
|
|
3
|
-
import ImpressionsCacheInMemory from './ImpressionsCacheInMemory';
|
|
4
|
-
import EventsCacheInMemory from './EventsCacheInMemory';
|
|
1
|
+
import { SplitsCacheInMemory } from './SplitsCacheInMemory';
|
|
2
|
+
import { SegmentsCacheInMemory } from './SegmentsCacheInMemory';
|
|
3
|
+
import { ImpressionsCacheInMemory } from './ImpressionsCacheInMemory';
|
|
4
|
+
import { EventsCacheInMemory } from './EventsCacheInMemory';
|
|
5
5
|
import { IStorageFactoryParams, IStorageSync } from '../types';
|
|
6
|
-
import ImpressionCountsCacheInMemory from './ImpressionCountsCacheInMemory';
|
|
6
|
+
import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
|
|
7
7
|
import { STORAGE_MEMORY } from '../../utils/constants';
|
|
8
8
|
|
|
9
9
|
/**
|