@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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strategyNoneFactory = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* None strategy for impressions tracker.
|
|
6
|
+
*
|
|
7
|
+
* @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
|
|
8
|
+
* @param uniqueKeysTracker unique keys tracker in charge of tracking the unique keys per split.
|
|
9
|
+
* @returns IStrategyResult
|
|
10
|
+
*/
|
|
11
|
+
function strategyNoneFactory(impressionsCounter, uniqueKeysTracker) {
|
|
12
|
+
return {
|
|
13
|
+
process: function (impressions) {
|
|
14
|
+
impressions.forEach(function (impression) {
|
|
15
|
+
var now = Date.now();
|
|
16
|
+
// Increments impression counter per featureName
|
|
17
|
+
impressionsCounter.track(impression.feature, now, 1);
|
|
18
|
+
// Keep track by unique key
|
|
19
|
+
uniqueKeysTracker.track(impression.keyName, impression.feature);
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
impressionsToStore: [],
|
|
23
|
+
impressionsToListener: impressions,
|
|
24
|
+
deduped: 0
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.strategyNoneFactory = strategyNoneFactory;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.strategyOptimizedFactory = void 0;
|
|
4
|
+
var time_1 = require("../../utils/time");
|
|
5
|
+
/**
|
|
6
|
+
* Optimized strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
|
|
7
|
+
*
|
|
8
|
+
* @param impressionsObserver impression observer. previous time (pt property) is included in impression instances
|
|
9
|
+
* @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
|
|
10
|
+
* @returns IStrategyResult
|
|
11
|
+
*/
|
|
12
|
+
function strategyOptimizedFactory(impressionsObserver, impressionsCounter) {
|
|
13
|
+
return {
|
|
14
|
+
process: function (impressions) {
|
|
15
|
+
var impressionsToStore = [];
|
|
16
|
+
impressions.forEach(function (impression) {
|
|
17
|
+
impression.pt = impressionsObserver.testAndSet(impression);
|
|
18
|
+
var now = Date.now();
|
|
19
|
+
// Increments impression counter per featureName
|
|
20
|
+
if (impression.pt)
|
|
21
|
+
impressionsCounter.track(impression.feature, now, 1);
|
|
22
|
+
// Checks if the impression should be added in queue to be sent
|
|
23
|
+
if (!impression.pt || impression.pt < (0, time_1.truncateTimeFrame)(now)) {
|
|
24
|
+
impressionsToStore.push(impression);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
impressionsToStore: impressionsToStore,
|
|
29
|
+
impressionsToListener: impressions,
|
|
30
|
+
deduped: impressions.length - impressionsToStore.length
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.strategyOptimizedFactory = strategyOptimizedFactory;
|
|
@@ -49,6 +49,11 @@ function telemetryTrackerFactory(telemetryCache, now) {
|
|
|
49
49
|
if (e === constants_1.TOKEN_REFRESH)
|
|
50
50
|
telemetryCache.recordTokenRefreshes();
|
|
51
51
|
}
|
|
52
|
+
},
|
|
53
|
+
addTag: function (tag) {
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
if (telemetryCache.addTag)
|
|
56
|
+
telemetryCache.addTag(tag);
|
|
52
57
|
}
|
|
53
58
|
};
|
|
54
59
|
}
|
|
@@ -59,6 +64,7 @@ function telemetryTrackerFactory(telemetryCache, now) {
|
|
|
59
64
|
trackHttp: noopTrack,
|
|
60
65
|
sessionLength: function () { },
|
|
61
66
|
streamingEvent: function () { },
|
|
67
|
+
addTag: function () { }
|
|
62
68
|
};
|
|
63
69
|
}
|
|
64
70
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqueKeysTrackerFactory = void 0;
|
|
4
|
+
var constants_1 = require("../logger/constants");
|
|
5
|
+
var noopFilterAdapter = {
|
|
6
|
+
add: function () { return true; },
|
|
7
|
+
contains: function () { return true; },
|
|
8
|
+
clear: function () { }
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Trackes uniques keys
|
|
12
|
+
* Unique Keys Tracker will be in charge of checking if the MTK was already sent to the BE in the last period
|
|
13
|
+
* or schedule to be sent; if not it will be added in an internal cache and sent in the next post.
|
|
14
|
+
*
|
|
15
|
+
* @param log Logger instance
|
|
16
|
+
* @param uniqueKeysCache cache to save unique keys
|
|
17
|
+
* @param filterAdapter filter adapter
|
|
18
|
+
*/
|
|
19
|
+
function uniqueKeysTrackerFactory(log, uniqueKeysCache, filterAdapter) {
|
|
20
|
+
if (filterAdapter === void 0) { filterAdapter = noopFilterAdapter; }
|
|
21
|
+
var intervalId;
|
|
22
|
+
if (filterAdapter.refreshRate) {
|
|
23
|
+
intervalId = setInterval(filterAdapter.clear, filterAdapter.refreshRate);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
track: function (key, featureName) {
|
|
27
|
+
if (!filterAdapter.add(key, featureName)) {
|
|
28
|
+
log.debug(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER + "The feature " + featureName + " and key " + key + " exist in the filter");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
uniqueKeysCache.track(key, featureName);
|
|
32
|
+
},
|
|
33
|
+
stop: function () {
|
|
34
|
+
clearInterval(intervalId);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.uniqueKeysTrackerFactory = uniqueKeysTrackerFactory;
|
package/cjs/types.js
ADDED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.PAUSED = exports.ENABLED = exports.DISABLED = exports.NON_REQUESTED = exports.REQUESTED = exports.POLLING = exports.STREAMING = void 0;
|
|
3
|
+
exports.ABLY_ERROR = exports.TOKEN_REFRESH = exports.SSE_CONNECTION_ERROR = exports.STREAMING_STATUS = exports.OCCUPANCY_SEC = exports.OCCUPANCY_PRI = exports.CONNECTION_ESTABLISHED = exports.TRACK = exports.TREATMENTS_WITH_CONFIG = exports.TREATMENT_WITH_CONFIG = exports.TREATMENTS = exports.TREATMENT = exports.MY_SEGMENT = exports.SEGMENT = exports.TOKEN = exports.TELEMETRY = exports.EVENTS = exports.IMPRESSIONS_COUNT = exports.IMPRESSIONS = exports.SPLITS = exports.NONE_ENUM = exports.DEBUG_ENUM = exports.OPTIMIZED_ENUM = exports.CONSUMER_PARTIAL_ENUM = exports.CONSUMER_ENUM = exports.STANDALONE_ENUM = exports.DEDUPED = exports.DROPPED = exports.QUEUED = exports.CONSENT_UNKNOWN = exports.CONSENT_DECLINED = exports.CONSENT_GRANTED = exports.STORAGE_PLUGGABLE = exports.STORAGE_REDIS = exports.STORAGE_LOCALSTORAGE = exports.STORAGE_MEMORY = exports.CONSUMER_PARTIAL_MODE = exports.CONSUMER_MODE = exports.PRODUCER_MODE = exports.STANDALONE_MODE = exports.LOCALHOST_MODE = exports.NONE = exports.OPTIMIZED = exports.DEBUG = exports.SPLIT_EVENT = exports.SPLIT_IMPRESSION = exports.NA = exports.UNKNOWN = exports.CONTROL_WITH_CONFIG = exports.CONTROL = void 0;
|
|
4
|
+
exports.PAUSED = exports.ENABLED = exports.DISABLED = exports.NON_REQUESTED = exports.REQUESTED = exports.POLLING = exports.STREAMING = exports.AUTH_REJECTION = exports.SYNC_MODE_UPDATE = void 0;
|
|
5
5
|
// Special treatments
|
|
6
6
|
exports.CONTROL = 'control';
|
|
7
7
|
exports.CONTROL_WITH_CONFIG = {
|
|
@@ -17,6 +17,7 @@ exports.SPLIT_EVENT = 'EVENT';
|
|
|
17
17
|
// Impression collection modes
|
|
18
18
|
exports.DEBUG = 'DEBUG';
|
|
19
19
|
exports.OPTIMIZED = 'OPTIMIZED';
|
|
20
|
+
exports.NONE = 'NONE';
|
|
20
21
|
// SDK Modes
|
|
21
22
|
exports.LOCALHOST_MODE = 'localhost';
|
|
22
23
|
exports.STANDALONE_MODE = 'standalone';
|
|
@@ -41,6 +42,7 @@ exports.CONSUMER_ENUM = 1;
|
|
|
41
42
|
exports.CONSUMER_PARTIAL_ENUM = 2;
|
|
42
43
|
exports.OPTIMIZED_ENUM = 0;
|
|
43
44
|
exports.DEBUG_ENUM = 1;
|
|
45
|
+
exports.NONE_ENUM = 2;
|
|
44
46
|
exports.SPLITS = 'sp';
|
|
45
47
|
exports.IMPRESSIONS = 'im';
|
|
46
48
|
exports.IMPRESSIONS_COUNT = 'ic';
|
package/cjs/utils/key/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.keyParser = exports.getBucketing = exports.getMatching = void 0;
|
|
4
4
|
var lang_1 = require("../lang");
|
|
5
|
-
// function isSplitKeyObject(key: any): key is SplitKeyObject {
|
|
5
|
+
// function isSplitKeyObject(key: any): key is SplitIO.SplitKeyObject {
|
|
6
6
|
// return key !== undefined && key !== null && typeof key.matchingKey === 'string';
|
|
7
7
|
// }
|
|
8
8
|
// returns the matchingKey if the Key is defined as an object or the key itself if it is a string
|
|
@@ -6,9 +6,9 @@ var constants_2 = require("../constants");
|
|
|
6
6
|
var lang_1 = require("../lang");
|
|
7
7
|
function validImpressionsMode(log, impressionsMode) {
|
|
8
8
|
impressionsMode = (0, lang_1.stringToUpperCase)(impressionsMode);
|
|
9
|
-
if ([constants_2.DEBUG, constants_2.OPTIMIZED].indexOf(impressionsMode) > -1)
|
|
9
|
+
if ([constants_2.DEBUG, constants_2.OPTIMIZED, constants_2.NONE].indexOf(impressionsMode) > -1)
|
|
10
10
|
return impressionsMode;
|
|
11
|
-
log.error(constants_1.ERROR_INVALID_CONFIG_PARAM, ['impressionsMode', [constants_2.DEBUG, constants_2.OPTIMIZED], constants_2.OPTIMIZED]);
|
|
11
|
+
log.error(constants_1.ERROR_INVALID_CONFIG_PARAM, ['impressionsMode', [constants_2.DEBUG, constants_2.OPTIMIZED, constants_2.NONE], constants_2.OPTIMIZED]);
|
|
12
12
|
return constants_2.OPTIMIZED;
|
|
13
13
|
}
|
|
14
14
|
exports.validImpressionsMode = validImpressionsMode;
|
|
@@ -34,6 +34,8 @@ exports.base = {
|
|
|
34
34
|
telemetryRefreshRate: 3600,
|
|
35
35
|
// publish evaluations each 300 sec (default value for OPTIMIZED impressions mode)
|
|
36
36
|
impressionsRefreshRate: 300,
|
|
37
|
+
// publish unique Keys each 900 sec (15 min)
|
|
38
|
+
uniqueKeysRefreshRate: 900,
|
|
37
39
|
// fetch offline changes each 15 sec
|
|
38
40
|
offlineRefreshRate: 15,
|
|
39
41
|
// publish events every 60 seconds after the first flush
|
|
@@ -112,6 +114,8 @@ function settingsValidation(config, validationParams) {
|
|
|
112
114
|
scheduler.segmentsRefreshRate = fromSecondsToMillis(scheduler.segmentsRefreshRate);
|
|
113
115
|
scheduler.offlineRefreshRate = fromSecondsToMillis(scheduler.offlineRefreshRate);
|
|
114
116
|
scheduler.eventsPushRate = fromSecondsToMillis(scheduler.eventsPushRate);
|
|
117
|
+
scheduler.uniqueKeysRefreshRate = fromSecondsToMillis(scheduler.uniqueKeysRefreshRate);
|
|
118
|
+
scheduler.impressionCountsRefreshRate = fromSecondsToMillis(scheduler.impressionCountsRefreshRate);
|
|
115
119
|
scheduler.telemetryRefreshRate = fromSecondsToMillis(validateMinValue('telemetryRefreshRate', scheduler.telemetryRefreshRate, 60));
|
|
116
120
|
// Default impressionsRefreshRate for DEBUG mode is 60 secs
|
|
117
121
|
if ((0, lang_1.get)(config, 'scheduler.impressionsRefreshRate') === undefined && withDefaults.sync.impressionsMode === constants_1.DEBUG)
|
|
@@ -175,7 +179,6 @@ function settingsValidation(config, validationParams) {
|
|
|
175
179
|
// validate the `splitFilters` settings and parse splits query
|
|
176
180
|
var splitFiltersValidation = (0, splitFilters_1.validateSplitFilters)(log, withDefaults.sync.splitFilters, withDefaults.mode);
|
|
177
181
|
withDefaults.sync.splitFilters = splitFiltersValidation.validFilters;
|
|
178
|
-
// @ts-ignore
|
|
179
182
|
withDefaults.sync.__splitFiltersValidation = splitFiltersValidation;
|
|
180
183
|
// ensure a valid user consent value
|
|
181
184
|
// @ts-ignore, modify readonly prop
|
|
@@ -36,8 +36,8 @@ export function createUserConsentAPI(params) {
|
|
|
36
36
|
if (events.clear)
|
|
37
37
|
events.clear(); // @ts-ignore
|
|
38
38
|
if (impressions.clear)
|
|
39
|
-
impressions.clear();
|
|
40
|
-
if (impressionCounts)
|
|
39
|
+
impressions.clear(); // @ts-ignore
|
|
40
|
+
if (impressionCounts && impressionCounts.clear)
|
|
41
41
|
impressionCounts.clear();
|
|
42
42
|
}
|
|
43
43
|
}
|
package/esm/evaluator/index.js
CHANGED
|
@@ -32,44 +32,43 @@ export function evaluateFeature(log, key, splitName, attributes, storage) {
|
|
|
32
32
|
return getEvaluation(log, stringifiedSplit, key, attributes, storage);
|
|
33
33
|
}
|
|
34
34
|
export function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
35
|
-
var
|
|
35
|
+
var parsedSplits;
|
|
36
36
|
try {
|
|
37
|
-
|
|
37
|
+
parsedSplits = storage.splits.getSplits(splitNames);
|
|
38
38
|
}
|
|
39
39
|
catch (e) {
|
|
40
40
|
// Exception on sync `getSplits` storage. Not possible ATM with InMemory and InLocal storages.
|
|
41
41
|
return treatmentsException(splitNames);
|
|
42
42
|
}
|
|
43
|
-
return
|
|
44
|
-
|
|
43
|
+
return thenable(parsedSplits) ?
|
|
44
|
+
parsedSplits.then(function (splits) { return getEvaluations(log, splitNames, splits, key, attributes, storage); })
|
|
45
45
|
.catch(function () {
|
|
46
46
|
// Exception on async `getSplits` storage. For example, when the storage is redis or
|
|
47
47
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
48
48
|
return treatmentsException(splitNames);
|
|
49
49
|
}) :
|
|
50
|
-
getEvaluations(log, splitNames,
|
|
50
|
+
getEvaluations(log, splitNames, parsedSplits, key, attributes, storage);
|
|
51
51
|
}
|
|
52
|
-
function getEvaluation(log,
|
|
52
|
+
function getEvaluation(log, splitJSON, key, attributes, storage) {
|
|
53
53
|
var evaluation = {
|
|
54
54
|
treatment: CONTROL,
|
|
55
55
|
label: LabelsConstants.SPLIT_NOT_FOUND,
|
|
56
56
|
config: null
|
|
57
57
|
};
|
|
58
|
-
if (
|
|
59
|
-
var
|
|
60
|
-
var split_1 = Engine.parse(log, splitJSON_1, storage);
|
|
58
|
+
if (splitJSON) {
|
|
59
|
+
var split_1 = Engine.parse(log, splitJSON, storage);
|
|
61
60
|
evaluation = split_1.getTreatment(key, attributes, evaluateFeature);
|
|
62
61
|
// If the storage is async and the evaluated split uses segment, evaluation is thenable
|
|
63
62
|
if (thenable(evaluation)) {
|
|
64
63
|
return evaluation.then(function (result) {
|
|
65
64
|
result.changeNumber = split_1.getChangeNumber();
|
|
66
|
-
result.config =
|
|
65
|
+
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
|
|
67
66
|
return result;
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
69
|
else {
|
|
71
70
|
evaluation.changeNumber = split_1.getChangeNumber(); // Always sync and optional
|
|
72
|
-
evaluation.config =
|
|
71
|
+
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
|
|
73
72
|
}
|
|
74
73
|
}
|
|
75
74
|
return evaluation;
|
|
@@ -13,7 +13,7 @@ var logNameMapper = 'ga-to-split:mapper';
|
|
|
13
13
|
* @param log Logger instance.
|
|
14
14
|
* @param autoRequire If true, log error when auto-require script is not detected
|
|
15
15
|
*/
|
|
16
|
-
function providePlugin(window, pluginName, pluginConstructor, log, autoRequire) {
|
|
16
|
+
function providePlugin(window, pluginName, pluginConstructor, log, autoRequire, telemetryTracker) {
|
|
17
17
|
// get reference to global command queue. Init it if not defined yet.
|
|
18
18
|
var gaAlias = window.GoogleAnalyticsObject || 'ga';
|
|
19
19
|
window[gaAlias] = window[gaAlias] || function () {
|
|
@@ -21,10 +21,13 @@ function providePlugin(window, pluginName, pluginConstructor, log, autoRequire)
|
|
|
21
21
|
};
|
|
22
22
|
// provides the plugin for use with analytics.js.
|
|
23
23
|
window[gaAlias]('provide', pluginName, pluginConstructor);
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
var hasAutoRequire = window[gaAlias].q && window[gaAlias].q.push !== [].push;
|
|
25
|
+
if (autoRequire && !hasAutoRequire) { // Expecting spy on ga.q push method but not found
|
|
26
26
|
log.error(logPrefix + 'integration is configured to autorequire the splitTracker plugin, but the necessary script does not seem to have run. Please check the docs.');
|
|
27
27
|
}
|
|
28
|
+
if (telemetryTracker && hasAutoRequire) {
|
|
29
|
+
telemetryTracker.addTag('integration:ga-autorequire');
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
// Default mapping: object used for building the default mapper from hits to Split events
|
|
30
33
|
var defaultMapping = {
|
|
@@ -157,7 +160,7 @@ export function fixEventTypeId(log, eventTypeId) {
|
|
|
157
160
|
* @param {object} log factory logger
|
|
158
161
|
*/
|
|
159
162
|
export function GaToSplit(sdkOptions, params) {
|
|
160
|
-
var storage = params.storage, _a = params.settings, coreSettings = _a.core, log = _a.log;
|
|
163
|
+
var storage = params.storage, _a = params.settings, coreSettings = _a.core, log = _a.log, telemetryTracker = params.telemetryTracker;
|
|
161
164
|
var defaultOptions = {
|
|
162
165
|
prefix: defaultPrefix,
|
|
163
166
|
// We set default identities if key and TT are present in settings.core
|
|
@@ -243,5 +246,5 @@ export function GaToSplit(sdkOptions, params) {
|
|
|
243
246
|
return SplitTracker;
|
|
244
247
|
}());
|
|
245
248
|
// Register the plugin, even if config is invalid, since, if not provided, it will block `ga` command queue.
|
|
246
|
-
providePlugin(window, 'splitTracker', SplitTracker, log, sdkOptions.autoRequire === true);
|
|
249
|
+
providePlugin(window, 'splitTracker', SplitTracker, log, sdkOptions.autoRequire === true, telemetryTracker);
|
|
247
250
|
}
|
package/esm/listeners/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fromImpressionsCollector } from '../sync/submitters/impressionsSubmitter';
|
|
2
2
|
import { fromImpressionCountsCollector } from '../sync/submitters/impressionCountsSubmitter';
|
|
3
|
-
import { OPTIMIZED, DEBUG } from '../utils/constants';
|
|
3
|
+
import { OPTIMIZED, DEBUG, NONE } from '../utils/constants';
|
|
4
4
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
5
5
|
import { CLEANUP_REGISTERING, CLEANUP_DEREGISTERING } from '../logger/constants';
|
|
6
6
|
import { isConsentGranted } from '../consent';
|
|
@@ -71,9 +71,10 @@ var BrowserSignalListener = /** @class */ (function () {
|
|
|
71
71
|
// Flush impressions & events data if there is user consent
|
|
72
72
|
if (isConsentGranted(this.settings)) {
|
|
73
73
|
var eventsUrl = this.settings.urls.events;
|
|
74
|
+
var sim = this.settings.sync.impressionsMode;
|
|
74
75
|
var extraMetadata = {
|
|
75
76
|
// sim stands for Sync/Split Impressions Mode
|
|
76
|
-
sim:
|
|
77
|
+
sim: sim === OPTIMIZED ? OPTIMIZED : sim === DEBUG ? DEBUG : NONE
|
|
77
78
|
};
|
|
78
79
|
this._flushData(eventsUrl + '/testImpressions/beacon', this.storage.impressions, this.serviceApi.postTestImpressionsBulk, this.fromImpressionsCollector, extraMetadata);
|
|
79
80
|
this._flushData(eventsUrl + '/events/beacon', this.storage.events, this.serviceApi.postEventsBulk);
|
package/esm/logger/constants.js
CHANGED
|
@@ -139,4 +139,5 @@ export var LOG_PREFIX_SYNC_POLLING = LOG_PREFIX_SYNC + ':polling-manager: ';
|
|
|
139
139
|
export var LOG_PREFIX_SYNC_SUBMITTERS = LOG_PREFIX_SYNC + ':submitter: ';
|
|
140
140
|
export var LOG_PREFIX_IMPRESSIONS_TRACKER = 'impressions-tracker: ';
|
|
141
141
|
export var LOG_PREFIX_EVENTS_TRACKER = 'events-tracker: ';
|
|
142
|
+
export var LOG_PREFIX_UNIQUE_KEYS_TRACKER = 'unique-keys-tracker: ';
|
|
142
143
|
export var LOG_PREFIX_CLEANUP = 'cleanup: ';
|
|
@@ -44,7 +44,7 @@ export function clientAttributesDecoration(log, client) {
|
|
|
44
44
|
* Add an attribute to client's in memory attributes storage
|
|
45
45
|
*
|
|
46
46
|
* @param {string} attributeName Attrinute name
|
|
47
|
-
* @param {
|
|
47
|
+
* @param {string, number, boolean, list} attributeValue Attribute value
|
|
48
48
|
* @returns {boolean} true if the attribute was stored and false otherways
|
|
49
49
|
*/
|
|
50
50
|
setAttribute: function (attributeName, attributeValue) {
|
|
@@ -6,7 +6,7 @@ import { clientInputValidationDecorator } from './clientInputValidation';
|
|
|
6
6
|
* Creates an Sdk client, i.e., a base client with status and destroy interface
|
|
7
7
|
*/
|
|
8
8
|
export function sdkClientFactory(params, isSharedClient) {
|
|
9
|
-
var sdkReadinessManager = params.sdkReadinessManager, syncManager = params.syncManager, storage = params.storage, signalListener = params.signalListener, settings = params.settings, telemetryTracker = params.telemetryTracker;
|
|
9
|
+
var sdkReadinessManager = params.sdkReadinessManager, syncManager = params.syncManager, storage = params.storage, signalListener = params.signalListener, settings = params.settings, telemetryTracker = params.telemetryTracker, uniqueKeysTracker = params.uniqueKeysTracker;
|
|
10
10
|
return objectAssign(
|
|
11
11
|
// Proto-linkage of the readiness Event Emitter
|
|
12
12
|
Object.create(sdkReadinessManager.sdkStatus),
|
|
@@ -28,6 +28,8 @@ export function sdkClientFactory(params, isSharedClient) {
|
|
|
28
28
|
// Release the API Key if it is the main client
|
|
29
29
|
if (!isSharedClient)
|
|
30
30
|
releaseApiKey(settings.core.authorizationKey);
|
|
31
|
+
if (uniqueKeysTracker)
|
|
32
|
+
uniqueKeysTracker.stop();
|
|
31
33
|
// Cleanup storage
|
|
32
34
|
return storage.destroy();
|
|
33
35
|
});
|
package/esm/sdkFactory/index.js
CHANGED
|
@@ -10,11 +10,16 @@ import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
|
10
10
|
import { metadataBuilder } from '../storages/metadataBuilder';
|
|
11
11
|
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
12
12
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
13
|
+
import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
|
|
14
|
+
import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
|
|
15
|
+
import { strategyNoneFactory } from '../trackers/strategy/strategyNone';
|
|
16
|
+
import { uniqueKeysTrackerFactory } from '../trackers/uniqueKeysTracker';
|
|
17
|
+
import { NONE, OPTIMIZED } from '../utils/constants';
|
|
13
18
|
/**
|
|
14
19
|
* Modular SDK factory
|
|
15
20
|
*/
|
|
16
21
|
export function sdkFactory(params) {
|
|
17
|
-
var settings = params.settings, platform = params.platform, storageFactory = params.storageFactory, splitApiFactory = params.splitApiFactory, extraProps = params.extraProps, syncManagerFactory = params.syncManagerFactory, SignalListener = params.SignalListener, impressionsObserverFactory = params.impressionsObserverFactory, integrationsManagerFactory = params.integrationsManagerFactory, sdkManagerFactory = params.sdkManagerFactory, sdkClientMethodFactory = params.sdkClientMethodFactory;
|
|
22
|
+
var settings = params.settings, platform = params.platform, storageFactory = params.storageFactory, splitApiFactory = params.splitApiFactory, extraProps = params.extraProps, syncManagerFactory = params.syncManagerFactory, SignalListener = params.SignalListener, impressionsObserverFactory = params.impressionsObserverFactory, integrationsManagerFactory = params.integrationsManagerFactory, sdkManagerFactory = params.sdkManagerFactory, sdkClientMethodFactory = params.sdkClientMethodFactory, filterAdapterFactory = params.filterAdapterFactory;
|
|
18
23
|
var log = settings.log;
|
|
19
24
|
// @TODO handle non-recoverable errors, such as, global `fetch` not available, invalid API Key, etc.
|
|
20
25
|
// On non-recoverable errors, we should mark the SDK as destroyed and not start synchronization.
|
|
@@ -26,13 +31,17 @@ export function sdkFactory(params) {
|
|
|
26
31
|
var storageFactoryParams = {
|
|
27
32
|
impressionsQueueSize: settings.scheduler.impressionsQueueSize,
|
|
28
33
|
eventsQueueSize: settings.scheduler.eventsQueueSize,
|
|
34
|
+
uniqueKeysCacheSize: settings.scheduler.uniqueKeysCacheSize,
|
|
35
|
+
impressionCountsQueueSize: settings.scheduler.impressionCountsQueueSize,
|
|
36
|
+
impressionCountsRefreshRate: settings.scheduler.impressionCountsRefreshRate,
|
|
37
|
+
uniqueKeysRefreshRate: settings.scheduler.uniqueKeysRefreshRate,
|
|
29
38
|
optimize: shouldBeOptimized(settings),
|
|
30
39
|
// ATM, only used by InLocalStorage
|
|
31
40
|
matchingKey: getMatching(settings.core.key),
|
|
32
|
-
// @ts-ignore
|
|
33
41
|
splitFiltersValidation: settings.sync.__splitFiltersValidation,
|
|
34
42
|
// ATM, only used by PluggableStorage
|
|
35
43
|
mode: settings.mode,
|
|
44
|
+
impressionsMode: settings.sync.impressionsMode,
|
|
36
45
|
// Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined,
|
|
37
46
|
// or partial consumer mode, where it only has submitters, and therefore it doesn't emit readiness events.
|
|
38
47
|
onReadyCb: function (error) {
|
|
@@ -46,15 +55,26 @@ export function sdkFactory(params) {
|
|
|
46
55
|
};
|
|
47
56
|
var storage = storageFactory(storageFactoryParams);
|
|
48
57
|
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
49
|
-
var integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings: settings, storage: storage });
|
|
50
|
-
// trackers
|
|
51
|
-
var observer = impressionsObserverFactory && impressionsObserverFactory();
|
|
52
|
-
var impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, integrationsManager, observer, storage.impressionCounts, storage.telemetry);
|
|
53
|
-
var eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
|
|
54
58
|
var telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
59
|
+
var integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings: settings, storage: storage, telemetryTracker: telemetryTracker });
|
|
60
|
+
var observer = impressionsObserverFactory();
|
|
61
|
+
var uniqueKeysTracker = storageFactoryParams.impressionsMode === NONE ? uniqueKeysTrackerFactory(log, storage.uniqueKeys, filterAdapterFactory && filterAdapterFactory()) : undefined;
|
|
62
|
+
var strategy;
|
|
63
|
+
switch (storageFactoryParams.impressionsMode) {
|
|
64
|
+
case OPTIMIZED:
|
|
65
|
+
strategy = strategyOptimizedFactory(observer, storage.impressionCounts);
|
|
66
|
+
break;
|
|
67
|
+
case NONE:
|
|
68
|
+
strategy = strategyNoneFactory(storage.impressionCounts, uniqueKeysTracker);
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
strategy = strategyDebugFactory(observer);
|
|
72
|
+
}
|
|
73
|
+
var impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, strategy, integrationsManager, storage.telemetry);
|
|
74
|
+
var eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
|
|
55
75
|
// splitApi is used by SyncManager and Browser signal listener
|
|
56
76
|
var splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
|
|
57
|
-
var ctx = { splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker, sdkReadinessManager: sdkReadinessManager, readiness: readiness, settings: settings, storage: storage, platform: platform };
|
|
77
|
+
var ctx = { splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker, uniqueKeysTracker: uniqueKeysTracker, sdkReadinessManager: sdkReadinessManager, readiness: readiness, settings: settings, storage: storage, platform: platform };
|
|
58
78
|
var syncManager = syncManagerFactory && syncManagerFactory(ctx);
|
|
59
79
|
ctx.syncManager = syncManager;
|
|
60
80
|
var signalListener = SignalListener && new SignalListener(syncManager, settings, storage, splitApi);
|
package/esm/sdkManager/index.js
CHANGED
|
@@ -12,15 +12,7 @@ function collectTreatments(splitObject) {
|
|
|
12
12
|
// Then extract the treatments from the partitions
|
|
13
13
|
return allTreatmentsCondition ? allTreatmentsCondition.partitions.map(function (v) { return v.treatment; }) : [];
|
|
14
14
|
}
|
|
15
|
-
function objectToView(
|
|
16
|
-
var splitObject;
|
|
17
|
-
try {
|
|
18
|
-
// @ts-expect-error
|
|
19
|
-
splitObject = JSON.parse(json);
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
15
|
+
function objectToView(splitObject) {
|
|
24
16
|
if (!splitObject)
|
|
25
17
|
return null;
|
|
26
18
|
return {
|
|
@@ -32,9 +24,9 @@ function objectToView(json) {
|
|
|
32
24
|
configs: splitObject.configurations || {}
|
|
33
25
|
};
|
|
34
26
|
}
|
|
35
|
-
function objectsToViews(
|
|
27
|
+
function objectsToViews(splitObjects) {
|
|
36
28
|
var views = [];
|
|
37
|
-
|
|
29
|
+
splitObjects.forEach(function (split) {
|
|
38
30
|
var view = objectToView(split);
|
|
39
31
|
if (view)
|
|
40
32
|
views.push(view);
|
package/esm/services/splitApi.js
CHANGED
|
@@ -13,7 +13,6 @@ function userKeyToQueryParam(userKey) {
|
|
|
13
13
|
*/
|
|
14
14
|
export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
15
15
|
var urls = settings.urls;
|
|
16
|
-
// @ts-ignore
|
|
17
16
|
var filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
|
|
18
17
|
var SplitSDKImpressionsMode = settings.sync.impressionsMode;
|
|
19
18
|
var splitHttpClient = splitHttpClientFactory(settings, platform.getFetch, platform.getOptions);
|
|
@@ -88,6 +87,26 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
88
87
|
var url = urls.events + "/testImpressions/count";
|
|
89
88
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(IMPRESSIONS_COUNT));
|
|
90
89
|
},
|
|
90
|
+
/**
|
|
91
|
+
* Post unique keys for client side.
|
|
92
|
+
*
|
|
93
|
+
* @param body unique keys payload
|
|
94
|
+
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
95
|
+
*/
|
|
96
|
+
postUniqueKeysBulkCs: function (body, headers) {
|
|
97
|
+
var url = urls.telemetry + "/v1/keys/cs";
|
|
98
|
+
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(TELEMETRY));
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Post unique keys for server side.
|
|
102
|
+
*
|
|
103
|
+
* @param body unique keys payload
|
|
104
|
+
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
105
|
+
*/
|
|
106
|
+
postUniqueKeysBulkSs: function (body, headers) {
|
|
107
|
+
var url = urls.telemetry + "/v1/keys/ss";
|
|
108
|
+
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(TELEMETRY));
|
|
109
|
+
},
|
|
91
110
|
postMetricsConfig: function (body) {
|
|
92
111
|
var url = urls.telemetry + "/v1/metrics/config";
|
|
93
112
|
return splitHttpClient(url, { method: 'POST', body: body }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
1
2
|
/**
|
|
2
3
|
* This class provides a skeletal implementation of the ISplitsCacheAsync interface
|
|
3
4
|
* to minimize the effort required to implement this interface.
|
|
@@ -31,15 +32,12 @@ var AbstractSplitsCacheAsync = /** @class */ (function () {
|
|
|
31
32
|
AbstractSplitsCacheAsync.prototype.killLocally = function (name, defaultTreatment, changeNumber) {
|
|
32
33
|
var _this = this;
|
|
33
34
|
return this.getSplit(name).then(function (split) {
|
|
34
|
-
if (split) {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var newSplit = JSON.stringify(parsedSplit);
|
|
41
|
-
return _this.addSplit(name, newSplit);
|
|
42
|
-
}
|
|
35
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
36
|
+
var newSplit = objectAssign({}, split);
|
|
37
|
+
newSplit.killed = true;
|
|
38
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
39
|
+
newSplit.changeNumber = changeNumber;
|
|
40
|
+
return _this.addSplit(name, newSplit);
|
|
43
41
|
}
|
|
44
42
|
return false;
|
|
45
43
|
}).catch(function () { return false; });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
1
2
|
/**
|
|
2
3
|
* This class provides a skeletal implementation of the ISplitsCacheSync interface
|
|
3
4
|
* to minimize the effort required to implement this interface.
|
|
@@ -44,15 +45,12 @@ var AbstractSplitsCacheSync = /** @class */ (function () {
|
|
|
44
45
|
*/
|
|
45
46
|
AbstractSplitsCacheSync.prototype.killLocally = function (name, defaultTreatment, changeNumber) {
|
|
46
47
|
var split = this.getSplit(name);
|
|
47
|
-
if (split) {
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var newSplit = JSON.stringify(parsedSplit);
|
|
54
|
-
return this.addSplit(name, newSplit);
|
|
55
|
-
}
|
|
48
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
49
|
+
var newSplit = objectAssign({}, split);
|
|
50
|
+
newSplit.killed = true;
|
|
51
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
52
|
+
newSplit.changeNumber = changeNumber;
|
|
53
|
+
return this.addSplit(name, newSplit);
|
|
56
54
|
}
|
|
57
55
|
return false;
|
|
58
56
|
};
|
|
@@ -20,6 +20,12 @@ var KeyBuilderSS = /** @class */ (function (_super) {
|
|
|
20
20
|
KeyBuilderSS.prototype.buildImpressionsKey = function () {
|
|
21
21
|
return this.prefix + ".impressions";
|
|
22
22
|
};
|
|
23
|
+
KeyBuilderSS.prototype.buildImpressionsCountKey = function () {
|
|
24
|
+
return this.prefix + ".impressions.count";
|
|
25
|
+
};
|
|
26
|
+
KeyBuilderSS.prototype.buildUniqueKeysKey = function () {
|
|
27
|
+
return this.prefix + ".uniquekeys";
|
|
28
|
+
};
|
|
23
29
|
KeyBuilderSS.prototype.buildEventsKey = function () {
|
|
24
30
|
return this.prefix + ".events";
|
|
25
31
|
};
|
|
@@ -32,7 +32,7 @@ export function dataLoaderFactory(preloadedData) {
|
|
|
32
32
|
storage.splits.clear();
|
|
33
33
|
storage.splits.setChangeNumber(since);
|
|
34
34
|
// splitsData in an object where the property is the split name and the pertaining value is a stringified json of its data
|
|
35
|
-
storage.splits.addSplits(Object.keys(splitsData).map(function (splitName) { return
|
|
35
|
+
storage.splits.addSplits(Object.keys(splitsData).map(function (splitName) { return JSON.parse(splitsData[splitName]); }));
|
|
36
36
|
// add mySegments data
|
|
37
37
|
var mySegmentsData = preloadedData.mySegmentsData && preloadedData.mySegmentsData[userId];
|
|
38
38
|
if (!mySegmentsData) {
|
|
@@ -93,9 +93,8 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
93
93
|
var splitFromLocalStorage = localStorage.getItem(splitKey);
|
|
94
94
|
var previousSplit = splitFromLocalStorage ? JSON.parse(splitFromLocalStorage) : null;
|
|
95
95
|
this._decrementCounts(previousSplit);
|
|
96
|
-
localStorage.setItem(splitKey, split);
|
|
97
|
-
|
|
98
|
-
this._incrementCounts(parsedSplit);
|
|
96
|
+
localStorage.setItem(splitKey, JSON.stringify(split));
|
|
97
|
+
this._incrementCounts(split);
|
|
99
98
|
return true;
|
|
100
99
|
}
|
|
101
100
|
catch (e) {
|
|
@@ -107,8 +106,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
107
106
|
try {
|
|
108
107
|
var split = this.getSplit(name);
|
|
109
108
|
localStorage.removeItem(this.keys.buildSplitKey(name));
|
|
110
|
-
|
|
111
|
-
this._decrementCounts(parsedSplit);
|
|
109
|
+
this._decrementCounts(split);
|
|
112
110
|
return true;
|
|
113
111
|
}
|
|
114
112
|
catch (e) {
|
|
@@ -117,7 +115,8 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
117
115
|
}
|
|
118
116
|
};
|
|
119
117
|
SplitsCacheInLocal.prototype.getSplit = function (name) {
|
|
120
|
-
|
|
118
|
+
var item = localStorage.getItem(this.keys.buildSplitKey(name));
|
|
119
|
+
return item && JSON.parse(item);
|
|
121
120
|
};
|
|
122
121
|
SplitsCacheInLocal.prototype.setChangeNumber = function (changeNumber) {
|
|
123
122
|
// when cache is ready but using a new split query, we must clear all split data
|