@splitsoftware/splitio-commons 1.6.2-rc.0 → 1.6.2-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.txt +4 -0
- package/cjs/consent/sdkUserConsent.js +2 -2
- package/cjs/evaluator/index.js +15 -16
- 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/client.js +19 -7
- package/cjs/sdkClient/sdkClient.js +3 -1
- package/cjs/sdkFactory/index.js +24 -7
- package/cjs/sdkManager/index.js +3 -11
- package/cjs/services/splitApi.js +24 -4
- package/cjs/storages/AbstractSplitsCacheAsync.js +8 -10
- package/cjs/storages/AbstractSplitsCacheSync.js +8 -10
- package/cjs/storages/KeyBuilderSS.js +54 -9
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +5 -7
- package/cjs/storages/inLocalStorage/index.js +5 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +12 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +6 -2
- package/cjs/storages/inMemory/InMemoryStorageCS.js +6 -2
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +7 -10
- package/cjs/storages/inMemory/TelemetryCacheInMemory.js +10 -5
- package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +73 -0
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +78 -0
- package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +50 -0
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +15 -9
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +100 -0
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +59 -0
- package/cjs/storages/inRedis/constants.js +4 -1
- package/cjs/storages/inRedis/index.js +17 -2
- package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +43 -0
- package/cjs/storages/pluggable/SplitsCachePluggable.js +14 -9
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +126 -0
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +50 -0
- package/cjs/storages/pluggable/index.js +42 -17
- 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 +8 -4
- package/cjs/sync/submitters/uniqueKeysSubmitter.js +27 -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/utils/constants/index.js +4 -2
- package/cjs/utils/lang/maps.js +15 -7
- package/cjs/utils/redis/RedisMock.js +31 -0
- package/cjs/utils/settingsValidation/impressionsMode.js +2 -2
- package/esm/consent/sdkUserConsent.js +2 -2
- package/esm/evaluator/index.js +15 -16
- 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/client.js +19 -7
- package/esm/sdkClient/sdkClient.js +3 -1
- package/esm/sdkFactory/index.js +24 -7
- package/esm/sdkManager/index.js +3 -11
- package/esm/services/splitApi.js +24 -4
- package/esm/storages/AbstractSplitsCacheAsync.js +8 -10
- package/esm/storages/AbstractSplitsCacheSync.js +8 -10
- package/esm/storages/KeyBuilderSS.js +50 -8
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +5 -7
- package/esm/storages/inLocalStorage/index.js +6 -2
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +12 -1
- package/esm/storages/inMemory/InMemoryStorage.js +8 -4
- package/esm/storages/inMemory/InMemoryStorageCS.js +7 -3
- package/esm/storages/inMemory/SplitsCacheInMemory.js +7 -10
- package/esm/storages/inMemory/TelemetryCacheInMemory.js +9 -5
- package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +70 -0
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +75 -0
- package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +47 -0
- package/esm/storages/inRedis/SplitsCacheInRedis.js +15 -9
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +100 -0
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +56 -0
- package/esm/storages/inRedis/constants.js +3 -0
- package/esm/storages/inRedis/index.js +18 -3
- package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +40 -0
- package/esm/storages/pluggable/SplitsCachePluggable.js +14 -9
- package/esm/storages/pluggable/TelemetryCachePluggable.js +126 -0
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +47 -0
- package/esm/storages/pluggable/index.js +43 -18
- 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 +9 -5
- package/esm/sync/submitters/uniqueKeysSubmitter.js +23 -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/utils/constants/index.js +2 -0
- package/esm/utils/lang/maps.js +15 -7
- package/esm/utils/redis/RedisMock.js +28 -0
- package/esm/utils/settingsValidation/impressionsMode.js +3 -3
- package/package.json +1 -2
- package/src/consent/sdkUserConsent.ts +2 -2
- package/src/evaluator/index.ts +14 -15
- package/src/integrations/ga/GaToSplit.ts +9 -5
- package/src/integrations/types.ts +2 -1
- package/src/listeners/browser.ts +3 -2
- package/src/logger/constants.ts +1 -0
- package/src/sdkClient/client.ts +21 -8
- package/src/sdkClient/sdkClient.ts +3 -1
- package/src/sdkFactory/index.ts +28 -8
- package/src/sdkFactory/types.ts +7 -4
- package/src/sdkManager/index.ts +3 -12
- package/src/services/splitApi.ts +26 -4
- package/src/services/types.ts +8 -2
- package/src/storages/AbstractSplitsCacheAsync.ts +13 -15
- package/src/storages/AbstractSplitsCacheSync.ts +15 -17
- package/src/storages/KeyBuilderSS.ts +61 -9
- package/src/storages/dataLoader.ts +1 -1
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +8 -11
- package/src/storages/inLocalStorage/index.ts +5 -2
- package/src/storages/inMemory/ImpressionCountsCacheInMemory.ts +16 -1
- package/src/storages/inMemory/InMemoryStorage.ts +7 -4
- package/src/storages/inMemory/InMemoryStorageCS.ts +6 -3
- package/src/storages/inMemory/SplitsCacheInMemory.ts +10 -14
- package/src/storages/inMemory/TelemetryCacheInMemory.ts +10 -6
- package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +82 -0
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +88 -0
- package/src/storages/inRedis/EventsCacheInRedis.ts +1 -1
- package/src/storages/inRedis/ImpressionCountsCacheInRedis.ts +53 -0
- package/src/storages/inRedis/SplitsCacheInRedis.ts +21 -17
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +122 -2
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +65 -0
- package/src/storages/inRedis/constants.ts +3 -0
- package/src/storages/inRedis/index.ts +15 -5
- package/src/storages/pluggable/ImpressionCountsCachePluggable.ts +47 -0
- package/src/storages/pluggable/SplitsCachePluggable.ts +20 -17
- package/src/storages/pluggable/TelemetryCachePluggable.ts +147 -2
- package/src/storages/pluggable/UniqueKeysCachePluggable.ts +56 -0
- package/src/storages/pluggable/index.ts +44 -19
- package/src/storages/types.ts +50 -29
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +5 -6
- package/src/sync/polling/updaters/splitChangesUpdater.ts +2 -2
- package/src/sync/submitters/submitterManager.ts +2 -0
- package/src/sync/submitters/telemetrySubmitter.ts +15 -8
- package/src/sync/submitters/types.ts +38 -7
- package/src/sync/submitters/uniqueKeysSubmitter.ts +36 -0
- package/src/trackers/impressionsTracker.ts +27 -48
- 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 +32 -0
- package/src/trackers/uniqueKeysTracker.ts +48 -0
- package/src/types.ts +1 -1
- package/src/utils/constants/index.ts +2 -0
- package/src/utils/lang/maps.ts +20 -8
- package/src/utils/redis/RedisMock.ts +33 -0
- package/src/utils/settingsValidation/impressionsMode.ts +3 -3
- package/src/utils/settingsValidation/index.ts +1 -0
- package/types/integrations/types.d.ts +2 -1
- package/types/logger/browser/{debugLogger.d.ts → DebugLogger.d.ts} +0 -0
- package/types/logger/browser/{errorLogger.d.ts → ErrorLogger.d.ts} +0 -0
- package/types/logger/browser/{infoLogger.d.ts → InfoLogger.d.ts} +0 -0
- package/types/logger/browser/{warnLogger.d.ts → WarnLogger.d.ts} +0 -0
- package/types/logger/constants.d.ts +1 -0
- package/types/sdkFactory/types.d.ts +4 -2
- package/types/services/types.d.ts +6 -2
- package/types/storages/AbstractSplitsCacheAsync.d.ts +7 -6
- package/types/storages/AbstractSplitsCacheSync.d.ts +6 -6
- package/types/storages/KeyBuilderSS.d.ts +9 -2
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +3 -4
- package/types/storages/inMemory/ImpressionCountsCacheInMemory.d.ts +5 -1
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +3 -2
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +6 -3
- package/types/storages/inMemory/uniqueKeysCacheInMemory.d.ts +35 -0
- package/types/storages/inMemory/uniqueKeysCacheInMemoryCS.d.ts +37 -0
- package/types/storages/inRedis/EventsCacheInRedis.d.ts +1 -1
- package/types/storages/inRedis/ImpressionCountsCacheInRedis.d.ts +14 -0
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +6 -5
- package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +16 -1
- package/types/storages/inRedis/constants.d.ts +3 -0
- package/types/storages/inRedis/uniqueKeysCacheInRedis.d.ts +15 -0
- package/types/storages/pluggable/ImpressionCountsCachePluggable.d.ts +14 -0
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +6 -5
- package/types/storages/pluggable/TelemetryCachePluggable.d.ts +17 -1
- package/types/storages/pluggable/UniqueKeysCachePluggable.d.ts +14 -0
- package/types/storages/types.d.ts +38 -25
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -1
- package/types/sync/submitters/telemetrySubmitter.d.ts +1 -1
- package/types/sync/submitters/types.d.ts +30 -7
- package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -8
- package/types/trackers/impressionsTracker.d.ts +4 -6
- package/types/trackers/types.d.ts +27 -0
- package/types/trackers/uniqueKeysTracker.d.ts +3 -3
- package/types/types.d.ts +1 -1
- package/types/utils/constants/index.d.ts +2 -0
- package/types/utils/lang/maps.d.ts +6 -2
- package/types/utils/redis/RedisMock.d.ts +4 -0
- package/src/splitio.d.ts +0 -1602
- package/types/integrations/ga/GaToSplitPlugin.d.ts +0 -3
- package/types/integrations/ga/SplitToGaPlugin.d.ts +0 -4
- package/types/integrations/ga/autoRequire.d.ts +0 -4
- package/types/logger/codes.d.ts +0 -2
- package/types/logger/codesConstants.d.ts +0 -117
- package/types/logger/codesConstantsBrowser.d.ts +0 -2
- package/types/logger/codesConstantsNode.d.ts +0 -14
- package/types/logger/codesDebug.d.ts +0 -1
- package/types/logger/codesDebugBrowser.d.ts +0 -1
- package/types/logger/codesDebugNode.d.ts +0 -1
- package/types/logger/codesError.d.ts +0 -1
- package/types/logger/codesErrorNode.d.ts +0 -1
- package/types/logger/codesInfo.d.ts +0 -1
- package/types/logger/codesWarn.d.ts +0 -1
- package/types/logger/codesWarnNode.d.ts +0 -1
- package/types/logger/debugLogger.d.ts +0 -2
- package/types/logger/errorLogger.d.ts +0 -2
- package/types/logger/infoLogger.d.ts +0 -2
- package/types/logger/messages/debugBrowser.d.ts +0 -1
- package/types/logger/messages/debugNode.d.ts +0 -1
- package/types/logger/messages/errorNode.d.ts +0 -1
- package/types/logger/messages/warnNode.d.ts +0 -1
- package/types/logger/noopLogger.d.ts +0 -2
- package/types/logger/warnLogger.d.ts +0 -2
- package/types/sdkClient/types.d.ts +0 -18
- package/types/sdkFactory/userConsentProps.d.ts +0 -6
- package/types/sdkManager/sdkManagerMethod.d.ts +0 -6
- package/types/storages/getRegisteredSegments.d.ts +0 -10
- package/types/storages/inMemory/CountsCacheInMemory.d.ts +0 -20
- package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +0 -20
- package/types/storages/inMemory/index.d.ts +0 -10
- package/types/storages/inRedis/CountsCacheInRedis.d.ts +0 -9
- package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +0 -9
- package/types/storages/parseSegments.d.ts +0 -6
- package/types/sync/offline/LocalhostFromFile.d.ts +0 -2
- package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +0 -2
- package/types/sync/polling/syncTasks/splitsSyncTask.copy.d.ts +0 -35
- package/types/sync/polling/syncTasks/splitsSyncTask.morelikeoriginal.d.ts +0 -35
- package/types/sync/streaming/AuthClient/indexV1.d.ts +0 -12
- package/types/sync/streaming/AuthClient/indexV2.d.ts +0 -8
- package/types/sync/streaming/pushManagerCS.d.ts +0 -1
- package/types/sync/streaming/pushManagerNoUsers.d.ts +0 -13
- package/types/sync/streaming/pushManagerSS.d.ts +0 -1
- 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/telemetrySyncTask.d.ts +0 -0
- package/types/sync/syncManagerFromFile.d.ts +0 -2
- package/types/sync/syncManagerFromObject.d.ts +0 -2
- package/types/sync/syncManagerOffline.d.ts +0 -9
- package/types/sync/syncTaskComposite.d.ts +0 -5
- package/types/trackers/telemetryRecorder.d.ts +0 -0
- package/types/utils/EventEmitter.d.ts +0 -4
- package/types/utils/consent.d.ts +0 -2
- package/types/utils/lang/errors.d.ts +0 -10
- package/types/utils/murmur3/commons.d.ts +0 -12
- package/types/utils/settingsValidation/buildMetadata.d.ts +0 -3
- package/types/utils/settingsValidation/localhost/index.d.ts +0 -9
- package/types/utils/settingsValidation/logger.d.ts +0 -11
- package/types/utils/settingsValidation/runtime/browser.d.ts +0 -2
- package/types/utils/settingsValidation/runtime/node.d.ts +0 -2
- package/types/utils/settingsValidation/userConsent.d.ts +0 -5
- package/types/utils/timeTracker/index.d.ts +0 -1
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.impressionsTrackerFactory = void 0;
|
|
4
4
|
var objectAssign_1 = require("../utils/lang/objectAssign");
|
|
5
5
|
var thenable_1 = require("../utils/promise/thenable");
|
|
6
|
-
var time_1 = require("../utils/time");
|
|
7
6
|
var constants_1 = require("../logger/constants");
|
|
8
7
|
var constants_2 = require("../utils/constants");
|
|
9
8
|
/**
|
|
@@ -13,52 +12,34 @@ var constants_2 = require("../utils/constants");
|
|
|
13
12
|
* @param metadata runtime metadata (ip, hostname and version)
|
|
14
13
|
* @param impressionListener optional impression listener
|
|
15
14
|
* @param integrationsManager optional integrations manager
|
|
16
|
-
* @param
|
|
17
|
-
* @param countsCache optional cache to save impressions count. If provided, impressions will be deduped (OPTIMIZED mode)
|
|
15
|
+
* @param strategy strategy for impressions tracking.
|
|
18
16
|
*/
|
|
19
|
-
function impressionsTrackerFactory(settings, impressionsCache, integrationsManager,
|
|
20
|
-
// if observer is provided, it implies `shouldAddPreviousTime` flag (i.e., if impressions previous time should be added or not)
|
|
21
|
-
observer,
|
|
22
|
-
// if countsCache is provided, it implies `isOptimized` flag (i.e., if impressions should be deduped or not)
|
|
23
|
-
countsCache, telemetryCache) {
|
|
17
|
+
function impressionsTrackerFactory(settings, impressionsCache, strategy, integrationsManager, telemetryCache) {
|
|
24
18
|
var log = settings.log, impressionListener = settings.impressionListener, _a = settings.runtime, ip = _a.ip, hostname = _a.hostname, version = settings.version;
|
|
25
19
|
return {
|
|
26
20
|
track: function (impressions, attributes) {
|
|
27
21
|
if (settings.userConsent === constants_2.CONSENT_DECLINED)
|
|
28
22
|
return;
|
|
29
23
|
var impressionsCount = impressions.length;
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
var _a = strategy.process(impressions), impressionsToStore = _a.impressionsToStore, impressionsToListener = _a.impressionsToListener, deduped = _a.deduped;
|
|
25
|
+
var impressionsToListenerCount = impressionsToListener.length;
|
|
26
|
+
if (impressionsToStore.length > 0) {
|
|
27
|
+
var res = impressionsCache.track(impressionsToStore);
|
|
28
|
+
// If we're on an async storage, handle error and log it.
|
|
29
|
+
if ((0, thenable_1.thenable)(res)) {
|
|
30
|
+
res.then(function () {
|
|
31
|
+
log.info(constants_1.IMPRESSIONS_TRACKER_SUCCESS, [impressionsCount]);
|
|
32
|
+
}).catch(function (err) {
|
|
33
|
+
log.error(constants_1.ERROR_IMPRESSIONS_TRACKER, [impressionsCount, err]);
|
|
34
|
+
});
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
impressionsToStore.push(impression);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
var res = impressionsCache.track(impressionsToStore);
|
|
48
|
-
// If we're on an async storage, handle error and log it.
|
|
49
|
-
if ((0, thenable_1.thenable)(res)) {
|
|
50
|
-
res.then(function () {
|
|
51
|
-
log.info(constants_1.IMPRESSIONS_TRACKER_SUCCESS, [impressionsCount]);
|
|
52
|
-
}).catch(function (err) {
|
|
53
|
-
log.error(constants_1.ERROR_IMPRESSIONS_TRACKER, [impressionsCount, err]);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
// Record when impressionsCache is sync only (standalone mode)
|
|
58
|
-
// @TODO we are not dropping impressions on full queue yet, so DROPPED stats are not recorded
|
|
59
|
-
if (telemetryCache) {
|
|
60
|
-
telemetryCache.recordImpressionStats(constants_2.QUEUED, impressionsToStore.length);
|
|
61
|
-
telemetryCache.recordImpressionStats(constants_2.DEDUPED, impressions.length - impressionsToStore.length);
|
|
36
|
+
else {
|
|
37
|
+
// Record when impressionsCache is sync only (standalone mode)
|
|
38
|
+
// @TODO we are not dropping impressions on full queue yet, so DROPPED stats are not recorded
|
|
39
|
+
if (telemetryCache) {
|
|
40
|
+
telemetryCache.recordImpressionStats(constants_2.QUEUED, impressionsToStore.length);
|
|
41
|
+
telemetryCache.recordImpressionStats(constants_2.DEDUPED, deduped);
|
|
42
|
+
}
|
|
62
43
|
}
|
|
63
44
|
}
|
|
64
45
|
// @TODO next block might be handled by the integration manager. In that case, the metadata object doesn't need to be passed in the constructor
|
|
@@ -66,7 +47,7 @@ countsCache, telemetryCache) {
|
|
|
66
47
|
var _loop_1 = function (i) {
|
|
67
48
|
var impressionData = {
|
|
68
49
|
// copy of impression, to avoid unexpected behaviour if modified by integrations or impressionListener
|
|
69
|
-
impression: (0, objectAssign_1.objectAssign)({},
|
|
50
|
+
impression: (0, objectAssign_1.objectAssign)({}, impressionsToListener[i]),
|
|
70
51
|
attributes: attributes,
|
|
71
52
|
ip: ip,
|
|
72
53
|
hostname: hostname,
|
|
@@ -86,7 +67,7 @@ countsCache, telemetryCache) {
|
|
|
86
67
|
}
|
|
87
68
|
}, 0);
|
|
88
69
|
};
|
|
89
|
-
for (var i = 0; i <
|
|
70
|
+
for (var i = 0; i < impressionsToListenerCount; i++) {
|
|
90
71
|
_loop_1(i);
|
|
91
72
|
}
|
|
92
73
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -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;
|
|
@@ -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/lang/maps.js
CHANGED
|
@@ -40,13 +40,6 @@ var MapPoly = /** @class */ (function () {
|
|
|
40
40
|
this.__mapKeysData__.length = 0;
|
|
41
41
|
this.__mapValuesData__.length = 0;
|
|
42
42
|
};
|
|
43
|
-
MapPoly.prototype.set = function (key, value) {
|
|
44
|
-
var index = this.__mapKeysData__.indexOf(key);
|
|
45
|
-
if (index === -1)
|
|
46
|
-
index = this.__mapKeysData__.push(key) - 1;
|
|
47
|
-
this.__mapValuesData__[index] = value;
|
|
48
|
-
return this;
|
|
49
|
-
};
|
|
50
43
|
MapPoly.prototype.delete = function (key) {
|
|
51
44
|
var index = this.__mapKeysData__.indexOf(key);
|
|
52
45
|
if (index === -1)
|
|
@@ -55,12 +48,27 @@ var MapPoly = /** @class */ (function () {
|
|
|
55
48
|
this.__mapValuesData__.splice(index, 1);
|
|
56
49
|
return true;
|
|
57
50
|
};
|
|
51
|
+
MapPoly.prototype.forEach = function (callbackfn, thisArg) {
|
|
52
|
+
for (var i = 0; i < this.__mapKeysData__.length; i++) {
|
|
53
|
+
callbackfn.call(thisArg, this.__mapValuesData__[i], this.__mapKeysData__[i], this);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
58
56
|
MapPoly.prototype.get = function (key) {
|
|
59
57
|
var index = this.__mapKeysData__.indexOf(key);
|
|
60
58
|
if (index === -1)
|
|
61
59
|
return;
|
|
62
60
|
return this.__mapValuesData__[index];
|
|
63
61
|
};
|
|
62
|
+
MapPoly.prototype.has = function (key) {
|
|
63
|
+
return this.__mapKeysData__.indexOf(key) !== -1;
|
|
64
|
+
};
|
|
65
|
+
MapPoly.prototype.set = function (key, value) {
|
|
66
|
+
var index = this.__mapKeysData__.indexOf(key);
|
|
67
|
+
if (index === -1)
|
|
68
|
+
index = this.__mapKeysData__.push(key) - 1;
|
|
69
|
+
this.__mapValuesData__[index] = value;
|
|
70
|
+
return this;
|
|
71
|
+
};
|
|
64
72
|
Object.defineProperty(MapPoly.prototype, "size", {
|
|
65
73
|
get: function () {
|
|
66
74
|
return this.__mapKeysData__.length;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisMock = void 0;
|
|
4
|
+
//@ts-nocheck
|
|
5
|
+
function identityFunction(data) {
|
|
6
|
+
return data;
|
|
7
|
+
}
|
|
8
|
+
function asyncFunction(data) {
|
|
9
|
+
return Promise.resolve(data);
|
|
10
|
+
}
|
|
11
|
+
var IDENTITY_METHODS = [];
|
|
12
|
+
var ASYNC_METHODS = ['rpush', 'hincrby'];
|
|
13
|
+
var PIPELINE_METHODS = ['rpush', 'hincrby'];
|
|
14
|
+
var RedisMock = /** @class */ (function () {
|
|
15
|
+
function RedisMock() {
|
|
16
|
+
var _this = this;
|
|
17
|
+
this.pipelineMethods = { exec: jest.fn(asyncFunction) };
|
|
18
|
+
IDENTITY_METHODS.forEach(function (method) {
|
|
19
|
+
_this[method] = jest.fn(identityFunction);
|
|
20
|
+
});
|
|
21
|
+
ASYNC_METHODS.forEach(function (method) {
|
|
22
|
+
_this[method] = jest.fn(asyncFunction);
|
|
23
|
+
});
|
|
24
|
+
PIPELINE_METHODS.forEach(function (method) {
|
|
25
|
+
_this.pipelineMethods[method] = _this[method];
|
|
26
|
+
});
|
|
27
|
+
this.pipeline = jest.fn(function () { return _this.pipelineMethods; });
|
|
28
|
+
}
|
|
29
|
+
return RedisMock;
|
|
30
|
+
}());
|
|
31
|
+
exports.RedisMock = RedisMock;
|
|
@@ -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;
|
|
@@ -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
|
@@ -15,61 +15,60 @@ function treatmentsException(splitNames) {
|
|
|
15
15
|
return evaluations;
|
|
16
16
|
}
|
|
17
17
|
export function evaluateFeature(log, key, splitName, attributes, storage) {
|
|
18
|
-
var
|
|
18
|
+
var parsedSplit;
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
parsedSplit = storage.splits.getSplit(splitName);
|
|
21
21
|
}
|
|
22
22
|
catch (e) {
|
|
23
23
|
// Exception on sync `getSplit` storage. Not possible ATM with InMemory and InLocal storages.
|
|
24
24
|
return treatmentException;
|
|
25
25
|
}
|
|
26
|
-
if (thenable(
|
|
27
|
-
return
|
|
26
|
+
if (thenable(parsedSplit)) {
|
|
27
|
+
return parsedSplit.then(function (split) { return getEvaluation(log, split, key, attributes, storage); }).catch(
|
|
28
28
|
// Exception on async `getSplit` storage. For example, when the storage is redis or
|
|
29
29
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
30
30
|
function () { return treatmentException; });
|
|
31
31
|
}
|
|
32
|
-
return getEvaluation(log,
|
|
32
|
+
return getEvaluation(log, parsedSplit, 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: ';
|
package/esm/sdkClient/client.js
CHANGED
|
@@ -6,6 +6,15 @@ import { validateTrafficTypeExistance } from '../utils/inputValidation/trafficTy
|
|
|
6
6
|
import { SDK_NOT_READY } from '../utils/labels';
|
|
7
7
|
import { CONTROL, TREATMENT, TREATMENTS, TREATMENT_WITH_CONFIG, TREATMENTS_WITH_CONFIG, TRACK } from '../utils/constants';
|
|
8
8
|
import { IMPRESSION, IMPRESSION_QUEUEING } from '../logger/constants';
|
|
9
|
+
import { isStorageSync } from '../trackers/impressionObserver/utils';
|
|
10
|
+
var treatmentNotReady = { treatment: CONTROL, label: SDK_NOT_READY };
|
|
11
|
+
function treatmentsNotReady(splitNames) {
|
|
12
|
+
var evaluations = {};
|
|
13
|
+
splitNames.forEach(function (splitName) {
|
|
14
|
+
evaluations[splitName] = treatmentNotReady;
|
|
15
|
+
});
|
|
16
|
+
return evaluations;
|
|
17
|
+
}
|
|
9
18
|
/**
|
|
10
19
|
* Creator of base client with getTreatments and track methods.
|
|
11
20
|
*/
|
|
@@ -22,7 +31,11 @@ export function clientFactory(params) {
|
|
|
22
31
|
stopTelemetryTracker(queue[0] && queue[0].label);
|
|
23
32
|
return treatment;
|
|
24
33
|
};
|
|
25
|
-
var evaluation =
|
|
34
|
+
var evaluation = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
|
|
35
|
+
evaluateFeature(log, key, splitName, attributes, storage) :
|
|
36
|
+
isStorageSync(settings) ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
|
|
37
|
+
treatmentNotReady :
|
|
38
|
+
Promise.resolve(treatmentNotReady); // Promisify if async
|
|
26
39
|
return thenable(evaluation) ? evaluation.then(function (res) { return wrapUp(res); }) : wrapUp(evaluation);
|
|
27
40
|
}
|
|
28
41
|
function getTreatmentWithConfig(key, splitName, attributes) {
|
|
@@ -41,7 +54,11 @@ export function clientFactory(params) {
|
|
|
41
54
|
stopTelemetryTracker(queue[0] && queue[0].label);
|
|
42
55
|
return treatments;
|
|
43
56
|
};
|
|
44
|
-
var evaluations =
|
|
57
|
+
var evaluations = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
|
|
58
|
+
evaluateFeatures(log, key, splitNames, attributes, storage) :
|
|
59
|
+
isStorageSync(settings) ? // If the SDK is not ready, treatment may be incorrect due to having splits but not segments data, or storage is not connected
|
|
60
|
+
treatmentsNotReady(splitNames) :
|
|
61
|
+
Promise.resolve(treatmentsNotReady(splitNames)); // Promisify if async
|
|
45
62
|
return thenable(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
|
|
46
63
|
}
|
|
47
64
|
function getTreatmentsWithConfig(key, splitNames, attributes) {
|
|
@@ -49,13 +66,8 @@ export function clientFactory(params) {
|
|
|
49
66
|
}
|
|
50
67
|
// Internal function
|
|
51
68
|
function processEvaluation(evaluation, splitName, key, attributes, withConfig, invokingMethodName, queue) {
|
|
52
|
-
var isSdkReady = readinessManager.isReady() || readinessManager.isReadyFromCache();
|
|
53
69
|
var matchingKey = getMatching(key);
|
|
54
70
|
var bucketingKey = getBucketing(key);
|
|
55
|
-
// If the SDK was not ready, treatment may be incorrect due to having Splits but not segments data.
|
|
56
|
-
if (!isSdkReady) {
|
|
57
|
-
evaluation = { treatment: CONTROL, label: SDK_NOT_READY };
|
|
58
|
-
}
|
|
59
71
|
var treatment = evaluation.treatment, label = evaluation.label, changeNumber = evaluation.changeNumber, _a = evaluation.config, config = _a === void 0 ? null : _a;
|
|
60
72
|
log.info(IMPRESSION, [splitName, matchingKey, treatment, label]);
|
|
61
73
|
if (validateSplitExistance(log, readinessManager, splitName, label, invokingMethodName)) {
|
|
@@ -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
|
});
|