@splitsoftware/splitio-commons 1.6.2-rc.4 → 1.6.2-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.txt +3 -0
- package/cjs/consent/sdkUserConsent.js +2 -2
- package/cjs/evaluator/index.js +10 -11
- package/cjs/integrations/ga/GaToSplit.js +8 -5
- package/cjs/listeners/browser.js +2 -1
- package/cjs/logger/constants.js +2 -1
- package/cjs/sdkClient/clientAttributesDecoration.js +1 -1
- package/cjs/sdkClient/sdkClient.js +3 -1
- package/cjs/sdkFactory/index.js +28 -8
- package/cjs/sdkManager/index.js +3 -11
- package/cjs/services/splitApi.js +20 -1
- package/cjs/storages/AbstractSplitsCacheAsync.js +7 -9
- package/cjs/storages/AbstractSplitsCacheSync.js +7 -9
- package/cjs/storages/KeyBuilderSS.js +6 -0
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +5 -6
- package/cjs/storages/inLocalStorage/index.js +4 -0
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +12 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +5 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +5 -1
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +7 -10
- package/cjs/storages/inMemory/uniqueKeysCacheInMemory.js +73 -0
- package/cjs/storages/inMemory/uniqueKeysCacheInMemoryCS.js +78 -0
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +49 -0
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +15 -9
- package/cjs/storages/inRedis/constants.js +4 -1
- package/cjs/storages/inRedis/index.js +15 -1
- package/cjs/storages/inRedis/uniqueKeysCacheInRedis.js +56 -0
- package/cjs/storages/pluggable/SplitsCachePluggable.js +14 -9
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +1 -1
- package/cjs/sync/submitters/submitterManager.js +3 -0
- package/cjs/sync/submitters/telemetrySubmitter.js +1 -0
- package/cjs/sync/submitters/uniqueKeysSubmitter.js +26 -0
- package/cjs/trackers/impressionsTracker.js +22 -41
- package/cjs/trackers/strategy/strategyDebug.js +25 -0
- package/cjs/trackers/strategy/strategyNone.js +29 -0
- package/cjs/trackers/strategy/strategyOptimized.js +35 -0
- package/cjs/trackers/telemetryTracker.js +6 -0
- package/cjs/trackers/uniqueKeysTracker.js +38 -0
- package/cjs/types.js +2 -0
- package/cjs/utils/constants/index.js +4 -2
- package/cjs/utils/key/index.js +1 -1
- package/cjs/utils/settingsValidation/impressionsMode.js +2 -2
- package/cjs/utils/settingsValidation/index.js +4 -1
- package/esm/consent/sdkUserConsent.js +2 -2
- package/esm/evaluator/index.js +10 -11
- package/esm/integrations/ga/GaToSplit.js +8 -5
- package/esm/listeners/browser.js +3 -2
- package/esm/logger/constants.js +1 -0
- package/esm/sdkClient/clientAttributesDecoration.js +1 -1
- package/esm/sdkClient/sdkClient.js +3 -1
- package/esm/sdkFactory/index.js +28 -8
- package/esm/sdkManager/index.js +3 -11
- package/esm/services/splitApi.js +20 -1
- package/esm/storages/AbstractSplitsCacheAsync.js +7 -9
- package/esm/storages/AbstractSplitsCacheSync.js +7 -9
- package/esm/storages/KeyBuilderSS.js +6 -0
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +5 -6
- package/esm/storages/inLocalStorage/index.js +5 -1
- package/esm/storages/inMemory/AttributesCacheInMemory.js +1 -1
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +12 -1
- package/esm/storages/inMemory/InMemoryStorage.js +6 -2
- package/esm/storages/inMemory/InMemoryStorageCS.js +6 -2
- package/esm/storages/inMemory/SplitsCacheInMemory.js +7 -10
- package/esm/storages/inMemory/uniqueKeysCacheInMemory.js +70 -0
- package/esm/storages/inMemory/uniqueKeysCacheInMemoryCS.js +75 -0
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +46 -0
- package/esm/storages/inRedis/SplitsCacheInRedis.js +15 -9
- package/esm/storages/inRedis/constants.js +3 -0
- package/esm/storages/inRedis/index.js +16 -2
- package/esm/storages/inRedis/uniqueKeysCacheInRedis.js +53 -0
- package/esm/storages/pluggable/SplitsCachePluggable.js +14 -9
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +2 -3
- package/esm/sync/polling/updaters/splitChangesUpdater.js +1 -1
- package/esm/sync/submitters/submitterManager.js +3 -0
- package/esm/sync/submitters/telemetrySubmitter.js +2 -1
- package/esm/sync/submitters/uniqueKeysSubmitter.js +22 -0
- package/esm/trackers/impressionsTracker.js +22 -41
- package/esm/trackers/strategy/strategyDebug.js +21 -0
- package/esm/trackers/strategy/strategyNone.js +25 -0
- package/esm/trackers/strategy/strategyOptimized.js +31 -0
- package/esm/trackers/telemetryTracker.js +6 -0
- package/esm/trackers/uniqueKeysTracker.js +34 -0
- package/esm/types.js +1 -0
- package/esm/utils/constants/index.js +2 -0
- package/esm/utils/key/index.js +1 -1
- package/esm/utils/settingsValidation/impressionsMode.js +3 -3
- package/esm/utils/settingsValidation/index.js +4 -1
- package/package.json +5 -4
- package/src/consent/sdkUserConsent.ts +5 -6
- package/src/dtos/types.ts +8 -0
- package/src/evaluator/Engine.ts +3 -3
- package/src/evaluator/combiners/and.ts +1 -1
- package/src/evaluator/combiners/ifelseif.ts +3 -3
- package/src/evaluator/condition/engineUtils.ts +1 -1
- package/src/evaluator/condition/index.ts +6 -6
- package/src/evaluator/index.ts +18 -19
- 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 +1 -1
- 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 +1 -1
- package/src/evaluator/matchers/lte.ts +1 -1
- package/src/evaluator/matchers/part_of.ts +1 -1
- package/src/evaluator/matchers/segment.ts +1 -1
- 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/parser/index.ts +3 -3
- package/src/evaluator/types.ts +6 -6
- package/src/evaluator/value/index.ts +4 -4
- package/src/evaluator/value/sanitize.ts +4 -4
- package/src/integrations/ga/GaToSplit.ts +15 -11
- package/src/integrations/ga/SplitToGa.ts +10 -10
- package/src/integrations/ga/types.ts +4 -4
- package/src/integrations/pluggable.ts +3 -3
- package/src/integrations/types.ts +4 -3
- package/src/listeners/browser.ts +3 -2
- package/src/logger/constants.ts +1 -0
- package/src/logger/index.ts +3 -3
- package/src/logger/sdkLogger.ts +2 -1
- package/src/logger/types.ts +16 -0
- package/src/readiness/sdkReadinessManager.ts +1 -1
- package/src/readiness/types.ts +9 -2
- package/src/sdkClient/client.ts +13 -13
- package/src/sdkClient/clientAttributesDecoration.ts +13 -13
- package/src/sdkClient/clientCS.ts +4 -3
- package/src/sdkClient/clientInputValidation.ts +15 -15
- package/src/sdkClient/sdkClient.ts +5 -3
- package/src/sdkClient/sdkClientMethod.ts +2 -2
- package/src/sdkClient/sdkClientMethodCS.ts +9 -9
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +9 -9
- package/src/sdkFactory/index.ts +34 -11
- package/src/sdkFactory/types.ts +11 -8
- package/src/sdkManager/index.ts +7 -16
- package/src/services/splitApi.ts +22 -1
- package/src/services/types.ts +6 -0
- package/src/storages/AbstractSplitsCacheAsync.ts +12 -14
- package/src/storages/AbstractSplitsCacheSync.ts +14 -16
- package/src/storages/KeyBuilderSS.ts +8 -0
- package/src/storages/dataLoader.ts +3 -3
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +10 -12
- package/src/storages/inLocalStorage/index.ts +6 -4
- package/src/storages/inMemory/AttributesCacheInMemory.ts +12 -13
- package/src/storages/inMemory/EventsCacheInMemory.ts +4 -4
- package/src/storages/inMemory/ImpressionCountsCacheInMemory.ts +16 -1
- package/src/storages/inMemory/InMemoryStorage.ts +5 -2
- package/src/storages/inMemory/InMemoryStorageCS.ts +6 -2
- package/src/storages/inMemory/SplitsCacheInMemory.ts +10 -14
- package/src/storages/inMemory/uniqueKeysCacheInMemory.ts +82 -0
- package/src/storages/inMemory/uniqueKeysCacheInMemoryCS.ts +88 -0
- package/src/storages/inRedis/EventsCacheInRedis.ts +4 -4
- package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +51 -0
- package/src/storages/inRedis/ImpressionsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/RedisAdapter.ts +1 -1
- package/src/storages/inRedis/SegmentsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/SplitsCacheInRedis.ts +22 -18
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +1 -1
- package/src/storages/inRedis/constants.ts +3 -0
- package/src/storages/inRedis/index.ts +14 -6
- package/src/storages/inRedis/uniqueKeysCacheInRedis.ts +63 -0
- package/src/storages/pluggable/EventsCachePluggable.ts +4 -4
- package/src/storages/pluggable/ImpressionsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SegmentsCachePluggable.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +21 -18
- package/src/storages/pluggable/TelemetryCachePluggable.ts +1 -1
- package/src/storages/pluggable/index.ts +3 -3
- package/src/storages/pluggable/wrapperAdapter.ts +1 -1
- package/src/storages/types.ts +60 -62
- package/src/sync/offline/LocalhostFromObject.ts +4 -4
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +8 -8
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +5 -6
- 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 +3 -3
- package/src/sync/streaming/SSEHandler/index.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +1 -1
- package/src/sync/submitters/submitter.ts +1 -1
- package/src/sync/submitters/submitterManager.ts +2 -0
- package/src/sync/submitters/telemetrySubmitter.ts +4 -3
- package/src/sync/submitters/types.ts +22 -3
- package/src/sync/submitters/uniqueKeysSubmitter.ts +35 -0
- package/src/sync/syncTask.ts +1 -1
- package/src/trackers/eventTracker.ts +3 -3
- package/src/trackers/impressionsTracker.ts +30 -51
- package/src/trackers/strategy/strategyDebug.ts +28 -0
- package/src/trackers/strategy/strategyNone.ts +34 -0
- package/src/trackers/strategy/strategyOptimized.ts +42 -0
- package/src/trackers/telemetryTracker.ts +7 -2
- package/src/trackers/types.ts +36 -4
- package/src/trackers/uniqueKeysTracker.ts +48 -0
- package/src/types.ts +1267 -0
- package/src/utils/constants/index.ts +3 -1
- package/src/utils/inputValidation/apiKey.ts +1 -1
- package/src/utils/inputValidation/attribute.ts +1 -1
- package/src/utils/inputValidation/attributes.ts +3 -3
- package/src/utils/inputValidation/event.ts +1 -1
- package/src/utils/inputValidation/eventProperties.ts +3 -3
- package/src/utils/inputValidation/eventValue.ts +1 -1
- package/src/utils/inputValidation/isOperational.ts +1 -1
- package/src/utils/inputValidation/key.ts +3 -3
- package/src/utils/inputValidation/preloadedData.ts +3 -3
- package/src/utils/inputValidation/split.ts +1 -1
- package/src/utils/inputValidation/splitExistance.ts +1 -1
- package/src/utils/inputValidation/splits.ts +1 -1
- package/src/utils/inputValidation/trafficType.ts +1 -1
- package/src/utils/inputValidation/trafficTypeExistance.ts +1 -1
- package/src/utils/key/index.ts +9 -9
- package/src/utils/settingsValidation/consent.ts +2 -1
- package/src/utils/settingsValidation/impressionsMode.ts +6 -6
- package/src/utils/settingsValidation/index.ts +5 -1
- package/src/utils/settingsValidation/integrations/common.ts +1 -1
- package/src/utils/settingsValidation/integrations/configurable.ts +1 -1
- package/src/utils/settingsValidation/integrations/pluggable.ts +2 -1
- package/src/utils/settingsValidation/localhost/builtin.ts +2 -1
- package/src/utils/settingsValidation/localhost/pluggable.ts +2 -1
- package/src/utils/settingsValidation/logger/builtinLogger.ts +2 -1
- package/src/utils/settingsValidation/logger/pluggableLogger.ts +2 -1
- package/src/utils/settingsValidation/splitFilters.ts +9 -7
- package/src/utils/settingsValidation/storage/storageCS.ts +2 -1
- package/types/consent/index.d.ts +2 -0
- package/types/consent/sdkUserConsent.d.ts +13 -0
- package/types/dtos/types.d.ts +172 -0
- package/types/evaluator/Engine.d.ts +15 -0
- package/types/evaluator/combiners/and.d.ts +4 -0
- package/types/evaluator/combiners/ifelseif.d.ts +3 -0
- package/types/evaluator/condition/engineUtils.d.ts +11 -0
- package/types/evaluator/condition/index.d.ts +6 -0
- package/types/evaluator/convertions/index.d.ts +2 -0
- package/types/evaluator/index.d.ts +7 -0
- package/types/evaluator/matchers/all.d.ts +2 -0
- package/types/evaluator/matchers/between.d.ts +3 -0
- package/types/evaluator/matchers/boolean.d.ts +2 -0
- package/types/evaluator/matchers/cont_all.d.ts +2 -0
- package/types/evaluator/matchers/cont_any.d.ts +2 -0
- package/types/evaluator/matchers/cont_str.d.ts +2 -0
- package/types/evaluator/matchers/dependency.d.ts +5 -0
- package/types/evaluator/matchers/eq.d.ts +2 -0
- package/types/evaluator/matchers/eq_set.d.ts +2 -0
- package/types/evaluator/matchers/ew.d.ts +2 -0
- package/types/evaluator/matchers/gte.d.ts +2 -0
- package/types/evaluator/matchers/index.d.ts +7 -0
- package/types/evaluator/matchers/lte.d.ts +2 -0
- package/types/evaluator/matchers/matcherTypes.d.ts +10 -0
- package/types/evaluator/matchers/part_of.d.ts +2 -0
- package/types/evaluator/matchers/segment.d.ts +6 -0
- package/types/evaluator/matchers/string.d.ts +2 -0
- package/types/evaluator/matchers/sw.d.ts +2 -0
- package/types/evaluator/matchers/whitelist.d.ts +3 -0
- package/types/evaluator/matchersTransform/index.d.ts +6 -0
- package/types/evaluator/matchersTransform/segment.d.ts +5 -0
- package/types/evaluator/matchersTransform/set.d.ts +5 -0
- package/types/evaluator/matchersTransform/unaryNumeric.d.ts +5 -0
- package/types/evaluator/matchersTransform/whitelist.d.ts +5 -0
- package/types/evaluator/parser/index.d.ts +5 -0
- package/types/evaluator/treatments/index.d.ts +8 -0
- package/types/evaluator/types.d.ts +28 -0
- package/types/evaluator/value/index.d.ts +7 -0
- package/types/evaluator/value/sanitize.d.ts +7 -0
- package/types/index.d.ts +5 -0
- package/types/integrations/browser.d.ts +12 -0
- package/types/integrations/ga/GaToSplit.d.ts +40 -0
- package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +3 -0
- package/types/integrations/ga/SplitToGa.d.ts +34 -0
- package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +3 -0
- package/types/integrations/ga/types.d.ts +148 -0
- package/types/integrations/pluggable.d.ts +11 -0
- package/types/integrations/types.d.ts +18 -0
- package/types/listeners/browser.d.ts +40 -0
- package/types/listeners/node.d.ts +22 -0
- package/types/listeners/types.d.ts +4 -0
- package/types/logger/browser/DebugLogger.d.ts +2 -0
- package/types/logger/browser/ErrorLogger.d.ts +2 -0
- package/types/logger/browser/InfoLogger.d.ts +2 -0
- package/types/logger/browser/WarnLogger.d.ts +2 -0
- package/types/logger/constants.d.ts +142 -0
- package/types/logger/index.d.ts +22 -0
- package/types/logger/messages/debug.d.ts +1 -0
- package/types/logger/messages/error.d.ts +1 -0
- package/types/logger/messages/info.d.ts +1 -0
- package/types/logger/messages/warn.d.ts +1 -0
- package/types/logger/sdkLogger.d.ts +8 -0
- package/types/logger/types.d.ts +17 -0
- package/types/readiness/constants.d.ts +7 -0
- package/types/readiness/readinessManager.d.ts +6 -0
- package/types/readiness/sdkReadinessManager.d.ts +11 -0
- package/types/readiness/types.d.ts +60 -0
- package/types/sdkClient/client.d.ts +6 -0
- package/types/sdkClient/clientAttributesDecoration.d.ts +51 -0
- package/types/sdkClient/clientCS.d.ts +10 -0
- package/types/sdkClient/clientInputValidation.d.ts +7 -0
- package/types/sdkClient/sdkClient.d.ts +6 -0
- package/types/sdkClient/sdkClientMethod.d.ts +6 -0
- package/types/sdkClient/sdkClientMethodCS.d.ts +7 -0
- package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +8 -0
- package/types/sdkClient/types.d.ts +18 -0
- package/types/sdkFactory/index.d.ts +6 -0
- package/types/sdkFactory/types.d.ts +82 -0
- package/types/sdkManager/index.d.ts +5 -0
- package/types/services/splitApi.d.ts +11 -0
- package/types/services/splitHttpClient.d.ts +10 -0
- package/types/services/types.d.ts +54 -0
- package/types/storages/AbstractSegmentsCacheSync.d.ts +55 -0
- package/types/storages/AbstractSplitsCacheAsync.d.ts +37 -0
- package/types/storages/AbstractSplitsCacheSync.d.ts +42 -0
- package/types/storages/KeyBuilder.d.ts +14 -0
- package/types/storages/KeyBuilderCS.d.ts +16 -0
- package/types/storages/KeyBuilderSS.d.ts +17 -0
- package/types/storages/dataLoader.d.ts +10 -0
- package/types/storages/findLatencyIndex.d.ts +7 -0
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +25 -0
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +51 -0
- package/types/storages/inLocalStorage/constants.d.ts +2 -0
- package/types/storages/inLocalStorage/index.d.ts +8 -0
- package/types/storages/inMemory/AttributesCacheInMemory.d.ts +43 -0
- package/types/storages/inMemory/CountsCacheInMemory.d.ts +20 -0
- package/types/storages/inMemory/EventsCacheInMemory.d.ts +35 -0
- package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +28 -0
- package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +30 -0
- package/types/storages/inMemory/InMemoryStorage.d.ts +10 -0
- package/types/storages/inMemory/InMemoryStorageCS.d.ts +10 -0
- package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +20 -0
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +22 -0
- package/types/storages/inMemory/SegmentsCacheInMemory.d.ts +19 -0
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +21 -0
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +53 -0
- package/types/storages/inMemory/uniqueKeysCacheInMemory.d.ts +35 -0
- package/types/storages/inMemory/uniqueKeysCacheInMemoryCS.d.ts +37 -0
- package/types/storages/inRedis/CountsCacheInRedis.d.ts +9 -0
- package/types/storages/inRedis/EventsCacheInRedis.d.ts +32 -0
- package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +14 -0
- package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +18 -0
- package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +9 -0
- package/types/storages/inRedis/RedisAdapter.d.ts +24 -0
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +18 -0
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +92 -0
- package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +20 -0
- package/types/storages/inRedis/constants.d.ts +4 -0
- package/types/storages/inRedis/index.d.ts +10 -0
- package/types/storages/inRedis/uniqueKeysCacheInRedis.d.ts +15 -0
- package/types/storages/metadataBuilder.d.ts +3 -0
- package/types/storages/pluggable/EventsCachePluggable.d.ts +38 -0
- package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +35 -0
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +54 -0
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +90 -0
- package/types/storages/pluggable/TelemetryCachePluggable.d.ts +18 -0
- package/types/storages/pluggable/constants.d.ts +1 -0
- package/types/storages/pluggable/inMemoryWrapper.d.ts +13 -0
- package/types/storages/pluggable/index.d.ts +9 -0
- package/types/storages/pluggable/wrapperAdapter.d.ts +12 -0
- package/types/storages/types.d.ts +417 -0
- package/types/sync/offline/LocalhostFromFile.d.ts +2 -0
- package/types/sync/offline/LocalhostFromObject.d.ts +2 -0
- package/types/sync/offline/splitsParser/parseCondition.d.ts +7 -0
- package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +2 -0
- package/types/sync/offline/splitsParser/splitsParserFromSettings.d.ts +3 -0
- package/types/sync/offline/splitsParser/types.d.ts +3 -0
- package/types/sync/offline/syncManagerOffline.d.ts +10 -0
- package/types/sync/offline/syncTasks/fromObjectSyncTask.d.ts +17 -0
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +7 -0
- package/types/sync/polling/fetchers/segmentChangesFetcher.d.ts +7 -0
- package/types/sync/polling/fetchers/splitChangesFetcher.d.ts +7 -0
- package/types/sync/polling/fetchers/types.d.ts +5 -0
- package/types/sync/polling/pollingManagerCS.d.ts +7 -0
- package/types/sync/polling/pollingManagerSS.d.ts +6 -0
- package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +9 -0
- package/types/sync/polling/syncTasks/segmentsSyncTask.d.ts +9 -0
- package/types/sync/polling/syncTasks/splitsSyncTask.d.ts +9 -0
- package/types/sync/polling/types.d.ts +26 -0
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +13 -0
- package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +18 -0
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +39 -0
- package/types/sync/streaming/AuthClient/index.d.ts +12 -0
- package/types/sync/streaming/AuthClient/types.d.ts +17 -0
- package/types/sync/streaming/SSEClient/index.d.ts +34 -0
- package/types/sync/streaming/SSEClient/types.d.ts +11 -0
- package/types/sync/streaming/SSEHandler/NotificationKeeper.d.ts +14 -0
- package/types/sync/streaming/SSEHandler/NotificationParser.d.ts +20 -0
- package/types/sync/streaming/SSEHandler/index.d.ts +11 -0
- package/types/sync/streaming/SSEHandler/types.d.ts +67 -0
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +6 -0
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +8 -0
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +12 -0
- package/types/sync/streaming/UpdateWorkers/constants.d.ts +3 -0
- package/types/sync/streaming/UpdateWorkers/types.d.ts +4 -0
- package/types/sync/streaming/constants.d.ts +34 -0
- package/types/sync/streaming/mySegmentsV2utils.d.ts +27 -0
- package/types/sync/streaming/pushManager.d.ts +9 -0
- package/types/sync/streaming/types.d.ts +35 -0
- package/types/sync/submitters/eventsSubmitter.d.ts +5 -0
- package/types/sync/submitters/eventsSyncTask.d.ts +8 -0
- package/types/sync/submitters/impressionCountsSubmitter.d.ts +10 -0
- package/types/sync/submitters/impressionCountsSubmitterInRedis.d.ts +5 -0
- package/types/sync/submitters/impressionCountsSyncTask.d.ts +13 -0
- package/types/sync/submitters/impressionsSubmitter.d.ts +11 -0
- package/types/sync/submitters/impressionsSyncTask.d.ts +14 -0
- package/types/sync/submitters/metricsSyncTask.d.ts +12 -0
- package/types/sync/submitters/submitter.d.ts +12 -0
- package/types/sync/submitters/submitterManager.d.ts +3 -0
- package/types/sync/submitters/submitterSyncTask.d.ts +10 -0
- package/types/sync/submitters/telemetrySubmitter.d.ts +25 -0
- package/types/sync/submitters/types.d.ts +194 -0
- package/types/sync/submitters/uniqueKeysSubmitter.d.ts +5 -0
- package/types/sync/submitters/uniqueKeysSubmitterInRedis.d.ts +5 -0
- package/types/sync/syncManagerOnline.d.ts +13 -0
- package/types/sync/syncTask.d.ts +13 -0
- package/types/sync/syncTaskComposite.d.ts +5 -0
- package/types/sync/types.d.ts +43 -0
- package/types/trackers/eventTracker.d.ts +10 -0
- package/types/trackers/filter/bloomFilter.d.ts +10 -0
- package/types/trackers/filter/dictionaryFilter.d.ts +8 -0
- package/types/trackers/filter/types.d.ts +5 -0
- package/types/trackers/impressionObserver/ImpressionObserver.d.ts +8 -0
- package/types/trackers/impressionObserver/buildKey.d.ts +2 -0
- package/types/trackers/impressionObserver/impressionObserverCS.d.ts +4 -0
- package/types/trackers/impressionObserver/impressionObserverSS.d.ts +4 -0
- package/types/trackers/impressionObserver/types.d.ts +4 -0
- package/types/trackers/impressionObserver/utils.d.ts +13 -0
- package/types/trackers/impressionsTracker.d.ts +13 -0
- package/types/trackers/strategy/strategyDebug.d.ts +9 -0
- package/types/trackers/strategy/strategyNone.d.ts +10 -0
- package/types/trackers/strategy/strategyOptimized.d.ts +11 -0
- package/types/trackers/telemetryTracker.d.ts +3 -0
- package/types/trackers/types.d.ts +63 -0
- package/types/trackers/uniqueKeysTracker.d.ts +13 -0
- package/types/types.d.ts +1265 -0
- package/types/utils/Backoff.d.ts +25 -0
- package/types/utils/LRUCache/LinkedList.d.ts +34 -0
- package/types/utils/LRUCache/index.d.ts +16 -0
- package/types/utils/MinEventEmitter.d.ts +12 -0
- package/types/utils/MinEvents.d.ts +4 -0
- package/types/utils/base64/index.d.ts +30 -0
- package/types/utils/constants/browser.d.ts +3 -0
- package/types/utils/constants/index.d.ts +64 -0
- package/types/utils/decompress/index.d.ts +16 -0
- package/types/utils/env/isLocalStorageAvailable.d.ts +1 -0
- package/types/utils/env/isNode.d.ts +5 -0
- package/types/utils/inputValidation/apiKey.d.ts +7 -0
- package/types/utils/inputValidation/attribute.d.ts +2 -0
- package/types/utils/inputValidation/attributes.d.ts +4 -0
- package/types/utils/inputValidation/event.d.ts +2 -0
- package/types/utils/inputValidation/eventProperties.d.ts +6 -0
- package/types/utils/inputValidation/eventValue.d.ts +2 -0
- package/types/utils/inputValidation/index.d.ts +13 -0
- package/types/utils/inputValidation/isOperational.d.ts +4 -0
- package/types/utils/inputValidation/key.d.ts +3 -0
- package/types/utils/inputValidation/preloadedData.d.ts +3 -0
- package/types/utils/inputValidation/split.d.ts +2 -0
- package/types/utils/inputValidation/splitExistance.d.ts +7 -0
- package/types/utils/inputValidation/splits.d.ts +2 -0
- package/types/utils/inputValidation/trafficType.d.ts +2 -0
- package/types/utils/inputValidation/trafficTypeExistance.d.ts +9 -0
- package/types/utils/jwt/index.d.ts +5 -0
- package/types/utils/jwt/types.d.ts +5 -0
- package/types/utils/key/index.d.ts +8 -0
- package/types/utils/labels/index.d.ts +7 -0
- package/types/utils/lang/binarySearch.d.ts +9 -0
- package/types/utils/lang/getFnName.d.ts +4 -0
- package/types/utils/lang/getGlobal.d.ts +4 -0
- package/types/utils/lang/index.d.ts +105 -0
- package/types/utils/lang/maps.d.ts +55 -0
- package/types/utils/lang/objectAssign.d.ts +3 -0
- package/types/utils/lang/sets.d.ts +60 -0
- package/types/utils/murmur3/common.d.ts +12 -0
- package/types/utils/murmur3/legacy.d.ts +2 -0
- package/types/utils/murmur3/murmur3.d.ts +2 -0
- package/types/utils/murmur3/murmur3_128.d.ts +6 -0
- package/types/utils/murmur3/murmur3_128_x86.d.ts +7 -0
- package/types/utils/murmur3/murmur3_64.d.ts +10 -0
- package/types/utils/murmur3/utfx.d.ts +27 -0
- package/types/utils/promise/thenable.d.ts +1 -0
- package/types/utils/promise/timeout.d.ts +1 -0
- package/types/utils/promise/wrapper.d.ts +21 -0
- package/types/utils/settingsValidation/consent.d.ts +6 -0
- package/types/utils/settingsValidation/impressionsMode.d.ts +3 -0
- package/types/utils/settingsValidation/index.d.ts +52 -0
- package/types/utils/settingsValidation/integrations/common.d.ts +14 -0
- package/types/utils/settingsValidation/integrations/configurable.d.ts +13 -0
- package/types/utils/settingsValidation/integrations/pluggable.d.ts +13 -0
- package/types/utils/settingsValidation/localhost/builtin.d.ts +16 -0
- package/types/utils/settingsValidation/localhost/pluggable.d.ts +16 -0
- package/types/utils/settingsValidation/logger/builtinLogger.d.ts +10 -0
- package/types/utils/settingsValidation/logger/commons.d.ts +9 -0
- package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +11 -0
- package/types/utils/settingsValidation/mode.d.ts +1 -0
- package/types/utils/settingsValidation/runtime.d.ts +2 -0
- package/types/utils/settingsValidation/splitFilters.d.ts +16 -0
- package/types/utils/settingsValidation/storage/storageCS.d.ts +21 -0
- package/types/utils/settingsValidation/types.d.ts +32 -0
- package/types/utils/settingsValidation/url.d.ts +10 -0
- package/types/utils/time/index.d.ts +4 -0
- package/types/utils/timeTracker/index.d.ts +70 -0
- package/types/utils/timeTracker/now/browser.d.ts +1 -0
- package/types/utils/timeTracker/now/node.d.ts +1 -0
- package/types/utils/timeTracker/timer.d.ts +1 -0
- package/src/logger/.DS_Store +0 -0
- package/src/types.d.ts +0 -1581
package/src/services/splitApi.ts
CHANGED
|
@@ -25,7 +25,6 @@ export function splitApiFactory(
|
|
|
25
25
|
): ISplitApi {
|
|
26
26
|
|
|
27
27
|
const urls = settings.urls;
|
|
28
|
-
// @ts-ignore
|
|
29
28
|
const filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
|
|
30
29
|
const SplitSDKImpressionsMode = settings.sync.impressionsMode;
|
|
31
30
|
const splitHttpClient = splitHttpClientFactory(settings, platform.getFetch, platform.getOptions);
|
|
@@ -107,6 +106,28 @@ export function splitApiFactory(
|
|
|
107
106
|
const url = `${urls.events}/testImpressions/count`;
|
|
108
107
|
return splitHttpClient(url, { method: 'POST', body, headers }, telemetryTracker.trackHttp(IMPRESSIONS_COUNT));
|
|
109
108
|
},
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Post unique keys for client side.
|
|
112
|
+
*
|
|
113
|
+
* @param body unique keys payload
|
|
114
|
+
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
115
|
+
*/
|
|
116
|
+
postUniqueKeysBulkCs(body: string, headers?: Record<string, string>) {
|
|
117
|
+
const url = `${urls.telemetry}/v1/keys/cs`;
|
|
118
|
+
return splitHttpClient(url, { method: 'POST', body, headers }, telemetryTracker.trackHttp(TELEMETRY));
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Post unique keys for server side.
|
|
123
|
+
*
|
|
124
|
+
* @param body unique keys payload
|
|
125
|
+
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
126
|
+
*/
|
|
127
|
+
postUniqueKeysBulkSs(body: string, headers?: Record<string, string>) {
|
|
128
|
+
const url = `${urls.telemetry}/v1/keys/ss`;
|
|
129
|
+
return splitHttpClient(url, { method: 'POST', body, headers }, telemetryTracker.trackHttp(TELEMETRY));
|
|
130
|
+
},
|
|
110
131
|
|
|
111
132
|
postMetricsConfig(body: string) {
|
|
112
133
|
const url = `${urls.telemetry}/v1/metrics/config`;
|
package/src/services/types.ts
CHANGED
|
@@ -43,6 +43,10 @@ export type IFetchMySegments = (userMatchingKey: string, noCache?: boolean) => P
|
|
|
43
43
|
|
|
44
44
|
export type IPostEventsBulk = (body: string, headers?: Record<string, string>) => Promise<IResponse>
|
|
45
45
|
|
|
46
|
+
export type IPostUniqueKeysBulkCs = (body: string, headers?: Record<string, string>) => Promise<IResponse>
|
|
47
|
+
|
|
48
|
+
export type IPostUniqueKeysBulkSs = (body: string, headers?: Record<string, string>) => Promise<IResponse>
|
|
49
|
+
|
|
46
50
|
export type IPostTestImpressionsBulk = (body: string, headers?: Record<string, string>) => Promise<IResponse>
|
|
47
51
|
|
|
48
52
|
export type IPostTestImpressionsCount = (body: string, headers?: Record<string, string>) => Promise<IResponse>
|
|
@@ -59,6 +63,8 @@ export interface ISplitApi {
|
|
|
59
63
|
fetchSegmentChanges: IFetchSegmentChanges
|
|
60
64
|
fetchMySegments: IFetchMySegments
|
|
61
65
|
postEventsBulk: IPostEventsBulk
|
|
66
|
+
postUniqueKeysBulkCs: IPostUniqueKeysBulkCs
|
|
67
|
+
postUniqueKeysBulkSs: IPostUniqueKeysBulkSs
|
|
62
68
|
postTestImpressionsBulk: IPostTestImpressionsBulk
|
|
63
69
|
postTestImpressionsCount: IPostTestImpressionsCount
|
|
64
70
|
postMetricsConfig: IPostMetricsConfig
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ISplitsCacheAsync } from './types';
|
|
2
2
|
import { ISplit } from '../dtos/types';
|
|
3
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class provides a skeletal implementation of the ISplitsCacheAsync interface
|
|
@@ -7,14 +8,14 @@ import { ISplit } from '../dtos/types';
|
|
|
7
8
|
*/
|
|
8
9
|
export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync {
|
|
9
10
|
|
|
10
|
-
abstract addSplit(name: string, split:
|
|
11
|
-
abstract addSplits(entries: [string,
|
|
11
|
+
abstract addSplit(name: string, split: ISplit): Promise<boolean>
|
|
12
|
+
abstract addSplits(entries: [string, ISplit][]): Promise<boolean[] | void>
|
|
12
13
|
abstract removeSplits(names: string[]): Promise<boolean[] | void>
|
|
13
|
-
abstract getSplit(name: string): Promise<
|
|
14
|
-
abstract getSplits(names: string[]): Promise<Record<string,
|
|
14
|
+
abstract getSplit(name: string): Promise<ISplit | null>
|
|
15
|
+
abstract getSplits(names: string[]): Promise<Record<string, ISplit | null>>
|
|
15
16
|
abstract setChangeNumber(changeNumber: number): Promise<boolean | void>
|
|
16
17
|
abstract getChangeNumber(): Promise<number>
|
|
17
|
-
abstract getAll(): Promise<
|
|
18
|
+
abstract getAll(): Promise<ISplit[]>
|
|
18
19
|
abstract getSplitNames(): Promise<string[]>
|
|
19
20
|
abstract trafficTypeExists(trafficType: string): Promise<boolean>
|
|
20
21
|
abstract clear(): Promise<boolean | void>
|
|
@@ -47,16 +48,13 @@ export abstract class AbstractSplitsCacheAsync implements ISplitsCacheAsync {
|
|
|
47
48
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): Promise<boolean> {
|
|
48
49
|
return this.getSplit(name).then(split => {
|
|
49
50
|
|
|
50
|
-
if (split) {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
parsedSplit.changeNumber = changeNumber;
|
|
56
|
-
const newSplit = JSON.stringify(parsedSplit);
|
|
51
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
52
|
+
const newSplit = objectAssign({}, split);
|
|
53
|
+
newSplit.killed = true;
|
|
54
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
55
|
+
newSplit.changeNumber = changeNumber;
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
}
|
|
57
|
+
return this.addSplit(name, newSplit);
|
|
60
58
|
}
|
|
61
59
|
return false;
|
|
62
60
|
}).catch(() => false);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ISplitsCacheSync } from './types';
|
|
2
2
|
import { ISplit } from '../dtos/types';
|
|
3
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class provides a skeletal implementation of the ISplitsCacheSync interface
|
|
@@ -7,9 +8,9 @@ import { ISplit } from '../dtos/types';
|
|
|
7
8
|
*/
|
|
8
9
|
export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
9
10
|
|
|
10
|
-
abstract addSplit(name: string, split:
|
|
11
|
+
abstract addSplit(name: string, split: ISplit): boolean
|
|
11
12
|
|
|
12
|
-
addSplits(entries: [string,
|
|
13
|
+
addSplits(entries: [string, ISplit][]): boolean[] {
|
|
13
14
|
return entries.map(keyValuePair => this.addSplit(keyValuePair[0], keyValuePair[1]));
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -19,10 +20,10 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
|
19
20
|
return names.map(name => this.removeSplit(name));
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
abstract getSplit(name: string):
|
|
23
|
+
abstract getSplit(name: string): ISplit | null
|
|
23
24
|
|
|
24
|
-
getSplits(names: string[]): Record<string,
|
|
25
|
-
const splits: Record<string,
|
|
25
|
+
getSplits(names: string[]): Record<string, ISplit | null> {
|
|
26
|
+
const splits: Record<string, ISplit | null> = {};
|
|
26
27
|
names.forEach(name => {
|
|
27
28
|
splits[name] = this.getSplit(name);
|
|
28
29
|
});
|
|
@@ -33,8 +34,8 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
|
33
34
|
|
|
34
35
|
abstract getChangeNumber(): number
|
|
35
36
|
|
|
36
|
-
getAll():
|
|
37
|
-
return this.getSplitNames().map(key => this.getSplit(key) as
|
|
37
|
+
getAll(): ISplit[] {
|
|
38
|
+
return this.getSplitNames().map(key => this.getSplit(key) as ISplit);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
abstract getSplitNames(): string[]
|
|
@@ -66,16 +67,13 @@ export abstract class AbstractSplitsCacheSync implements ISplitsCacheSync {
|
|
|
66
67
|
killLocally(name: string, defaultTreatment: string, changeNumber: number): boolean {
|
|
67
68
|
const split = this.getSplit(name);
|
|
68
69
|
|
|
69
|
-
if (split) {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
parsedSplit.changeNumber = changeNumber;
|
|
75
|
-
const newSplit = JSON.stringify(parsedSplit);
|
|
70
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
71
|
+
const newSplit = objectAssign({}, split);
|
|
72
|
+
newSplit.killed = true;
|
|
73
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
74
|
+
newSplit.changeNumber = changeNumber;
|
|
76
75
|
|
|
77
|
-
|
|
78
|
-
}
|
|
76
|
+
return this.addSplit(name, newSplit);
|
|
79
77
|
}
|
|
80
78
|
return false;
|
|
81
79
|
}
|
|
@@ -27,6 +27,14 @@ export class KeyBuilderSS extends KeyBuilder {
|
|
|
27
27
|
return `${this.prefix}.impressions`;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
buildImpressionsCountKey() {
|
|
31
|
+
return `${this.prefix}.impressions.count`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
buildUniqueKeysKey() {
|
|
35
|
+
return `${this.prefix}.uniquekeys`;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
buildEventsKey() {
|
|
31
39
|
return `${this.prefix}.events`;
|
|
32
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SplitIO } from '../types';
|
|
2
2
|
import { DEFAULT_CACHE_EXPIRATION_IN_MILLIS } from '../utils/constants/browser';
|
|
3
3
|
import { DataLoader, ISegmentsCacheSync, ISplitsCacheSync } from './types';
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ import { DataLoader, ISegmentsCacheSync, ISplitsCacheSync } from './types';
|
|
|
9
9
|
* and extended with a `mySegmentsData` property.
|
|
10
10
|
* @returns function to preload the storage
|
|
11
11
|
*/
|
|
12
|
-
export function dataLoaderFactory(preloadedData: PreloadedData): DataLoader {
|
|
12
|
+
export function dataLoaderFactory(preloadedData: SplitIO.PreloadedData): DataLoader {
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Storage-agnostic adaptation of `loadDataIntoLocalStorage` function
|
|
@@ -39,7 +39,7 @@ export function dataLoaderFactory(preloadedData: PreloadedData): DataLoader {
|
|
|
39
39
|
storage.splits.setChangeNumber(since);
|
|
40
40
|
|
|
41
41
|
// splitsData in an object where the property is the split name and the pertaining value is a stringified json of its data
|
|
42
|
-
storage.splits.addSplits(Object.keys(splitsData).map(splitName =>
|
|
42
|
+
storage.splits.addSplits(Object.keys(splitsData).map(splitName => JSON.parse(splitsData[splitName])));
|
|
43
43
|
|
|
44
44
|
// add mySegments data
|
|
45
45
|
let mySegmentsData = preloadedData.mySegmentsData && preloadedData.mySegmentsData[userId];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ISplit } from '../../dtos/types';
|
|
1
|
+
import { ISplit, ISplitFiltersValidation } from '../../dtos/types';
|
|
2
2
|
import { AbstractSplitsCacheSync, usesSegments } from '../AbstractSplitsCacheSync';
|
|
3
3
|
import { isFiniteNumber, toNumber, isNaNNumber } from '../../utils/lang';
|
|
4
4
|
import { KeyBuilderCS } from '../KeyBuilderCS';
|
|
5
|
-
import { ILogger
|
|
5
|
+
import { ILogger } from '../../logger/types';
|
|
6
6
|
import { LOG_PREFIX } from './constants';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -38,7 +38,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
38
38
|
else localStorage.removeItem(key);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
private _decrementCounts(split: ISplit) {
|
|
41
|
+
private _decrementCounts(split: ISplit | null) {
|
|
42
42
|
try {
|
|
43
43
|
if (split) {
|
|
44
44
|
if (split.trafficTypeName) {
|
|
@@ -99,18 +99,16 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
99
99
|
this.hasSync = false;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
addSplit(name: string, split:
|
|
102
|
+
addSplit(name: string, split: ISplit) {
|
|
103
103
|
try {
|
|
104
104
|
const splitKey = this.keys.buildSplitKey(name);
|
|
105
105
|
const splitFromLocalStorage = localStorage.getItem(splitKey);
|
|
106
106
|
const previousSplit = splitFromLocalStorage ? JSON.parse(splitFromLocalStorage) : null;
|
|
107
107
|
this._decrementCounts(previousSplit);
|
|
108
108
|
|
|
109
|
-
localStorage.setItem(splitKey, split);
|
|
109
|
+
localStorage.setItem(splitKey, JSON.stringify(split));
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this._incrementCounts(parsedSplit);
|
|
111
|
+
this._incrementCounts(split);
|
|
114
112
|
|
|
115
113
|
return true;
|
|
116
114
|
} catch (e) {
|
|
@@ -124,8 +122,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
124
122
|
const split = this.getSplit(name);
|
|
125
123
|
localStorage.removeItem(this.keys.buildSplitKey(name));
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
this._decrementCounts(parsedSplit);
|
|
125
|
+
this._decrementCounts(split);
|
|
129
126
|
|
|
130
127
|
return true;
|
|
131
128
|
} catch (e) {
|
|
@@ -135,7 +132,8 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
getSplit(name: string) {
|
|
138
|
-
|
|
135
|
+
const item = localStorage.getItem(this.keys.buildSplitKey(name));
|
|
136
|
+
return item && JSON.parse(item);
|
|
139
137
|
}
|
|
140
138
|
|
|
141
139
|
setChangeNumber(changeNumber: number): boolean {
|
|
@@ -184,7 +182,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
|
|
|
184
182
|
return n;
|
|
185
183
|
}
|
|
186
184
|
|
|
187
|
-
getSplitNames() {
|
|
185
|
+
getSplitNames(): string[] {
|
|
188
186
|
const len = localStorage.length;
|
|
189
187
|
const accum = [];
|
|
190
188
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { ImpressionsCacheInMemory } from '../inMemory/ImpressionsCacheInMemory';
|
|
2
2
|
import { ImpressionCountsCacheInMemory } from '../inMemory/ImpressionCountsCacheInMemory';
|
|
3
3
|
import { EventsCacheInMemory } from '../inMemory/EventsCacheInMemory';
|
|
4
|
-
import { IStorageFactoryParams, IStorageSync } from '../types';
|
|
5
|
-
import { StorageSyncFactory } from '../../types';
|
|
4
|
+
import { IStorageFactoryParams, IStorageSync, IStorageSyncFactory } from '../types';
|
|
6
5
|
import { validatePrefix } from '../KeyBuilder';
|
|
7
6
|
import { KeyBuilderCS } from '../KeyBuilderCS';
|
|
8
7
|
import { isLocalStorageAvailable } from '../../utils/env/isLocalStorageAvailable';
|
|
@@ -13,8 +12,9 @@ import { SplitsCacheInMemory } from '../inMemory/SplitsCacheInMemory';
|
|
|
13
12
|
import { DEFAULT_CACHE_EXPIRATION_IN_MILLIS } from '../../utils/constants/browser';
|
|
14
13
|
import { InMemoryStorageCSFactory } from '../inMemory/InMemoryStorageCS';
|
|
15
14
|
import { LOG_PREFIX } from './constants';
|
|
16
|
-
import { LOCALHOST_MODE, STORAGE_LOCALSTORAGE } from '../../utils/constants';
|
|
15
|
+
import { LOCALHOST_MODE, NONE, STORAGE_LOCALSTORAGE } from '../../utils/constants';
|
|
17
16
|
import { shouldRecordTelemetry, TelemetryCacheInMemory } from '../inMemory/TelemetryCacheInMemory';
|
|
17
|
+
import { UniqueKeysCacheInMemoryCS } from '../inMemory/uniqueKeysCacheInMemoryCS';
|
|
18
18
|
|
|
19
19
|
export interface InLocalStorageOptions {
|
|
20
20
|
prefix?: string
|
|
@@ -23,7 +23,7 @@ export interface InLocalStorageOptions {
|
|
|
23
23
|
/**
|
|
24
24
|
* InLocal storage factory for standalone client-side SplitFactory
|
|
25
25
|
*/
|
|
26
|
-
export function InLocalStorage(options: InLocalStorageOptions = {}):
|
|
26
|
+
export function InLocalStorage(options: InLocalStorageOptions = {}): IStorageSyncFactory {
|
|
27
27
|
|
|
28
28
|
const prefix = validatePrefix(options.prefix);
|
|
29
29
|
|
|
@@ -46,6 +46,7 @@ export function InLocalStorage(options: InLocalStorageOptions = {}): StorageSync
|
|
|
46
46
|
impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory() : undefined,
|
|
47
47
|
events: new EventsCacheInMemory(params.eventsQueueSize),
|
|
48
48
|
telemetry: params.mode !== LOCALHOST_MODE && shouldRecordTelemetry() ? new TelemetryCacheInMemory() : undefined,
|
|
49
|
+
uniqueKeys: params.impressionsMode === NONE ? new UniqueKeysCacheInMemoryCS() : undefined,
|
|
49
50
|
|
|
50
51
|
destroy() {
|
|
51
52
|
this.splits = new SplitsCacheInMemory();
|
|
@@ -53,6 +54,7 @@ export function InLocalStorage(options: InLocalStorageOptions = {}): StorageSync
|
|
|
53
54
|
this.impressions.clear();
|
|
54
55
|
this.impressionCounts && this.impressionCounts.clear();
|
|
55
56
|
this.events.clear();
|
|
57
|
+
this.uniqueKeys?.clear();
|
|
56
58
|
},
|
|
57
59
|
|
|
58
60
|
// When using shared instanciation with MEMORY we reuse everything but segments (they are customer per key).
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import { AttributeType } from '../../types';
|
|
2
1
|
import { objectAssign } from '../../utils/lang/objectAssign';
|
|
3
2
|
|
|
4
3
|
export class AttributesCacheInMemory {
|
|
5
4
|
|
|
6
|
-
private attributesCache: Record<string,
|
|
5
|
+
private attributesCache: Record<string, Object> = {};
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Create or update the value for the given attribute
|
|
11
|
-
*
|
|
10
|
+
*
|
|
12
11
|
* @param {string} attributeName attribute name
|
|
13
12
|
* @param {Object} attributeValue attribute value
|
|
14
|
-
* @returns {boolean} the attribute was stored
|
|
13
|
+
* @returns {boolean} the attribute was stored
|
|
15
14
|
*/
|
|
16
|
-
setAttribute(attributeName: string, attributeValue:
|
|
15
|
+
setAttribute(attributeName: string, attributeValue: Object): boolean {
|
|
17
16
|
this.attributesCache[attributeName] = attributeValue;
|
|
18
17
|
return true;
|
|
19
18
|
}
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Retrieves the value of a given attribute
|
|
23
|
-
*
|
|
22
|
+
*
|
|
24
23
|
* @param {string} attributeName attribute name
|
|
25
24
|
* @returns {Object?} stored attribute value
|
|
26
25
|
*/
|
|
27
|
-
getAttribute(attributeName: string):
|
|
26
|
+
getAttribute(attributeName: string): Object {
|
|
28
27
|
return this.attributesCache[attributeName];
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* Create or update all the given attributes
|
|
33
|
-
*
|
|
32
|
+
*
|
|
34
33
|
* @param {[string, Object]} attributes attributes to create or update
|
|
35
34
|
* @returns {boolean} attributes were stored
|
|
36
35
|
*/
|
|
@@ -41,16 +40,16 @@ export class AttributesCacheInMemory {
|
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
42
|
* Retrieve the full attributes map
|
|
44
|
-
*
|
|
45
|
-
* @returns {Map<string,
|
|
43
|
+
*
|
|
44
|
+
* @returns {Map<string, Object>} stored attributes
|
|
46
45
|
*/
|
|
47
|
-
getAll(): Record<string,
|
|
46
|
+
getAll(): Record<string, Object> {
|
|
48
47
|
return this.attributesCache;
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
/**
|
|
52
51
|
* Removes a given attribute from the map
|
|
53
|
-
*
|
|
52
|
+
*
|
|
54
53
|
* @param {string} attributeName attribute to remove
|
|
55
54
|
* @returns {boolean} attribute removed
|
|
56
55
|
*/
|
|
@@ -64,7 +63,7 @@ export class AttributesCacheInMemory {
|
|
|
64
63
|
|
|
65
64
|
/**
|
|
66
65
|
* Clears all attributes stored in the SDK
|
|
67
|
-
*
|
|
66
|
+
*
|
|
68
67
|
*/
|
|
69
68
|
clear() {
|
|
70
69
|
this.attributesCache = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SplitIO } from '../../types';
|
|
2
2
|
import { IEventsCacheSync } from '../types';
|
|
3
3
|
|
|
4
4
|
const MAX_QUEUE_BYTE_SIZE = 5 * 1024 * 1024; // 5M
|
|
@@ -7,7 +7,7 @@ export class EventsCacheInMemory implements IEventsCacheSync {
|
|
|
7
7
|
|
|
8
8
|
private onFullQueue?: () => void;
|
|
9
9
|
private readonly maxQueue: number;
|
|
10
|
-
private queue: EventData[];
|
|
10
|
+
private queue: SplitIO.EventData[];
|
|
11
11
|
private queueByteSize: number;
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -28,7 +28,7 @@ export class EventsCacheInMemory implements IEventsCacheSync {
|
|
|
28
28
|
/**
|
|
29
29
|
* Add a new event object at the end of the queue.
|
|
30
30
|
*/
|
|
31
|
-
track(data: EventData, size = 0) {
|
|
31
|
+
track(data: SplitIO.EventData, size = 0) {
|
|
32
32
|
this.queueByteSize += size;
|
|
33
33
|
this.queue.push(data);
|
|
34
34
|
|
|
@@ -48,7 +48,7 @@ export class EventsCacheInMemory implements IEventsCacheSync {
|
|
|
48
48
|
/**
|
|
49
49
|
* Pop the collected data, used as payload for posting.
|
|
50
50
|
*/
|
|
51
|
-
pop(toMerge?: EventData[]) {
|
|
51
|
+
pop(toMerge?: SplitIO.EventData[]) {
|
|
52
52
|
const data = this.queue;
|
|
53
53
|
this.clear();
|
|
54
54
|
return toMerge ? toMerge.concat(data) : data;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { truncateTimeFrame } from '../../utils/time';
|
|
2
|
+
import { DEFAULT_CACHE_SIZE } from '../inRedis/constants';
|
|
2
3
|
import { IImpressionCountsCacheSync } from '../types';
|
|
3
4
|
|
|
4
5
|
export class ImpressionCountsCacheInMemory implements IImpressionCountsCacheSync {
|
|
5
|
-
|
|
6
|
+
protected cache: Record<string, number> = {};
|
|
7
|
+
private readonly maxStorage: number;
|
|
8
|
+
protected onFullQueue?: () => void;
|
|
9
|
+
private cacheSize = 0;
|
|
10
|
+
|
|
11
|
+
constructor(impressionCountsCacheSize: number = DEFAULT_CACHE_SIZE) {
|
|
12
|
+
this.maxStorage = impressionCountsCacheSize;
|
|
13
|
+
}
|
|
6
14
|
|
|
7
15
|
/**
|
|
8
16
|
* Builds key to be stored in the cache with the featureName and the timeFrame truncated.
|
|
@@ -18,6 +26,13 @@ export class ImpressionCountsCacheInMemory implements IImpressionCountsCacheSync
|
|
|
18
26
|
const key = this._makeKey(featureName, timeFrame);
|
|
19
27
|
const currentAmount = this.cache[key];
|
|
20
28
|
this.cache[key] = currentAmount ? currentAmount + amount : amount;
|
|
29
|
+
if (this.onFullQueue) {
|
|
30
|
+
this.cacheSize = this.cacheSize + amount;
|
|
31
|
+
if (this.cacheSize >= this.maxStorage) {
|
|
32
|
+
this.onFullQueue();
|
|
33
|
+
this.cacheSize = 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
21
36
|
}
|
|
22
37
|
|
|
23
38
|
|
|
@@ -4,8 +4,9 @@ import { ImpressionsCacheInMemory } from './ImpressionsCacheInMemory';
|
|
|
4
4
|
import { EventsCacheInMemory } from './EventsCacheInMemory';
|
|
5
5
|
import { IStorageFactoryParams, IStorageSync } from '../types';
|
|
6
6
|
import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
|
|
7
|
-
import { LOCALHOST_MODE, STORAGE_MEMORY } from '../../utils/constants';
|
|
7
|
+
import { DEBUG, LOCALHOST_MODE, NONE, STORAGE_MEMORY } from '../../utils/constants';
|
|
8
8
|
import { TelemetryCacheInMemory } from './TelemetryCacheInMemory';
|
|
9
|
+
import { UniqueKeysCacheInMemory } from './uniqueKeysCacheInMemory';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* InMemory storage factory for standalone server-side SplitFactory
|
|
@@ -18,9 +19,10 @@ export function InMemoryStorageFactory(params: IStorageFactoryParams): IStorageS
|
|
|
18
19
|
splits: new SplitsCacheInMemory(),
|
|
19
20
|
segments: new SegmentsCacheInMemory(),
|
|
20
21
|
impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
21
|
-
impressionCounts: params.
|
|
22
|
+
impressionCounts: params.impressionsMode !== DEBUG ? new ImpressionCountsCacheInMemory() : undefined,
|
|
22
23
|
events: new EventsCacheInMemory(params.eventsQueueSize),
|
|
23
24
|
telemetry: params.mode !== LOCALHOST_MODE ? new TelemetryCacheInMemory() : undefined, // Always track telemetry in standalone mode on server-side
|
|
25
|
+
uniqueKeys: params.impressionsMode === NONE ? new UniqueKeysCacheInMemory(params.uniqueKeysCacheSize) : undefined,
|
|
24
26
|
|
|
25
27
|
// When using MEMORY we should clean all the caches to leave them empty
|
|
26
28
|
destroy() {
|
|
@@ -29,6 +31,7 @@ export function InMemoryStorageFactory(params: IStorageFactoryParams): IStorageS
|
|
|
29
31
|
this.impressions.clear();
|
|
30
32
|
this.impressionCounts && this.impressionCounts.clear();
|
|
31
33
|
this.events.clear();
|
|
34
|
+
this.uniqueKeys?.clear();
|
|
32
35
|
}
|
|
33
36
|
};
|
|
34
37
|
}
|
|
@@ -4,8 +4,9 @@ import { ImpressionsCacheInMemory } from './ImpressionsCacheInMemory';
|
|
|
4
4
|
import { EventsCacheInMemory } from './EventsCacheInMemory';
|
|
5
5
|
import { IStorageSync, IStorageFactoryParams } from '../types';
|
|
6
6
|
import { ImpressionCountsCacheInMemory } from './ImpressionCountsCacheInMemory';
|
|
7
|
-
import { LOCALHOST_MODE, STORAGE_MEMORY } from '../../utils/constants';
|
|
7
|
+
import { DEBUG, LOCALHOST_MODE, NONE, STORAGE_MEMORY } from '../../utils/constants';
|
|
8
8
|
import { shouldRecordTelemetry, TelemetryCacheInMemory } from './TelemetryCacheInMemory';
|
|
9
|
+
import { UniqueKeysCacheInMemoryCS } from './uniqueKeysCacheInMemoryCS';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* InMemory storage factory for standalone client-side SplitFactory
|
|
@@ -18,9 +19,11 @@ export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorag
|
|
|
18
19
|
splits: new SplitsCacheInMemory(),
|
|
19
20
|
segments: new MySegmentsCacheInMemory(),
|
|
20
21
|
impressions: new ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
21
|
-
impressionCounts: params.
|
|
22
|
+
impressionCounts: params.impressionsMode !== DEBUG ? new ImpressionCountsCacheInMemory() : undefined,
|
|
22
23
|
events: new EventsCacheInMemory(params.eventsQueueSize),
|
|
23
24
|
telemetry: params.mode !== LOCALHOST_MODE && shouldRecordTelemetry() ? new TelemetryCacheInMemory() : undefined,
|
|
25
|
+
uniqueKeys: params.impressionsMode === NONE ? new UniqueKeysCacheInMemoryCS(params.uniqueKeysCacheSize) : undefined,
|
|
26
|
+
|
|
24
27
|
|
|
25
28
|
// When using MEMORY we should clean all the caches to leave them empty
|
|
26
29
|
destroy() {
|
|
@@ -29,6 +32,7 @@ export function InMemoryStorageCSFactory(params: IStorageFactoryParams): IStorag
|
|
|
29
32
|
this.impressions.clear();
|
|
30
33
|
this.impressionCounts && this.impressionCounts.clear();
|
|
31
34
|
this.events.clear();
|
|
35
|
+
this.uniqueKeys?.clear();
|
|
32
36
|
},
|
|
33
37
|
|
|
34
38
|
// When using shared instanciation with MEMORY we reuse everything but segments (they are unique per key)
|
|
@@ -8,7 +8,7 @@ import { isFiniteNumber } from '../../utils/lang';
|
|
|
8
8
|
*/
|
|
9
9
|
export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
|
|
10
10
|
|
|
11
|
-
private splitsCache: Record<string,
|
|
11
|
+
private splitsCache: Record<string, ISplit> = {};
|
|
12
12
|
private ttCache: Record<string, number> = {};
|
|
13
13
|
private changeNumber: number = -1;
|
|
14
14
|
private splitsWithSegmentsCount: number = 0;
|
|
@@ -20,10 +20,9 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
|
|
|
20
20
|
this.splitsWithSegmentsCount = 0;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
addSplit(name: string, split:
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
const previousSplit: ISplit = JSON.parse(splitFromMemory);
|
|
23
|
+
addSplit(name: string, split: ISplit): boolean {
|
|
24
|
+
const previousSplit = this.getSplit(name);
|
|
25
|
+
if (previousSplit) { // We had this Split already
|
|
27
26
|
|
|
28
27
|
if (previousSplit.trafficTypeName) {
|
|
29
28
|
const previousTtName = previousSplit.trafficTypeName;
|
|
@@ -36,20 +35,18 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
|
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (parsedSplit) {
|
|
38
|
+
if (split) {
|
|
42
39
|
// Store the Split.
|
|
43
40
|
this.splitsCache[name] = split;
|
|
44
41
|
// Update TT cache
|
|
45
|
-
const ttName =
|
|
42
|
+
const ttName = split.trafficTypeName;
|
|
46
43
|
if (ttName) { // safeguard
|
|
47
44
|
if (!this.ttCache[ttName]) this.ttCache[ttName] = 0;
|
|
48
45
|
this.ttCache[ttName]++;
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
// Add to segments count for the new version of the Split
|
|
52
|
-
if (usesSegments(
|
|
49
|
+
if (usesSegments(split)) this.splitsWithSegmentsCount++;
|
|
53
50
|
|
|
54
51
|
return true;
|
|
55
52
|
} else {
|
|
@@ -63,8 +60,7 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
|
|
|
63
60
|
// Delete the Split
|
|
64
61
|
delete this.splitsCache[name];
|
|
65
62
|
|
|
66
|
-
const
|
|
67
|
-
const ttName = parsedSplit.trafficTypeName;
|
|
63
|
+
const ttName = split.trafficTypeName;
|
|
68
64
|
|
|
69
65
|
if (ttName) { // safeguard
|
|
70
66
|
this.ttCache[ttName]--; // Update tt cache
|
|
@@ -72,7 +68,7 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
|
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
// Update the segments count.
|
|
75
|
-
if (usesSegments(
|
|
71
|
+
if (usesSegments(split)) this.splitsWithSegmentsCount--;
|
|
76
72
|
|
|
77
73
|
return true;
|
|
78
74
|
} else {
|
|
@@ -80,7 +76,7 @@ export class SplitsCacheInMemory extends AbstractSplitsCacheSync {
|
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
78
|
|
|
83
|
-
getSplit(name: string):
|
|
79
|
+
getSplit(name: string): ISplit | null {
|
|
84
80
|
return this.splitsCache[name] || null;
|
|
85
81
|
}
|
|
86
82
|
|