@splitsoftware/splitio-commons 1.6.2-rc.2 → 1.6.2-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/listeners/browser.js +1 -2
- package/cjs/logger/constants.js +1 -2
- package/cjs/sdkFactory/index.js +6 -14
- package/cjs/services/splitApi.js +1 -20
- package/cjs/storages/inLocalStorage/index.js +0 -4
- package/cjs/storages/inMemory/InMemoryStorage.js +1 -5
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -5
- package/cjs/sync/submitters/submitterManager.js +0 -3
- package/cjs/sync/submitters/telemetrySubmitter.js +0 -1
- package/cjs/trackers/impressionsTracker.js +28 -7
- package/cjs/utils/constants/index.js +2 -4
- package/cjs/utils/key/index.js +1 -1
- package/cjs/utils/settingsValidation/impressionsMode.js +2 -2
- package/cjs/utils/settingsValidation/index.js +1 -3
- package/esm/listeners/browser.js +2 -3
- package/esm/logger/constants.js +0 -1
- package/esm/sdkFactory/index.js +6 -14
- package/esm/services/splitApi.js +1 -20
- package/esm/storages/inLocalStorage/index.js +1 -5
- package/esm/storages/inMemory/InMemoryStorage.js +2 -6
- package/esm/storages/inMemory/InMemoryStorageCS.js +2 -6
- package/esm/sync/submitters/submitterManager.js +0 -3
- package/esm/sync/submitters/telemetrySubmitter.js +1 -2
- package/esm/trackers/impressionsTracker.js +28 -7
- package/esm/utils/constants/index.js +0 -2
- package/esm/utils/key/index.js +1 -1
- package/esm/utils/settingsValidation/impressionsMode.js +3 -3
- package/esm/utils/settingsValidation/index.js +1 -3
- package/package.json +2 -2
- package/src/consent/sdkUserConsent.ts +4 -3
- package/src/dtos/types.ts +0 -8
- 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 +10 -10
- 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 +6 -6
- 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 +2 -2
- package/src/listeners/browser.ts +2 -3
- package/src/logger/.DS_Store +0 -0
- package/src/logger/constants.ts +0 -1
- package/src/logger/index.ts +3 -3
- package/src/logger/sdkLogger.ts +1 -2
- package/src/logger/types.ts +0 -16
- package/src/readiness/sdkReadinessManager.ts +1 -1
- package/src/readiness/types.ts +2 -9
- package/src/sdkClient/client.ts +13 -13
- package/src/sdkClient/clientAttributesDecoration.ts +9 -9
- package/src/sdkClient/clientCS.ts +3 -4
- package/src/sdkClient/clientInputValidation.ts +15 -15
- package/src/sdkClient/sdkClient.ts +2 -2
- 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 +8 -18
- package/src/sdkFactory/types.ts +8 -11
- package/src/sdkManager/index.ts +5 -5
- package/src/services/splitApi.ts +1 -22
- package/src/services/types.ts +0 -6
- package/src/storages/dataLoader.ts +2 -2
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +2 -2
- package/src/storages/inLocalStorage/index.ts +4 -6
- package/src/storages/inMemory/EventsCacheInMemory.ts +4 -4
- package/src/storages/inMemory/InMemoryStorage.ts +2 -5
- package/src/storages/inMemory/InMemoryStorageCS.ts +2 -6
- package/src/storages/inRedis/EventsCacheInRedis.ts +4 -4
- 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 +1 -1
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +1 -1
- package/src/storages/inRedis/index.ts +3 -2
- 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 +1 -1
- 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 +48 -40
- package/src/sync/offline/LocalhostFromObject.ts +4 -4
- package/src/sync/offline/splitsParser/splitsParserFromSettings.ts +8 -8
- 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 +1 -1
- 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 +0 -2
- package/src/sync/submitters/telemetrySubmitter.ts +3 -4
- package/src/sync/submitters/types.ts +3 -22
- package/src/sync/syncTask.ts +1 -1
- package/src/trackers/eventTracker.ts +3 -3
- package/src/trackers/impressionsTracker.ts +38 -15
- package/src/trackers/types.ts +4 -30
- package/src/types.d.ts +1646 -0
- package/src/utils/constants/index.ts +1 -3
- 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 +1 -2
- package/src/utils/settingsValidation/impressionsMode.ts +6 -6
- package/src/utils/settingsValidation/index.ts +1 -4
- 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 +1 -2
- package/src/utils/settingsValidation/localhost/builtin.ts +1 -2
- package/src/utils/settingsValidation/localhost/pluggable.ts +1 -2
- package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
- package/src/utils/settingsValidation/logger/pluggableLogger.ts +1 -2
- package/src/utils/settingsValidation/splitFilters.ts +7 -9
- package/src/utils/settingsValidation/storage/storageCS.ts +1 -2
- package/types/consent/sdkUserConsent.d.ts +2 -9
- package/types/dtos/types.d.ts +0 -6
- package/types/evaluator/Engine.d.ts +3 -3
- package/types/evaluator/combiners/and.d.ts +1 -1
- package/types/evaluator/combiners/ifelseif.d.ts +1 -1
- package/types/evaluator/condition/engineUtils.d.ts +1 -1
- package/types/evaluator/condition/index.d.ts +1 -1
- package/types/evaluator/index.d.ts +4 -4
- package/types/evaluator/matchers/all.d.ts +1 -1
- package/types/evaluator/matchers/between.d.ts +1 -1
- package/types/evaluator/matchers/boolean.d.ts +1 -1
- package/types/evaluator/matchers/cont_all.d.ts +1 -1
- package/types/evaluator/matchers/cont_any.d.ts +1 -1
- package/types/evaluator/matchers/cont_str.d.ts +1 -1
- package/types/evaluator/matchers/dependency.d.ts +1 -1
- package/types/evaluator/matchers/eq.d.ts +1 -1
- package/types/evaluator/matchers/eq_set.d.ts +1 -1
- package/types/evaluator/matchers/ew.d.ts +1 -1
- package/types/evaluator/matchers/gte.d.ts +1 -1
- package/types/evaluator/matchers/index.d.ts +1 -1
- package/types/evaluator/matchers/lte.d.ts +1 -1
- package/types/evaluator/matchers/part_of.d.ts +1 -1
- package/types/evaluator/matchers/segment.d.ts +1 -1
- package/types/evaluator/matchers/string.d.ts +1 -1
- package/types/evaluator/matchers/sw.d.ts +1 -1
- package/types/evaluator/matchers/whitelist.d.ts +1 -1
- package/types/evaluator/parser/index.d.ts +1 -1
- package/types/evaluator/types.d.ts +6 -6
- package/types/evaluator/value/index.d.ts +3 -3
- package/types/evaluator/value/sanitize.d.ts +3 -3
- package/types/integrations/ga/GaToSplit.d.ts +4 -4
- package/types/integrations/ga/SplitToGa.d.ts +4 -4
- package/types/integrations/ga/types.d.ts +4 -4
- package/types/integrations/types.d.ts +2 -2
- package/types/logger/constants.d.ts +0 -1
- package/types/logger/index.d.ts +3 -5
- package/types/logger/sdkLogger.d.ts +1 -2
- package/types/logger/types.d.ts +0 -11
- package/types/readiness/sdkReadinessManager.d.ts +1 -1
- package/types/readiness/types.d.ts +2 -8
- package/types/sdkClient/client.d.ts +2 -2
- package/types/sdkClient/clientAttributesDecoration.d.ts +8 -8
- package/types/sdkClient/clientCS.d.ts +2 -3
- package/types/sdkClient/clientInputValidation.d.ts +2 -2
- package/types/sdkClient/sdkClient.d.ts +2 -2
- package/types/sdkClient/sdkClientMethod.d.ts +2 -2
- package/types/sdkClient/sdkClientMethodCS.d.ts +2 -2
- package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +2 -2
- package/types/sdkFactory/index.d.ts +2 -2
- package/types/sdkFactory/types.d.ts +8 -10
- package/types/sdkManager/index.d.ts +3 -3
- package/types/services/types.d.ts +0 -4
- package/types/storages/dataLoader.d.ts +2 -2
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +1 -1
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -2
- package/types/storages/inLocalStorage/index.d.ts +2 -2
- package/types/storages/inMemory/EventsCacheInMemory.d.ts +3 -3
- package/types/storages/inMemory/InMemoryStorage.d.ts +1 -1
- package/types/storages/inMemory/InMemoryStorageCS.d.ts +1 -1
- package/types/storages/inRedis/EventsCacheInRedis.d.ts +3 -3
- package/types/storages/inRedis/ImpressionsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
- package/types/storages/inRedis/SegmentsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/index.d.ts +2 -2
- package/types/storages/pluggable/EventsCachePluggable.d.ts +3 -3
- package/types/storages/pluggable/ImpressionsCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/SegmentsCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/TelemetryCachePluggable.d.ts +1 -1
- package/types/storages/pluggable/index.d.ts +3 -2
- package/types/storages/pluggable/wrapperAdapter.d.ts +1 -1
- package/types/storages/types.d.ts +46 -30
- package/types/sync/offline/LocalhostFromObject.d.ts +2 -2
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
- package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +1 -1
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -1
- package/types/sync/streaming/SSEHandler/index.d.ts +1 -1
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +1 -1
- package/types/sync/submitters/submitter.d.ts +1 -1
- package/types/sync/submitters/types.d.ts +3 -20
- package/types/sync/syncTask.d.ts +1 -1
- package/types/trackers/impressionsTracker.d.ts +6 -4
- package/types/trackers/types.d.ts +4 -25
- package/types/utils/constants/index.d.ts +1 -3
- package/types/utils/inputValidation/apiKey.d.ts +1 -1
- package/types/utils/inputValidation/attribute.d.ts +1 -1
- package/types/utils/inputValidation/attributes.d.ts +3 -3
- package/types/utils/inputValidation/event.d.ts +1 -1
- package/types/utils/inputValidation/eventProperties.d.ts +3 -3
- package/types/utils/inputValidation/eventValue.d.ts +1 -1
- package/types/utils/inputValidation/isOperational.d.ts +1 -1
- package/types/utils/inputValidation/key.d.ts +3 -3
- package/types/utils/inputValidation/preloadedData.d.ts +3 -3
- package/types/utils/inputValidation/split.d.ts +1 -1
- package/types/utils/inputValidation/splitExistance.d.ts +1 -1
- package/types/utils/inputValidation/splits.d.ts +1 -1
- package/types/utils/inputValidation/trafficType.d.ts +1 -1
- package/types/utils/inputValidation/trafficTypeExistance.d.ts +1 -1
- package/types/utils/key/index.d.ts +4 -4
- package/types/utils/settingsValidation/consent.d.ts +1 -2
- package/types/utils/settingsValidation/impressionsMode.d.ts +3 -3
- package/types/utils/settingsValidation/index.d.ts +0 -1
- package/types/utils/settingsValidation/integrations/common.d.ts +1 -1
- package/types/utils/settingsValidation/integrations/configurable.d.ts +1 -1
- package/types/utils/settingsValidation/integrations/pluggable.d.ts +1 -2
- package/types/utils/settingsValidation/localhost/builtin.d.ts +1 -2
- package/types/utils/settingsValidation/localhost/pluggable.d.ts +1 -2
- package/types/utils/settingsValidation/logger/builtinLogger.d.ts +1 -1
- package/types/utils/settingsValidation/logger/pluggableLogger.d.ts +1 -1
- package/types/utils/settingsValidation/splitFilters.d.ts +1 -2
- package/types/utils/settingsValidation/storage/storageCS.d.ts +2 -3
- package/cjs/storages/inMemory/uniqueKeysCacheInMemory.js +0 -73
- package/cjs/storages/inMemory/uniqueKeysCacheInMemoryCS.js +0 -78
- package/cjs/sync/submitters/uniqueKeysSubmitter.js +0 -26
- package/cjs/trackers/strategy/strategyDebug.js +0 -25
- package/cjs/trackers/strategy/strategyNone.js +0 -29
- package/cjs/trackers/strategy/strategyOptimized.js +0 -34
- package/cjs/trackers/uniqueKeysTracker.js +0 -31
- package/cjs/types.js +0 -2
- package/esm/storages/inMemory/uniqueKeysCacheInMemory.js +0 -70
- package/esm/storages/inMemory/uniqueKeysCacheInMemoryCS.js +0 -75
- package/esm/sync/submitters/uniqueKeysSubmitter.js +0 -22
- package/esm/trackers/strategy/strategyDebug.js +0 -21
- package/esm/trackers/strategy/strategyNone.js +0 -25
- package/esm/trackers/strategy/strategyOptimized.js +0 -30
- package/esm/trackers/uniqueKeysTracker.js +0 -27
- package/esm/types.js +0 -1
- package/src/storages/inMemory/uniqueKeysCacheInMemory.ts +0 -83
- package/src/storages/inMemory/uniqueKeysCacheInMemoryCS.ts +0 -89
- package/src/sync/submitters/uniqueKeysSubmitter.ts +0 -35
- package/src/trackers/strategy/strategyDebug.ts +0 -28
- package/src/trackers/strategy/strategyNone.ts +0 -34
- package/src/trackers/strategy/strategyOptimized.ts +0 -42
- package/src/trackers/uniqueKeysTracker.ts +0 -37
- package/src/types.ts +0 -1265
- package/types/sdkClient/types.d.ts +0 -18
- package/types/storages/inMemory/CountsCacheInMemory.d.ts +0 -20
- package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +0 -20
- package/types/storages/inMemory/uniqueKeysCacheInMemory.d.ts +0 -32
- package/types/storages/inMemory/uniqueKeysCacheInMemoryCS.d.ts +0 -37
- package/types/storages/inRedis/CountsCacheInRedis.d.ts +0 -9
- package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +0 -9
- package/types/sync/offline/LocalhostFromFile.d.ts +0 -2
- package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +0 -2
- package/types/sync/submitters/eventsSyncTask.d.ts +0 -8
- package/types/sync/submitters/impressionCountsSyncTask.d.ts +0 -13
- package/types/sync/submitters/impressionsSyncTask.d.ts +0 -14
- package/types/sync/submitters/metricsSyncTask.d.ts +0 -12
- package/types/sync/submitters/submitterSyncTask.d.ts +0 -10
- package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -5
- package/types/sync/syncTaskComposite.d.ts +0 -5
- package/types/trackers/filter/bloomFilter.d.ts +0 -10
- package/types/trackers/filter/dictionaryFilter.d.ts +0 -8
- package/types/trackers/filter/types.d.ts +0 -5
- package/types/trackers/strategy/strategyDebug.d.ts +0 -9
- package/types/trackers/strategy/strategyNone.d.ts +0 -10
- package/types/trackers/strategy/strategyOptimized.d.ts +0 -11
- package/types/trackers/uniqueKeysTracker.d.ts +0 -13
- package/types/types.d.ts +0 -1263
- package/types/utils/timeTracker/index.d.ts +0 -70
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { ISplitFiltersValidation } from '../../
|
|
2
|
-
import { ILogger } from '../../logger/types';
|
|
1
|
+
import { ISplitFiltersValidation, ILogger } from '../../types';
|
|
3
2
|
/**
|
|
4
3
|
* Validates `splitFilters` configuration object and parses it into a query string for filtering splits on `/splitChanges` fetch.
|
|
5
4
|
*
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ISettings, SDKMode } from '../../../types';
|
|
2
|
-
import { ILogger } from '../../../logger/types';
|
|
1
|
+
import { ISettings, SDKMode, ILogger } from '../../../types';
|
|
3
2
|
import { IStorageFactoryParams, IStorageSync } from '../../../storages/types';
|
|
4
3
|
export declare function __InLocalStorageMockFactory(params: IStorageFactoryParams): IStorageSync;
|
|
5
4
|
export declare namespace __InLocalStorageMockFactory {
|
|
6
|
-
var type: import("../../../
|
|
5
|
+
var type: import("../../../types").StorageType;
|
|
7
6
|
}
|
|
8
7
|
/**
|
|
9
8
|
* This function validates `settings.storage` object
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniqueKeysCacheInMemory = void 0;
|
|
4
|
-
var sets_1 = require("../../utils/lang/sets");
|
|
5
|
-
var DEFAULT_CACHE_SIZE = 30000;
|
|
6
|
-
var UniqueKeysCacheInMemory = /** @class */ (function () {
|
|
7
|
-
function UniqueKeysCacheInMemory(uniqueKeysQueueSize) {
|
|
8
|
-
if (uniqueKeysQueueSize === void 0) { uniqueKeysQueueSize = DEFAULT_CACHE_SIZE; }
|
|
9
|
-
this.uniqueTrackerSize = 0;
|
|
10
|
-
this.maxStorage = uniqueKeysQueueSize;
|
|
11
|
-
this.uniqueKeysTracker = {};
|
|
12
|
-
}
|
|
13
|
-
UniqueKeysCacheInMemory.prototype.setOnFullQueueCb = function (cb) {
|
|
14
|
-
this.onFullQueue = cb;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Store unique keys in sequential order
|
|
18
|
-
* key: string = feature name.
|
|
19
|
-
* value: Set<string> = set of unique keys.
|
|
20
|
-
*/
|
|
21
|
-
UniqueKeysCacheInMemory.prototype.track = function (key, featureName) {
|
|
22
|
-
if (!this.uniqueKeysTracker[featureName])
|
|
23
|
-
this.uniqueKeysTracker[featureName] = new sets_1._Set();
|
|
24
|
-
var tracker = this.uniqueKeysTracker[featureName];
|
|
25
|
-
if (!tracker.has(key)) {
|
|
26
|
-
tracker.add(key);
|
|
27
|
-
this.uniqueTrackerSize++;
|
|
28
|
-
}
|
|
29
|
-
if (this.uniqueTrackerSize >= this.maxStorage && this.onFullQueue) {
|
|
30
|
-
this.uniqueTrackerSize = 0;
|
|
31
|
-
this.onFullQueue();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Clear the data stored on the cache.
|
|
36
|
-
*/
|
|
37
|
-
UniqueKeysCacheInMemory.prototype.clear = function () {
|
|
38
|
-
this.uniqueKeysTracker = {};
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Pop the collected data, used as payload for posting.
|
|
42
|
-
*/
|
|
43
|
-
UniqueKeysCacheInMemory.prototype.pop = function () {
|
|
44
|
-
var data = this.uniqueKeysTracker;
|
|
45
|
-
this.uniqueKeysTracker = {};
|
|
46
|
-
return this.fromUniqueKeysCollector(data);
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Check if the cache is empty.
|
|
50
|
-
*/
|
|
51
|
-
UniqueKeysCacheInMemory.prototype.isEmpty = function () {
|
|
52
|
-
return Object.keys(this.uniqueKeysTracker).length === 0;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Converts `uniqueKeys` data from cache into request payload for SS.
|
|
56
|
-
*/
|
|
57
|
-
UniqueKeysCacheInMemory.prototype.fromUniqueKeysCollector = function (uniqueKeys) {
|
|
58
|
-
var payload = [];
|
|
59
|
-
var featureNames = Object.keys(uniqueKeys);
|
|
60
|
-
for (var i = 0; i < featureNames.length; i++) {
|
|
61
|
-
var featureName = featureNames[i];
|
|
62
|
-
var featureKeys = (0, sets_1.setToArray)(uniqueKeys[featureName]);
|
|
63
|
-
var uniqueKeysPayload = {
|
|
64
|
-
f: featureName,
|
|
65
|
-
ks: featureKeys
|
|
66
|
-
};
|
|
67
|
-
payload.push(uniqueKeysPayload);
|
|
68
|
-
}
|
|
69
|
-
return { keys: payload };
|
|
70
|
-
};
|
|
71
|
-
return UniqueKeysCacheInMemory;
|
|
72
|
-
}());
|
|
73
|
-
exports.UniqueKeysCacheInMemory = UniqueKeysCacheInMemory;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UniqueKeysCacheInMemoryCS = void 0;
|
|
4
|
-
var sets_1 = require("../../utils/lang/sets");
|
|
5
|
-
var DEFAULT_CACHE_SIZE = 30000;
|
|
6
|
-
var UniqueKeysCacheInMemoryCS = /** @class */ (function () {
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param impressionsQueueSize number of queued impressions to call onFullQueueCb.
|
|
10
|
-
* Default value is 0, that means no maximum value, in case we want to avoid this being triggered.
|
|
11
|
-
*/
|
|
12
|
-
function UniqueKeysCacheInMemoryCS(uniqueKeysQueueSize) {
|
|
13
|
-
if (uniqueKeysQueueSize === void 0) { uniqueKeysQueueSize = DEFAULT_CACHE_SIZE; }
|
|
14
|
-
this.uniqueTrackerSize = 0;
|
|
15
|
-
this.maxStorage = uniqueKeysQueueSize;
|
|
16
|
-
this.uniqueKeysTracker = {};
|
|
17
|
-
}
|
|
18
|
-
UniqueKeysCacheInMemoryCS.prototype.setOnFullQueueCb = function (cb) {
|
|
19
|
-
this.onFullQueue = cb;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Store unique keys in sequential order
|
|
23
|
-
* key: string = key.
|
|
24
|
-
* value: HashSet<string> = set of split names.
|
|
25
|
-
*/
|
|
26
|
-
UniqueKeysCacheInMemoryCS.prototype.track = function (key, featureName) {
|
|
27
|
-
if (!this.uniqueKeysTracker[key])
|
|
28
|
-
this.uniqueKeysTracker[key] = new sets_1._Set();
|
|
29
|
-
var tracker = this.uniqueKeysTracker[key];
|
|
30
|
-
if (!tracker.has(featureName)) {
|
|
31
|
-
tracker.add(featureName);
|
|
32
|
-
this.uniqueTrackerSize++;
|
|
33
|
-
}
|
|
34
|
-
if (this.uniqueTrackerSize >= this.maxStorage && this.onFullQueue) {
|
|
35
|
-
this.uniqueTrackerSize = 0;
|
|
36
|
-
this.onFullQueue();
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Clear the data stored on the cache.
|
|
41
|
-
*/
|
|
42
|
-
UniqueKeysCacheInMemoryCS.prototype.clear = function () {
|
|
43
|
-
this.uniqueKeysTracker = {};
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Pop the collected data, used as payload for posting.
|
|
47
|
-
*/
|
|
48
|
-
UniqueKeysCacheInMemoryCS.prototype.pop = function () {
|
|
49
|
-
var data = this.uniqueKeysTracker;
|
|
50
|
-
this.uniqueKeysTracker = {};
|
|
51
|
-
return this.fromUniqueKeysCollector(data);
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Check if the cache is empty.
|
|
55
|
-
*/
|
|
56
|
-
UniqueKeysCacheInMemoryCS.prototype.isEmpty = function () {
|
|
57
|
-
return Object.keys(this.uniqueKeysTracker).length === 0;
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Converts `uniqueKeys` data from cache into request payload.
|
|
61
|
-
*/
|
|
62
|
-
UniqueKeysCacheInMemoryCS.prototype.fromUniqueKeysCollector = function (uniqueKeys) {
|
|
63
|
-
var payload = [];
|
|
64
|
-
var featureKeys = Object.keys(uniqueKeys);
|
|
65
|
-
for (var k = 0; k < featureKeys.length; k++) {
|
|
66
|
-
var featureKey = featureKeys[k];
|
|
67
|
-
var featureNames = (0, sets_1.setToArray)(uniqueKeys[featureKey]);
|
|
68
|
-
var uniqueKeysPayload = {
|
|
69
|
-
k: featureKey,
|
|
70
|
-
fs: featureNames
|
|
71
|
-
};
|
|
72
|
-
payload.push(uniqueKeysPayload);
|
|
73
|
-
}
|
|
74
|
-
return { keys: payload };
|
|
75
|
-
};
|
|
76
|
-
return UniqueKeysCacheInMemoryCS;
|
|
77
|
-
}());
|
|
78
|
-
exports.UniqueKeysCacheInMemoryCS = UniqueKeysCacheInMemoryCS;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uniqueKeysSubmitterFactory = void 0;
|
|
4
|
-
var constants_1 = require("../../logger/constants");
|
|
5
|
-
var submitter_1 = require("./submitter");
|
|
6
|
-
var DATA_NAME = 'uniqueKeys';
|
|
7
|
-
/**
|
|
8
|
-
* Submitter that periodically posts impression counts
|
|
9
|
-
*/
|
|
10
|
-
function uniqueKeysSubmitterFactory(params) {
|
|
11
|
-
var _a = params.settings, log = _a.log, uniqueKeysRefreshRate = _a.scheduler.uniqueKeysRefreshRate, key = _a.core.key, _b = params.splitApi, postUniqueKeysBulkCs = _b.postUniqueKeysBulkCs, postUniqueKeysBulkSs = _b.postUniqueKeysBulkSs, uniqueKeys = params.storage.uniqueKeys;
|
|
12
|
-
var isClientSide = key !== undefined;
|
|
13
|
-
var postUniqueKeysBulk = isClientSide ? postUniqueKeysBulkCs : postUniqueKeysBulkSs;
|
|
14
|
-
var syncTask = (0, submitter_1.submitterFactory)(log, postUniqueKeysBulk, uniqueKeys, uniqueKeysRefreshRate, 'unique keys');
|
|
15
|
-
// register unique keys submitter to be executed when uniqueKeys cache is full
|
|
16
|
-
uniqueKeys.setOnFullQueueCb(function () {
|
|
17
|
-
if (syncTask.isRunning()) {
|
|
18
|
-
log.info(constants_1.SUBMITTERS_PUSH_FULL_QUEUE, [DATA_NAME]);
|
|
19
|
-
syncTask.execute();
|
|
20
|
-
}
|
|
21
|
-
// If submitter is stopped (e.g., user consent declined or unknown, or app state offline), we don't send the data.
|
|
22
|
-
// Data will be sent when submitter is resumed.
|
|
23
|
-
});
|
|
24
|
-
return syncTask;
|
|
25
|
-
}
|
|
26
|
-
exports.uniqueKeysSubmitterFactory = uniqueKeysSubmitterFactory;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.strategyDebugFactory = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Debug strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
|
|
6
|
-
*
|
|
7
|
-
* @param impressionsObserver impression observer. Previous time (pt property) is included in impression instances
|
|
8
|
-
* @returns IStrategyResult
|
|
9
|
-
*/
|
|
10
|
-
function strategyDebugFactory(impressionsObserver) {
|
|
11
|
-
return {
|
|
12
|
-
process: function (impressions) {
|
|
13
|
-
impressions.forEach(function (impression) {
|
|
14
|
-
// Adds previous time if it is enabled
|
|
15
|
-
impression.pt = impressionsObserver.testAndSet(impression);
|
|
16
|
-
});
|
|
17
|
-
return {
|
|
18
|
-
impressionsToStore: impressions,
|
|
19
|
-
impressionsToListener: impressions,
|
|
20
|
-
deduped: 0
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
exports.strategyDebugFactory = strategyDebugFactory;
|
|
@@ -1,29 +0,0 @@
|
|
|
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;
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
impressionsCounter.track(impression.feature, now, 1);
|
|
21
|
-
// Checks if the impression should be added in queue to be sent
|
|
22
|
-
if (!impression.pt || impression.pt < (0, time_1.truncateTimeFrame)(now)) {
|
|
23
|
-
impressionsToStore.push(impression);
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
impressionsToStore: impressionsToStore,
|
|
28
|
-
impressionsToListener: impressions,
|
|
29
|
-
deduped: impressions.length - impressionsToStore.length
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.strategyOptimizedFactory = strategyOptimizedFactory;
|
|
@@ -1,31 +0,0 @@
|
|
|
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 filterAdapter filter adapter
|
|
17
|
-
* @param uniqueKeysCache cache to save unique keys
|
|
18
|
-
*/
|
|
19
|
-
function uniqueKeysTrackerFactory(log, uniqueKeysCache, filterAdapter) {
|
|
20
|
-
if (filterAdapter === void 0) { filterAdapter = noopFilterAdapter; }
|
|
21
|
-
return {
|
|
22
|
-
track: function (key, featureName) {
|
|
23
|
-
if (!filterAdapter.add(key, featureName)) {
|
|
24
|
-
log.debug(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER + "The feature " + featureName + " and key " + key + " exist in the filter");
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
uniqueKeysCache.track(key, featureName);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.uniqueKeysTrackerFactory = uniqueKeysTrackerFactory;
|
package/cjs/types.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { setToArray, _Set } from '../../utils/lang/sets';
|
|
2
|
-
var DEFAULT_CACHE_SIZE = 30000;
|
|
3
|
-
var UniqueKeysCacheInMemory = /** @class */ (function () {
|
|
4
|
-
function UniqueKeysCacheInMemory(uniqueKeysQueueSize) {
|
|
5
|
-
if (uniqueKeysQueueSize === void 0) { uniqueKeysQueueSize = DEFAULT_CACHE_SIZE; }
|
|
6
|
-
this.uniqueTrackerSize = 0;
|
|
7
|
-
this.maxStorage = uniqueKeysQueueSize;
|
|
8
|
-
this.uniqueKeysTracker = {};
|
|
9
|
-
}
|
|
10
|
-
UniqueKeysCacheInMemory.prototype.setOnFullQueueCb = function (cb) {
|
|
11
|
-
this.onFullQueue = cb;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Store unique keys in sequential order
|
|
15
|
-
* key: string = feature name.
|
|
16
|
-
* value: Set<string> = set of unique keys.
|
|
17
|
-
*/
|
|
18
|
-
UniqueKeysCacheInMemory.prototype.track = function (key, featureName) {
|
|
19
|
-
if (!this.uniqueKeysTracker[featureName])
|
|
20
|
-
this.uniqueKeysTracker[featureName] = new _Set();
|
|
21
|
-
var tracker = this.uniqueKeysTracker[featureName];
|
|
22
|
-
if (!tracker.has(key)) {
|
|
23
|
-
tracker.add(key);
|
|
24
|
-
this.uniqueTrackerSize++;
|
|
25
|
-
}
|
|
26
|
-
if (this.uniqueTrackerSize >= this.maxStorage && this.onFullQueue) {
|
|
27
|
-
this.uniqueTrackerSize = 0;
|
|
28
|
-
this.onFullQueue();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Clear the data stored on the cache.
|
|
33
|
-
*/
|
|
34
|
-
UniqueKeysCacheInMemory.prototype.clear = function () {
|
|
35
|
-
this.uniqueKeysTracker = {};
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Pop the collected data, used as payload for posting.
|
|
39
|
-
*/
|
|
40
|
-
UniqueKeysCacheInMemory.prototype.pop = function () {
|
|
41
|
-
var data = this.uniqueKeysTracker;
|
|
42
|
-
this.uniqueKeysTracker = {};
|
|
43
|
-
return this.fromUniqueKeysCollector(data);
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Check if the cache is empty.
|
|
47
|
-
*/
|
|
48
|
-
UniqueKeysCacheInMemory.prototype.isEmpty = function () {
|
|
49
|
-
return Object.keys(this.uniqueKeysTracker).length === 0;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Converts `uniqueKeys` data from cache into request payload for SS.
|
|
53
|
-
*/
|
|
54
|
-
UniqueKeysCacheInMemory.prototype.fromUniqueKeysCollector = function (uniqueKeys) {
|
|
55
|
-
var payload = [];
|
|
56
|
-
var featureNames = Object.keys(uniqueKeys);
|
|
57
|
-
for (var i = 0; i < featureNames.length; i++) {
|
|
58
|
-
var featureName = featureNames[i];
|
|
59
|
-
var featureKeys = setToArray(uniqueKeys[featureName]);
|
|
60
|
-
var uniqueKeysPayload = {
|
|
61
|
-
f: featureName,
|
|
62
|
-
ks: featureKeys
|
|
63
|
-
};
|
|
64
|
-
payload.push(uniqueKeysPayload);
|
|
65
|
-
}
|
|
66
|
-
return { keys: payload };
|
|
67
|
-
};
|
|
68
|
-
return UniqueKeysCacheInMemory;
|
|
69
|
-
}());
|
|
70
|
-
export { UniqueKeysCacheInMemory };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { setToArray, _Set } from '../../utils/lang/sets';
|
|
2
|
-
var DEFAULT_CACHE_SIZE = 30000;
|
|
3
|
-
var UniqueKeysCacheInMemoryCS = /** @class */ (function () {
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param impressionsQueueSize number of queued impressions to call onFullQueueCb.
|
|
7
|
-
* Default value is 0, that means no maximum value, in case we want to avoid this being triggered.
|
|
8
|
-
*/
|
|
9
|
-
function UniqueKeysCacheInMemoryCS(uniqueKeysQueueSize) {
|
|
10
|
-
if (uniqueKeysQueueSize === void 0) { uniqueKeysQueueSize = DEFAULT_CACHE_SIZE; }
|
|
11
|
-
this.uniqueTrackerSize = 0;
|
|
12
|
-
this.maxStorage = uniqueKeysQueueSize;
|
|
13
|
-
this.uniqueKeysTracker = {};
|
|
14
|
-
}
|
|
15
|
-
UniqueKeysCacheInMemoryCS.prototype.setOnFullQueueCb = function (cb) {
|
|
16
|
-
this.onFullQueue = cb;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Store unique keys in sequential order
|
|
20
|
-
* key: string = key.
|
|
21
|
-
* value: HashSet<string> = set of split names.
|
|
22
|
-
*/
|
|
23
|
-
UniqueKeysCacheInMemoryCS.prototype.track = function (key, featureName) {
|
|
24
|
-
if (!this.uniqueKeysTracker[key])
|
|
25
|
-
this.uniqueKeysTracker[key] = new _Set();
|
|
26
|
-
var tracker = this.uniqueKeysTracker[key];
|
|
27
|
-
if (!tracker.has(featureName)) {
|
|
28
|
-
tracker.add(featureName);
|
|
29
|
-
this.uniqueTrackerSize++;
|
|
30
|
-
}
|
|
31
|
-
if (this.uniqueTrackerSize >= this.maxStorage && this.onFullQueue) {
|
|
32
|
-
this.uniqueTrackerSize = 0;
|
|
33
|
-
this.onFullQueue();
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Clear the data stored on the cache.
|
|
38
|
-
*/
|
|
39
|
-
UniqueKeysCacheInMemoryCS.prototype.clear = function () {
|
|
40
|
-
this.uniqueKeysTracker = {};
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Pop the collected data, used as payload for posting.
|
|
44
|
-
*/
|
|
45
|
-
UniqueKeysCacheInMemoryCS.prototype.pop = function () {
|
|
46
|
-
var data = this.uniqueKeysTracker;
|
|
47
|
-
this.uniqueKeysTracker = {};
|
|
48
|
-
return this.fromUniqueKeysCollector(data);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Check if the cache is empty.
|
|
52
|
-
*/
|
|
53
|
-
UniqueKeysCacheInMemoryCS.prototype.isEmpty = function () {
|
|
54
|
-
return Object.keys(this.uniqueKeysTracker).length === 0;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Converts `uniqueKeys` data from cache into request payload.
|
|
58
|
-
*/
|
|
59
|
-
UniqueKeysCacheInMemoryCS.prototype.fromUniqueKeysCollector = function (uniqueKeys) {
|
|
60
|
-
var payload = [];
|
|
61
|
-
var featureKeys = Object.keys(uniqueKeys);
|
|
62
|
-
for (var k = 0; k < featureKeys.length; k++) {
|
|
63
|
-
var featureKey = featureKeys[k];
|
|
64
|
-
var featureNames = setToArray(uniqueKeys[featureKey]);
|
|
65
|
-
var uniqueKeysPayload = {
|
|
66
|
-
k: featureKey,
|
|
67
|
-
fs: featureNames
|
|
68
|
-
};
|
|
69
|
-
payload.push(uniqueKeysPayload);
|
|
70
|
-
}
|
|
71
|
-
return { keys: payload };
|
|
72
|
-
};
|
|
73
|
-
return UniqueKeysCacheInMemoryCS;
|
|
74
|
-
}());
|
|
75
|
-
export { UniqueKeysCacheInMemoryCS };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SUBMITTERS_PUSH_FULL_QUEUE } from '../../logger/constants';
|
|
2
|
-
import { submitterFactory } from './submitter';
|
|
3
|
-
var DATA_NAME = 'uniqueKeys';
|
|
4
|
-
/**
|
|
5
|
-
* Submitter that periodically posts impression counts
|
|
6
|
-
*/
|
|
7
|
-
export function uniqueKeysSubmitterFactory(params) {
|
|
8
|
-
var _a = params.settings, log = _a.log, uniqueKeysRefreshRate = _a.scheduler.uniqueKeysRefreshRate, key = _a.core.key, _b = params.splitApi, postUniqueKeysBulkCs = _b.postUniqueKeysBulkCs, postUniqueKeysBulkSs = _b.postUniqueKeysBulkSs, uniqueKeys = params.storage.uniqueKeys;
|
|
9
|
-
var isClientSide = key !== undefined;
|
|
10
|
-
var postUniqueKeysBulk = isClientSide ? postUniqueKeysBulkCs : postUniqueKeysBulkSs;
|
|
11
|
-
var syncTask = submitterFactory(log, postUniqueKeysBulk, uniqueKeys, uniqueKeysRefreshRate, 'unique keys');
|
|
12
|
-
// register unique keys submitter to be executed when uniqueKeys cache is full
|
|
13
|
-
uniqueKeys.setOnFullQueueCb(function () {
|
|
14
|
-
if (syncTask.isRunning()) {
|
|
15
|
-
log.info(SUBMITTERS_PUSH_FULL_QUEUE, [DATA_NAME]);
|
|
16
|
-
syncTask.execute();
|
|
17
|
-
}
|
|
18
|
-
// If submitter is stopped (e.g., user consent declined or unknown, or app state offline), we don't send the data.
|
|
19
|
-
// Data will be sent when submitter is resumed.
|
|
20
|
-
});
|
|
21
|
-
return syncTask;
|
|
22
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Debug strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
|
|
3
|
-
*
|
|
4
|
-
* @param impressionsObserver impression observer. Previous time (pt property) is included in impression instances
|
|
5
|
-
* @returns IStrategyResult
|
|
6
|
-
*/
|
|
7
|
-
export function strategyDebugFactory(impressionsObserver) {
|
|
8
|
-
return {
|
|
9
|
-
process: function (impressions) {
|
|
10
|
-
impressions.forEach(function (impression) {
|
|
11
|
-
// Adds previous time if it is enabled
|
|
12
|
-
impression.pt = impressionsObserver.testAndSet(impression);
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
impressionsToStore: impressions,
|
|
16
|
-
impressionsToListener: impressions,
|
|
17
|
-
deduped: 0
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* None strategy for impressions tracker.
|
|
3
|
-
*
|
|
4
|
-
* @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
|
|
5
|
-
* @param uniqueKeysTracker unique keys tracker in charge of tracking the unique keys per split.
|
|
6
|
-
* @returns IStrategyResult
|
|
7
|
-
*/
|
|
8
|
-
export function strategyNoneFactory(impressionsCounter, uniqueKeysTracker) {
|
|
9
|
-
return {
|
|
10
|
-
process: function (impressions) {
|
|
11
|
-
impressions.forEach(function (impression) {
|
|
12
|
-
var now = Date.now();
|
|
13
|
-
// Increments impression counter per featureName
|
|
14
|
-
impressionsCounter.track(impression.feature, now, 1);
|
|
15
|
-
// Keep track by unique key
|
|
16
|
-
uniqueKeysTracker.track(impression.keyName, impression.feature);
|
|
17
|
-
});
|
|
18
|
-
return {
|
|
19
|
-
impressionsToStore: [],
|
|
20
|
-
impressionsToListener: impressions,
|
|
21
|
-
deduped: 0
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { truncateTimeFrame } from '../../utils/time';
|
|
2
|
-
/**
|
|
3
|
-
* Optimized strategy for impressions tracker. Wraps impressions to store and adds previousTime if it corresponds
|
|
4
|
-
*
|
|
5
|
-
* @param impressionsObserver impression observer. previous time (pt property) is included in impression instances
|
|
6
|
-
* @param impressionsCounter cache to save impressions count. impressions will be deduped (OPTIMIZED mode)
|
|
7
|
-
* @returns IStrategyResult
|
|
8
|
-
*/
|
|
9
|
-
export function strategyOptimizedFactory(impressionsObserver, impressionsCounter) {
|
|
10
|
-
return {
|
|
11
|
-
process: function (impressions) {
|
|
12
|
-
var impressionsToStore = [];
|
|
13
|
-
impressions.forEach(function (impression) {
|
|
14
|
-
impression.pt = impressionsObserver.testAndSet(impression);
|
|
15
|
-
var now = Date.now();
|
|
16
|
-
// Increments impression counter per featureName
|
|
17
|
-
impressionsCounter.track(impression.feature, now, 1);
|
|
18
|
-
// Checks if the impression should be added in queue to be sent
|
|
19
|
-
if (!impression.pt || impression.pt < truncateTimeFrame(now)) {
|
|
20
|
-
impressionsToStore.push(impression);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
impressionsToStore: impressionsToStore,
|
|
25
|
-
impressionsToListener: impressions,
|
|
26
|
-
deduped: impressions.length - impressionsToStore.length
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { LOG_PREFIX_UNIQUE_KEYS_TRACKER } from '../logger/constants';
|
|
2
|
-
var noopFilterAdapter = {
|
|
3
|
-
add: function () { return true; },
|
|
4
|
-
contains: function () { return true; },
|
|
5
|
-
clear: function () { }
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Trackes uniques keys
|
|
9
|
-
* Unique Keys Tracker will be in charge of checking if the MTK was already sent to the BE in the last period
|
|
10
|
-
* or schedule to be sent; if not it will be added in an internal cache and sent in the next post.
|
|
11
|
-
*
|
|
12
|
-
* @param log Logger instance
|
|
13
|
-
* @param filterAdapter filter adapter
|
|
14
|
-
* @param uniqueKeysCache cache to save unique keys
|
|
15
|
-
*/
|
|
16
|
-
export function uniqueKeysTrackerFactory(log, uniqueKeysCache, filterAdapter) {
|
|
17
|
-
if (filterAdapter === void 0) { filterAdapter = noopFilterAdapter; }
|
|
18
|
-
return {
|
|
19
|
-
track: function (key, featureName) {
|
|
20
|
-
if (!filterAdapter.add(key, featureName)) {
|
|
21
|
-
log.debug(LOG_PREFIX_UNIQUE_KEYS_TRACKER + "The feature " + featureName + " and key " + key + " exist in the filter");
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
uniqueKeysCache.track(key, featureName);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
package/esm/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|