@splitsoftware/splitio-commons 2.11.1-rc.2 → 2.12.1
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 +6 -2
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +3 -3
- package/cjs/evaluator/fallbackTreatmentsCalculator/index.js +21 -32
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/integrations/pluggable.js +1 -1
- package/cjs/listeners/node.js +2 -2
- package/cjs/logger/constants.js +3 -4
- package/cjs/logger/index.js +1 -1
- package/cjs/logger/messages/debug.js +1 -1
- package/cjs/logger/messages/error.js +1 -1
- package/cjs/logger/messages/info.js +2 -3
- package/cjs/logger/messages/warn.js +4 -4
- package/cjs/sdkClient/client.js +2 -3
- package/cjs/sdkClient/clientAttributesDecoration.js +3 -3
- package/cjs/sdkClient/clientInputValidation.js +36 -68
- package/cjs/sdkClient/identity.js +1 -1
- package/cjs/sdkClient/sdkClient.js +19 -7
- package/cjs/sdkFactory/index.js +8 -41
- package/cjs/services/splitApi.js +13 -13
- package/cjs/services/splitHttpClient.js +1 -1
- package/cjs/storages/KeyBuilder.js +12 -12
- package/cjs/storages/KeyBuilderCS.js +13 -13
- package/cjs/storages/KeyBuilderSS.js +15 -15
- package/cjs/storages/getRolloutPlan.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +1 -1
- package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -5
- package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +8 -8
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -6
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +6 -6
- package/cjs/storages/pluggable/SplitsCachePluggable.js +4 -4
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
- package/cjs/storages/pluggable/index.js +3 -3
- package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
- package/cjs/storages/setRolloutPlan.js +3 -3
- package/cjs/storages/utils.js +6 -6
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerSS.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +12 -10
- package/cjs/sync/streaming/SSEClient/index.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/parseUtils.js +1 -1
- package/cjs/sync/submitters/submitter.js +1 -1
- package/cjs/trackers/eventTracker.js +10 -12
- package/cjs/trackers/impressionObserver/buildKey.js +1 -1
- package/cjs/trackers/impressionsTracker.js +37 -20
- package/cjs/trackers/uniqueKeysTracker.js +1 -1
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +2 -2
- package/cjs/utils/inputValidation/eventProperties.js +1 -1
- package/cjs/utils/inputValidation/isOperational.js +1 -1
- package/cjs/utils/lang/index.js +1 -1
- package/cjs/utils/lang/sets.js +4 -4
- package/cjs/utils/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +2 -2
- package/cjs/utils/settingsValidation/url.js +5 -5
- package/esm/evaluator/condition/engineUtils.js +2 -2
- package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +3 -3
- package/esm/evaluator/fallbackTreatmentsCalculator/index.js +21 -33
- package/esm/evaluator/matchers/whitelist.js +1 -1
- package/esm/integrations/pluggable.js +1 -1
- package/esm/listeners/node.js +2 -2
- package/esm/logger/constants.js +0 -1
- package/esm/logger/index.js +1 -1
- package/esm/logger/messages/info.js +1 -2
- package/esm/logger/messages/warn.js +3 -3
- package/esm/sdkClient/client.js +3 -4
- package/esm/sdkClient/clientAttributesDecoration.js +3 -3
- package/esm/sdkClient/clientInputValidation.js +36 -68
- package/esm/sdkClient/identity.js +1 -1
- package/esm/sdkClient/sdkClient.js +20 -8
- package/esm/sdkFactory/index.js +8 -41
- package/esm/services/splitApi.js +13 -13
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/KeyBuilder.js +12 -12
- package/esm/storages/KeyBuilderCS.js +12 -12
- package/esm/storages/KeyBuilderSS.js +14 -14
- package/esm/storages/getRolloutPlan.js +1 -1
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/RedisAdapter.js +7 -7
- package/esm/storages/inRedis/SplitsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +5 -5
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/storages/pluggable/wrapperAdapter.js +1 -1
- package/esm/storages/setRolloutPlan.js +3 -3
- package/esm/storages/utils.js +6 -6
- package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
- package/esm/sync/polling/pollingManagerSS.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/esm/sync/polling/updaters/splitChangesUpdater.js +12 -10
- package/esm/sync/streaming/SSEClient/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +2 -2
- package/esm/sync/streaming/parseUtils.js +1 -1
- package/esm/sync/submitters/submitter.js +1 -1
- package/esm/trackers/eventTracker.js +10 -12
- package/esm/trackers/impressionObserver/buildKey.js +1 -1
- package/esm/trackers/impressionsTracker.js +38 -21
- package/esm/trackers/uniqueKeysTracker.js +1 -1
- package/esm/utils/inputValidation/apiKey.js +1 -1
- package/esm/utils/inputValidation/attribute.js +2 -2
- package/esm/utils/inputValidation/isOperational.js +1 -1
- package/esm/utils/lang/sets.js +4 -4
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +2 -2
- package/esm/utils/settingsValidation/url.js +5 -5
- package/package.json +5 -5
- package/src/dtos/types.ts +15 -15
- package/src/evaluator/condition/engineUtils.ts +2 -2
- package/src/evaluator/fallbackTreatmentsCalculator/index.ts +23 -41
- package/src/evaluator/matchers/whitelist.ts +2 -2
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +1 -1
- package/src/integrations/pluggable.ts +1 -1
- package/src/logger/constants.ts +0 -1
- package/src/logger/messages/info.ts +1 -2
- package/src/logger/messages/warn.ts +3 -3
- package/src/sdkClient/client.ts +3 -5
- package/src/sdkClient/clientInputValidation.ts +38 -61
- package/src/sdkClient/sdkClient.ts +20 -5
- package/src/sdkFactory/index.ts +10 -47
- package/src/sdkFactory/types.ts +6 -3
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -1
- package/src/storages/inMemory/SplitsCacheInMemory.ts +1 -1
- package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +1 -1
- package/src/storages/setRolloutPlan.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +11 -9
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +42 -26
- package/src/trackers/types.ts +3 -1
- package/src/utils/lang/sets.ts +4 -2
- package/types/splitio.d.ts +22 -18
package/cjs/sdkFactory/index.js
CHANGED
|
@@ -5,16 +5,10 @@ var sdkReadinessManager_1 = require("../readiness/sdkReadinessManager");
|
|
|
5
5
|
var impressionsTracker_1 = require("../trackers/impressionsTracker");
|
|
6
6
|
var eventTracker_1 = require("../trackers/eventTracker");
|
|
7
7
|
var telemetryTracker_1 = require("../trackers/telemetryTracker");
|
|
8
|
-
var apiKey_1 = require("../utils/inputValidation/apiKey");
|
|
9
8
|
var sdkLogger_1 = require("../logger/sdkLogger");
|
|
10
9
|
var constants_1 = require("../logger/constants");
|
|
11
10
|
var constants_2 = require("../readiness/constants");
|
|
12
11
|
var objectAssign_1 = require("../utils/lang/objectAssign");
|
|
13
|
-
var strategyDebug_1 = require("../trackers/strategy/strategyDebug");
|
|
14
|
-
var strategyOptimized_1 = require("../trackers/strategy/strategyOptimized");
|
|
15
|
-
var strategyNone_1 = require("../trackers/strategy/strategyNone");
|
|
16
|
-
var uniqueKeysTracker_1 = require("../trackers/uniqueKeysTracker");
|
|
17
|
-
var constants_3 = require("../utils/constants");
|
|
18
12
|
var setRolloutPlan_1 = require("../storages/setRolloutPlan");
|
|
19
13
|
var key_1 = require("../utils/key");
|
|
20
14
|
var fallbackTreatmentsCalculator_1 = require("../evaluator/fallbackTreatmentsCalculator");
|
|
@@ -22,19 +16,10 @@ var fallbackTreatmentsCalculator_1 = require("../evaluator/fallbackTreatmentsCal
|
|
|
22
16
|
* Modular SDK factory
|
|
23
17
|
*/
|
|
24
18
|
function sdkFactory(params) {
|
|
25
|
-
var settings = params.settings, platform = params.platform, storageFactory = params.storageFactory, splitApiFactory = params.splitApiFactory, extraProps = params.extraProps, syncManagerFactory = params.syncManagerFactory, SignalListener = params.SignalListener,
|
|
26
|
-
var log = settings.log,
|
|
19
|
+
var settings = params.settings, platform = params.platform, storageFactory = params.storageFactory, splitApiFactory = params.splitApiFactory, extraProps = params.extraProps, syncManagerFactory = params.syncManagerFactory, SignalListener = params.SignalListener, integrationsManagerFactory = params.integrationsManagerFactory, sdkManagerFactory = params.sdkManagerFactory, sdkClientMethodFactory = params.sdkClientMethodFactory, lazyInit = params.lazyInit;
|
|
20
|
+
var log = settings.log, initialRolloutPlan = settings.initialRolloutPlan, key = settings.core.key;
|
|
27
21
|
// @TODO handle non-recoverable errors, such as, global `fetch` not available, invalid SDK Key, etc.
|
|
28
22
|
// On non-recoverable errors, we should mark the SDK as destroyed and not start synchronization.
|
|
29
|
-
// initialization
|
|
30
|
-
var hasInit = false;
|
|
31
|
-
var initCallbacks = [];
|
|
32
|
-
function whenInit(cb) {
|
|
33
|
-
if (hasInit)
|
|
34
|
-
cb();
|
|
35
|
-
else
|
|
36
|
-
initCallbacks.push(cb);
|
|
37
|
-
}
|
|
38
23
|
var sdkReadinessManager = (0, sdkReadinessManager_1.sdkReadinessManagerFactory)(platform.EventEmitter, settings);
|
|
39
24
|
var readiness = sdkReadinessManager.readinessManager;
|
|
40
25
|
var storage = storageFactory({
|
|
@@ -52,7 +37,7 @@ function sdkFactory(params) {
|
|
|
52
37
|
readiness.splits.emit(constants_2.SDK_SPLITS_CACHE_LOADED);
|
|
53
38
|
}
|
|
54
39
|
});
|
|
55
|
-
var fallbackTreatmentsCalculator =
|
|
40
|
+
var fallbackTreatmentsCalculator = (0, fallbackTreatmentsCalculator_1.FallbackTreatmentsCalculator)(settings.fallbackTreatments);
|
|
56
41
|
if (initialRolloutPlan) {
|
|
57
42
|
(0, setRolloutPlan_1.setRolloutPlan)(log, initialRolloutPlan, storage, key && (0, key_1.getMatching)(key));
|
|
58
43
|
if (storage.splits.getChangeNumber() > -1)
|
|
@@ -61,38 +46,21 @@ function sdkFactory(params) {
|
|
|
61
46
|
var clients = {};
|
|
62
47
|
var telemetryTracker = (0, telemetryTracker_1.telemetryTrackerFactory)(storage.telemetry, platform.now);
|
|
63
48
|
var integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings: settings, storage: storage, telemetryTracker: telemetryTracker });
|
|
64
|
-
var
|
|
65
|
-
var
|
|
66
|
-
var noneStrategy = (0, strategyNone_1.strategyNoneFactory)(storage.impressionCounts, uniqueKeysTracker);
|
|
67
|
-
var strategy = impressionsMode === constants_3.OPTIMIZED ?
|
|
68
|
-
(0, strategyOptimized_1.strategyOptimizedFactory)(observer, storage.impressionCounts) :
|
|
69
|
-
impressionsMode === constants_3.DEBUG ?
|
|
70
|
-
(0, strategyDebug_1.strategyDebugFactory)(observer) :
|
|
71
|
-
noneStrategy;
|
|
72
|
-
var impressionsTracker = (0, impressionsTracker_1.impressionsTrackerFactory)(settings, storage.impressions, noneStrategy, strategy, whenInit, integrationsManager, storage.telemetry);
|
|
73
|
-
var eventTracker = (0, eventTracker_1.eventTrackerFactory)(settings, storage.events, whenInit, integrationsManager, storage.telemetry);
|
|
49
|
+
var impressionsTracker = (0, impressionsTracker_1.impressionsTrackerFactory)(params, storage, integrationsManager);
|
|
50
|
+
var eventTracker = (0, eventTracker_1.eventTrackerFactory)(settings, storage.events, integrationsManager, storage.telemetry);
|
|
74
51
|
// splitApi is used by SyncManager and Browser signal listener
|
|
75
52
|
var splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
|
|
76
|
-
var ctx = { clients: clients, splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker,
|
|
53
|
+
var ctx = { clients: clients, splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker, sdkReadinessManager: sdkReadinessManager, readiness: readiness, settings: settings, storage: storage, platform: platform, fallbackTreatmentsCalculator: fallbackTreatmentsCalculator };
|
|
77
54
|
var syncManager = syncManagerFactory && syncManagerFactory(ctx);
|
|
78
55
|
ctx.syncManager = syncManager;
|
|
56
|
+
// @TODO: move into platform, and call inside sdkClientFactory (if it's used only there)
|
|
79
57
|
var signalListener = SignalListener && new SignalListener(syncManager, settings, storage, splitApi);
|
|
80
58
|
ctx.signalListener = signalListener;
|
|
81
59
|
// SDK client and manager
|
|
82
60
|
var clientMethod = sdkClientMethodFactory(ctx);
|
|
83
61
|
var managerInstance = sdkManagerFactory(settings, storage.splits, sdkReadinessManager);
|
|
84
62
|
function init() {
|
|
85
|
-
|
|
86
|
-
return;
|
|
87
|
-
hasInit = true;
|
|
88
|
-
// We will just log and allow for the SDK to end up throwing an SDK_TIMEOUT event for devs to handle.
|
|
89
|
-
(0, apiKey_1.validateAndTrackApiKey)(log, settings.core.authorizationKey);
|
|
90
|
-
readiness.init();
|
|
91
|
-
uniqueKeysTracker.start();
|
|
92
|
-
syncManager && syncManager.start();
|
|
93
|
-
signalListener && signalListener.start();
|
|
94
|
-
initCallbacks.forEach(function (cb) { return cb(); });
|
|
95
|
-
initCallbacks.length = 0;
|
|
63
|
+
Object.keys(clients).map(function (key) { return clients[key].init(); });
|
|
96
64
|
}
|
|
97
65
|
log.info(constants_1.NEW_FACTORY, [settings.version]);
|
|
98
66
|
// @ts-ignore
|
|
@@ -108,7 +76,6 @@ function sdkFactory(params) {
|
|
|
108
76
|
Logger: (0, sdkLogger_1.createLoggerAPI)(log),
|
|
109
77
|
settings: settings,
|
|
110
78
|
destroy: function () {
|
|
111
|
-
hasInit = false;
|
|
112
79
|
return Promise.all(Object.keys(clients).map(function (key) { return clients[key].destroy(); })).then(function () { });
|
|
113
80
|
}
|
|
114
81
|
}, extraProps && extraProps(ctx), lazyInit ? { init: init } : init());
|
package/cjs/services/splitApi.js
CHANGED
|
@@ -24,15 +24,15 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
24
24
|
return {
|
|
25
25
|
// @TODO throw errors if health check requests fail, to log them in the Synchronizer
|
|
26
26
|
getSdkAPIHealthCheck: function () {
|
|
27
|
-
var url = urls.sdk
|
|
27
|
+
var url = "".concat(urls.sdk, "/version");
|
|
28
28
|
return splitHttpClient(url).then(function () { return true; }).catch(function () { return false; });
|
|
29
29
|
},
|
|
30
30
|
getEventsAPIHealthCheck: function () {
|
|
31
|
-
var url = urls.events
|
|
31
|
+
var url = "".concat(urls.events, "/version");
|
|
32
32
|
return splitHttpClient(url).then(function () { return true; }).catch(function () { return false; });
|
|
33
33
|
},
|
|
34
34
|
fetchAuth: function (userMatchingKeys) {
|
|
35
|
-
var url = urls.auth
|
|
35
|
+
var url = "".concat(urls.auth, "/v2/auth?s=").concat(settings.sync.flagSpecVersion);
|
|
36
36
|
if (userMatchingKeys) { // `userMatchingKeys` is undefined in server-side
|
|
37
37
|
var queryParams = userMatchingKeys.map(userKeyToQueryParam).join('&');
|
|
38
38
|
if (queryParams)
|
|
@@ -41,7 +41,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
41
41
|
return splitHttpClient(url, undefined, telemetryTracker.trackHttp(constants_1.TOKEN));
|
|
42
42
|
},
|
|
43
43
|
fetchSplitChanges: function (since, noCache, till, rbSince) {
|
|
44
|
-
var url = urls.sdk
|
|
44
|
+
var url = "".concat(urls.sdk, "/splitChanges?s=").concat(settings.sync.flagSpecVersion, "&since=").concat(since).concat(rbSince ? '&rbSince=' + rbSince : '').concat(filterQueryString || '').concat(till ? '&till=' + till : '');
|
|
45
45
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS))
|
|
46
46
|
.catch(function (err) {
|
|
47
47
|
if (err.statusCode === 414)
|
|
@@ -50,7 +50,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
50
50
|
});
|
|
51
51
|
},
|
|
52
52
|
fetchSegmentChanges: function (since, segmentName, noCache, till) {
|
|
53
|
-
var url = urls.sdk
|
|
53
|
+
var url = "".concat(urls.sdk, "/segmentChanges/").concat(segmentName, "?since=").concat(since).concat(till ? '&till=' + till : '');
|
|
54
54
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SEGMENT));
|
|
55
55
|
},
|
|
56
56
|
fetchMemberships: function (userMatchingKey, noCache, till) {
|
|
@@ -60,7 +60,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
60
60
|
* - avoid 404 responses. E.g.: '/api/memberships/foo/bar'
|
|
61
61
|
* - match user keys with special characters. E.g.: 'foo%bar', 'foo/bar'
|
|
62
62
|
*/
|
|
63
|
-
var url = urls.sdk
|
|
63
|
+
var url = "".concat(urls.sdk, "/memberships/").concat(encodeURIComponent(userMatchingKey)).concat(till ? '?till=' + till : '');
|
|
64
64
|
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.MEMBERSHIPS));
|
|
65
65
|
},
|
|
66
66
|
/**
|
|
@@ -70,7 +70,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
70
70
|
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
71
71
|
*/
|
|
72
72
|
postEventsBulk: function (body, headers) {
|
|
73
|
-
var url = urls.events
|
|
73
|
+
var url = "".concat(urls.events, "/events/bulk");
|
|
74
74
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(constants_1.EVENTS));
|
|
75
75
|
},
|
|
76
76
|
/**
|
|
@@ -80,7 +80,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
80
80
|
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
81
81
|
*/
|
|
82
82
|
postTestImpressionsBulk: function (body, headers) {
|
|
83
|
-
var url = urls.events
|
|
83
|
+
var url = "".concat(urls.events, "/testImpressions/bulk");
|
|
84
84
|
return splitHttpClient(url, {
|
|
85
85
|
// Adding extra headers to send impressions in OPTIMIZED or DEBUG modes.
|
|
86
86
|
method: 'POST',
|
|
@@ -95,7 +95,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
95
95
|
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
96
96
|
*/
|
|
97
97
|
postTestImpressionsCount: function (body, headers) {
|
|
98
|
-
var url = urls.events
|
|
98
|
+
var url = "".concat(urls.events, "/testImpressions/count");
|
|
99
99
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(constants_1.IMPRESSIONS_COUNT));
|
|
100
100
|
},
|
|
101
101
|
/**
|
|
@@ -105,7 +105,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
105
105
|
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
106
106
|
*/
|
|
107
107
|
postUniqueKeysBulkCs: function (body, headers) {
|
|
108
|
-
var url = urls.telemetry
|
|
108
|
+
var url = "".concat(urls.telemetry, "/v1/keys/cs");
|
|
109
109
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(constants_1.TELEMETRY));
|
|
110
110
|
},
|
|
111
111
|
/**
|
|
@@ -115,15 +115,15 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
115
115
|
* @param headers - Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
116
116
|
*/
|
|
117
117
|
postUniqueKeysBulkSs: function (body, headers) {
|
|
118
|
-
var url = urls.telemetry
|
|
118
|
+
var url = "".concat(urls.telemetry, "/v1/keys/ss");
|
|
119
119
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(constants_1.TELEMETRY));
|
|
120
120
|
},
|
|
121
121
|
postMetricsConfig: function (body, headers) {
|
|
122
|
-
var url = urls.telemetry
|
|
122
|
+
var url = "".concat(urls.telemetry, "/v1/metrics/config");
|
|
123
123
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(constants_1.TELEMETRY), true);
|
|
124
124
|
},
|
|
125
125
|
postMetricsUsage: function (body, headers) {
|
|
126
|
-
var url = urls.telemetry
|
|
126
|
+
var url = "".concat(urls.telemetry, "/v1/metrics/usage");
|
|
127
127
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(constants_1.TELEMETRY), true);
|
|
128
128
|
}
|
|
129
129
|
};
|
|
@@ -24,7 +24,7 @@ function splitHttpClientFactory(settings, _a) {
|
|
|
24
24
|
var commonHeaders = {
|
|
25
25
|
'Accept': 'application/json',
|
|
26
26
|
'Content-Type': 'application/json',
|
|
27
|
-
'Authorization': "Bearer "
|
|
27
|
+
'Authorization': "Bearer ".concat(authorizationKey),
|
|
28
28
|
'SplitSDKVersion': version
|
|
29
29
|
};
|
|
30
30
|
if (ip)
|
|
@@ -14,34 +14,34 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
14
14
|
this.prefix = prefix;
|
|
15
15
|
}
|
|
16
16
|
KeyBuilder.prototype.buildTrafficTypeKey = function (trafficType) {
|
|
17
|
-
return this.prefix
|
|
17
|
+
return "".concat(this.prefix, ".trafficType.").concat(trafficType);
|
|
18
18
|
};
|
|
19
19
|
KeyBuilder.prototype.buildFlagSetKey = function (flagSet) {
|
|
20
|
-
return this.prefix
|
|
20
|
+
return "".concat(this.prefix, ".flagSet.").concat(flagSet);
|
|
21
21
|
};
|
|
22
22
|
KeyBuilder.prototype.buildSplitKey = function (splitName) {
|
|
23
|
-
return this.prefix
|
|
23
|
+
return "".concat(this.prefix, ".split.").concat(splitName);
|
|
24
24
|
};
|
|
25
25
|
KeyBuilder.prototype.buildSplitsTillKey = function () {
|
|
26
|
-
return this.prefix
|
|
26
|
+
return "".concat(this.prefix, ".splits.till");
|
|
27
27
|
};
|
|
28
28
|
KeyBuilder.prototype.buildSplitKeyPrefix = function () {
|
|
29
|
-
return this.prefix
|
|
29
|
+
return "".concat(this.prefix, ".split.");
|
|
30
30
|
};
|
|
31
31
|
KeyBuilder.prototype.buildRBSegmentKey = function (rbsegmentName) {
|
|
32
|
-
return this.prefix
|
|
32
|
+
return "".concat(this.prefix, ".rbsegment.").concat(rbsegmentName);
|
|
33
33
|
};
|
|
34
34
|
KeyBuilder.prototype.buildRBSegmentsTillKey = function () {
|
|
35
|
-
return this.prefix
|
|
35
|
+
return "".concat(this.prefix, ".rbsegments.till");
|
|
36
36
|
};
|
|
37
37
|
KeyBuilder.prototype.buildRBSegmentKeyPrefix = function () {
|
|
38
|
-
return this.prefix
|
|
38
|
+
return "".concat(this.prefix, ".rbsegment.");
|
|
39
39
|
};
|
|
40
40
|
KeyBuilder.prototype.buildSegmentNameKey = function (segmentName) {
|
|
41
|
-
return this.prefix
|
|
41
|
+
return "".concat(this.prefix, ".segment.").concat(segmentName);
|
|
42
42
|
};
|
|
43
43
|
KeyBuilder.prototype.buildSegmentTillKey = function (segmentName) {
|
|
44
|
-
return this.prefix
|
|
44
|
+
return "".concat(this.prefix, ".segment.").concat(segmentName, ".till");
|
|
45
45
|
};
|
|
46
46
|
KeyBuilder.prototype.extractKey = function (builtKey) {
|
|
47
47
|
var s = builtKey.match(everythingAtTheEnd);
|
|
@@ -53,7 +53,7 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
KeyBuilder.prototype.buildHashKey = function () {
|
|
56
|
-
return this.prefix
|
|
56
|
+
return "".concat(this.prefix, ".hash");
|
|
57
57
|
};
|
|
58
58
|
return KeyBuilder;
|
|
59
59
|
}());
|
|
@@ -63,6 +63,6 @@ exports.KeyBuilder = KeyBuilder;
|
|
|
63
63
|
* The hash is in hexadecimal format (8 characters max, 32 bits).
|
|
64
64
|
*/
|
|
65
65
|
function getStorageHash(settings) {
|
|
66
|
-
return (0, murmur3_1.hash)(settings.core.authorizationKey
|
|
66
|
+
return (0, murmur3_1.hash)("".concat(settings.core.authorizationKey, "::").concat(settings.sync.__splitFiltersValidation.queryString, "::").concat(settings.sync.flagSpecVersion)).toString(16);
|
|
67
67
|
}
|
|
68
68
|
exports.getStorageHash = getStorageHash;
|
|
@@ -5,44 +5,44 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var lang_1 = require("../utils/lang");
|
|
6
6
|
var KeyBuilder_1 = require("./KeyBuilder");
|
|
7
7
|
var KeyBuilderCS = /** @class */ (function (_super) {
|
|
8
|
-
|
|
8
|
+
tslib_1.__extends(KeyBuilderCS, _super);
|
|
9
9
|
function KeyBuilderCS(prefix, matchingKey) {
|
|
10
10
|
var _this = _super.call(this, prefix) || this;
|
|
11
11
|
_this.matchingKey = matchingKey;
|
|
12
|
-
_this.regexSplitsCacheKey = new RegExp("^"
|
|
12
|
+
_this.regexSplitsCacheKey = new RegExp("^".concat(prefix, "\\.(splits?|trafficType|flagSet)\\."));
|
|
13
13
|
return _this;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* @override
|
|
17
17
|
*/
|
|
18
18
|
KeyBuilderCS.prototype.buildSegmentNameKey = function (segmentName) {
|
|
19
|
-
return this.prefix
|
|
19
|
+
return "".concat(this.prefix, ".").concat(this.matchingKey, ".segment.").concat(segmentName);
|
|
20
20
|
};
|
|
21
21
|
KeyBuilderCS.prototype.extractSegmentName = function (builtSegmentKeyName) {
|
|
22
|
-
var prefix = this.prefix
|
|
22
|
+
var prefix = "".concat(this.prefix, ".").concat(this.matchingKey, ".segment.");
|
|
23
23
|
if ((0, lang_1.startsWith)(builtSegmentKeyName, prefix))
|
|
24
24
|
return builtSegmentKeyName.slice(prefix.length);
|
|
25
25
|
};
|
|
26
26
|
KeyBuilderCS.prototype.buildLastUpdatedKey = function () {
|
|
27
|
-
return this.prefix
|
|
27
|
+
return "".concat(this.prefix, ".splits.lastUpdated");
|
|
28
28
|
};
|
|
29
29
|
KeyBuilderCS.prototype.isSplitsCacheKey = function (key) {
|
|
30
30
|
return this.regexSplitsCacheKey.test(key);
|
|
31
31
|
};
|
|
32
32
|
KeyBuilderCS.prototype.buildTillKey = function () {
|
|
33
|
-
return this.prefix
|
|
33
|
+
return "".concat(this.prefix, ".").concat(this.matchingKey, ".segments.till");
|
|
34
34
|
};
|
|
35
35
|
KeyBuilderCS.prototype.isSplitKey = function (key) {
|
|
36
|
-
return (0, lang_1.startsWith)(key, this.prefix
|
|
36
|
+
return (0, lang_1.startsWith)(key, "".concat(this.prefix, ".split."));
|
|
37
37
|
};
|
|
38
38
|
KeyBuilderCS.prototype.isRBSegmentKey = function (key) {
|
|
39
|
-
return (0, lang_1.startsWith)(key, this.prefix
|
|
39
|
+
return (0, lang_1.startsWith)(key, "".concat(this.prefix, ".rbsegment."));
|
|
40
40
|
};
|
|
41
41
|
KeyBuilderCS.prototype.buildSplitsWithSegmentCountKey = function () {
|
|
42
|
-
return this.prefix
|
|
42
|
+
return "".concat(this.prefix, ".splits.usingSegments");
|
|
43
43
|
};
|
|
44
44
|
KeyBuilderCS.prototype.buildLastClear = function () {
|
|
45
|
-
return this.prefix
|
|
45
|
+
return "".concat(this.prefix, ".lastClear");
|
|
46
46
|
};
|
|
47
47
|
return KeyBuilderCS;
|
|
48
48
|
}(KeyBuilder_1.KeyBuilder));
|
|
@@ -50,15 +50,15 @@ exports.KeyBuilderCS = KeyBuilderCS;
|
|
|
50
50
|
function myLargeSegmentsKeyBuilder(prefix, matchingKey) {
|
|
51
51
|
return {
|
|
52
52
|
buildSegmentNameKey: function (segmentName) {
|
|
53
|
-
return prefix
|
|
53
|
+
return "".concat(prefix, ".").concat(matchingKey, ".largeSegment.").concat(segmentName);
|
|
54
54
|
},
|
|
55
55
|
extractSegmentName: function (builtSegmentKeyName) {
|
|
56
|
-
var p = prefix
|
|
56
|
+
var p = "".concat(prefix, ".").concat(matchingKey, ".largeSegment.");
|
|
57
57
|
if ((0, lang_1.startsWith)(builtSegmentKeyName, p))
|
|
58
58
|
return builtSegmentKeyName.slice(p.length);
|
|
59
59
|
},
|
|
60
60
|
buildTillKey: function () {
|
|
61
|
-
return prefix
|
|
61
|
+
return "".concat(prefix, ".").concat(matchingKey, ".largeSegments.till");
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
@@ -15,45 +15,45 @@ exports.METHOD_NAMES = {
|
|
|
15
15
|
tr: 'track'
|
|
16
16
|
};
|
|
17
17
|
var KeyBuilderSS = /** @class */ (function (_super) {
|
|
18
|
-
|
|
18
|
+
tslib_1.__extends(KeyBuilderSS, _super);
|
|
19
19
|
function KeyBuilderSS(prefix, metadata) {
|
|
20
20
|
var _this = _super.call(this, prefix) || this;
|
|
21
|
-
_this.latencyPrefix = _this.prefix
|
|
22
|
-
_this.exceptionPrefix = _this.prefix
|
|
23
|
-
_this.initPrefix = _this.prefix
|
|
24
|
-
_this.versionablePrefix = metadata.s
|
|
21
|
+
_this.latencyPrefix = "".concat(_this.prefix, ".telemetry.latencies");
|
|
22
|
+
_this.exceptionPrefix = "".concat(_this.prefix, ".telemetry.exceptions");
|
|
23
|
+
_this.initPrefix = "".concat(_this.prefix, ".telemetry.init");
|
|
24
|
+
_this.versionablePrefix = "".concat(metadata.s, "/").concat(metadata.n, "/").concat(metadata.i);
|
|
25
25
|
return _this;
|
|
26
26
|
}
|
|
27
27
|
KeyBuilderSS.prototype.buildRegisteredSegmentsKey = function () {
|
|
28
|
-
return this.prefix
|
|
28
|
+
return "".concat(this.prefix, ".segments.registered");
|
|
29
29
|
};
|
|
30
30
|
KeyBuilderSS.prototype.buildImpressionsKey = function () {
|
|
31
|
-
return this.prefix
|
|
31
|
+
return "".concat(this.prefix, ".impressions");
|
|
32
32
|
};
|
|
33
33
|
KeyBuilderSS.prototype.buildImpressionsCountKey = function () {
|
|
34
|
-
return this.prefix
|
|
34
|
+
return "".concat(this.prefix, ".impressions.count");
|
|
35
35
|
};
|
|
36
36
|
KeyBuilderSS.prototype.buildUniqueKeysKey = function () {
|
|
37
|
-
return this.prefix
|
|
37
|
+
return "".concat(this.prefix, ".uniquekeys");
|
|
38
38
|
};
|
|
39
39
|
KeyBuilderSS.prototype.buildEventsKey = function () {
|
|
40
|
-
return this.prefix
|
|
40
|
+
return "".concat(this.prefix, ".events");
|
|
41
41
|
};
|
|
42
42
|
KeyBuilderSS.prototype.searchPatternForSplitKeys = function () {
|
|
43
|
-
return this.buildSplitKeyPrefix()
|
|
43
|
+
return "".concat(this.buildSplitKeyPrefix(), "*");
|
|
44
44
|
};
|
|
45
45
|
KeyBuilderSS.prototype.searchPatternForRBSegmentKeys = function () {
|
|
46
|
-
return this.buildRBSegmentKeyPrefix()
|
|
46
|
+
return "".concat(this.buildRBSegmentKeyPrefix(), "*");
|
|
47
47
|
};
|
|
48
48
|
/* Telemetry keys */
|
|
49
49
|
KeyBuilderSS.prototype.buildLatencyKey = function (method, bucket) {
|
|
50
|
-
return this.latencyPrefix
|
|
50
|
+
return "".concat(this.latencyPrefix, "::").concat(this.versionablePrefix, "/").concat(exports.METHOD_NAMES[method], "/").concat(bucket);
|
|
51
51
|
};
|
|
52
52
|
KeyBuilderSS.prototype.buildExceptionKey = function (method) {
|
|
53
|
-
return this.exceptionPrefix
|
|
53
|
+
return "".concat(this.exceptionPrefix, "::").concat(this.versionablePrefix, "/").concat(exports.METHOD_NAMES[method]);
|
|
54
54
|
};
|
|
55
55
|
KeyBuilderSS.prototype.buildInitKey = function () {
|
|
56
|
-
return this.initPrefix
|
|
56
|
+
return "".concat(this.initPrefix, "::").concat(this.versionablePrefix);
|
|
57
57
|
};
|
|
58
58
|
return KeyBuilderSS;
|
|
59
59
|
}(KeyBuilder_1.KeyBuilder));
|
|
@@ -10,7 +10,7 @@ function getRolloutPlan(log, storage, options) {
|
|
|
10
10
|
if (options === void 0) { options = {}; }
|
|
11
11
|
var keys = options.keys, exposeSegments = options.exposeSegments;
|
|
12
12
|
var splits = storage.splits, segments = storage.segments, rbSegments = storage.rbSegments;
|
|
13
|
-
log.debug("storage: get feature flags"
|
|
13
|
+
log.debug("storage: get feature flags".concat(keys ? ", and memberships for keys: ".concat(keys) : '').concat(exposeSegments ? ', and segments' : ''));
|
|
14
14
|
return {
|
|
15
15
|
splitChanges: {
|
|
16
16
|
ff: {
|
|
@@ -6,7 +6,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
6
6
|
var AbstractMySegmentsCacheSync_1 = require("../AbstractMySegmentsCacheSync");
|
|
7
7
|
var constants_1 = require("./constants");
|
|
8
8
|
var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
9
|
-
|
|
9
|
+
tslib_1.__extends(MySegmentsCacheInLocal, _super);
|
|
10
10
|
function MySegmentsCacheInLocal(log, keys, storage) {
|
|
11
11
|
var _this = _super.call(this) || this;
|
|
12
12
|
_this.log = log;
|
|
@@ -7,7 +7,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
7
7
|
var constants_1 = require("./constants");
|
|
8
8
|
var sets_1 = require("../../utils/lang/sets");
|
|
9
9
|
var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
10
|
-
|
|
10
|
+
tslib_1.__extends(SplitsCacheInLocal, _super);
|
|
11
11
|
function SplitsCacheInLocal(settings, keys, storage) {
|
|
12
12
|
var _this = _super.call(this) || this;
|
|
13
13
|
_this.keys = keys;
|
|
@@ -15,7 +15,7 @@ var ImpressionCountsCacheInMemory = /** @class */ (function () {
|
|
|
15
15
|
* Builds key to be stored in the cache with the featureName and the timeFrame truncated.
|
|
16
16
|
*/
|
|
17
17
|
ImpressionCountsCacheInMemory.prototype._makeKey = function (featureName, timeFrame) {
|
|
18
|
-
return featureName
|
|
18
|
+
return "".concat(featureName, "::").concat((0, time_1.truncateTimeFrame)(timeFrame));
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Increments the quantity of impressions with the passed featureName and timeFrame.
|
|
@@ -8,7 +8,7 @@ var AbstractMySegmentsCacheSync_1 = require("../AbstractMySegmentsCacheSync");
|
|
|
8
8
|
* Supported by all JS runtimes.
|
|
9
9
|
*/
|
|
10
10
|
var MySegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
11
|
-
|
|
11
|
+
tslib_1.__extends(MySegmentsCacheInMemory, _super);
|
|
12
12
|
function MySegmentsCacheInMemory() {
|
|
13
13
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
14
14
|
_this.segmentCache = {};
|
|
@@ -8,7 +8,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
8
8
|
* Default ISplitsCacheSync implementation that stores split definitions in memory.
|
|
9
9
|
*/
|
|
10
10
|
var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
11
|
-
|
|
11
|
+
tslib_1.__extends(SplitsCacheInMemory, _super);
|
|
12
12
|
function SplitsCacheInMemory(splitFiltersValidation) {
|
|
13
13
|
var _this = _super.call(this) || this;
|
|
14
14
|
_this.splitsCache = {};
|
|
@@ -19,7 +19,7 @@ var EventsCacheInRedis = /** @class */ (function () {
|
|
|
19
19
|
// We use boolean values to signal successful queueing
|
|
20
20
|
.then(function () { return true; })
|
|
21
21
|
.catch(function (err) {
|
|
22
|
-
_this.log.error(constants_1.LOG_PREFIX
|
|
22
|
+
_this.log.error("".concat(constants_1.LOG_PREFIX, "Error adding event to queue: ").concat(err, "."));
|
|
23
23
|
return false;
|
|
24
24
|
});
|
|
25
25
|
};
|
|
@@ -6,7 +6,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
6
6
|
var ImpressionCountsCacheInMemory_1 = require("../inMemory/ImpressionCountsCacheInMemory");
|
|
7
7
|
var constants_1 = require("./constants");
|
|
8
8
|
var ImpressionCountsCacheInRedis = /** @class */ (function (_super) {
|
|
9
|
-
|
|
9
|
+
tslib_1.__extends(ImpressionCountsCacheInRedis, _super);
|
|
10
10
|
function ImpressionCountsCacheInRedis(log, key, redis, impressionCountsCacheSize, refreshRate) {
|
|
11
11
|
if (refreshRate === void 0) { refreshRate = constants_1.REFRESH_RATE; }
|
|
12
12
|
var _this = _super.call(this, impressionCountsCacheSize) || this;
|
|
@@ -35,7 +35,7 @@ var ImpressionCountsCacheInRedis = /** @class */ (function (_super) {
|
|
|
35
35
|
}
|
|
36
36
|
})
|
|
37
37
|
.catch(function (err) {
|
|
38
|
-
_this.log.error(constants_1.LOG_PREFIX
|
|
38
|
+
_this.log.error("".concat(constants_1.LOG_PREFIX, "Error in impression counts pipeline: ").concat(err, "."));
|
|
39
39
|
return false;
|
|
40
40
|
});
|
|
41
41
|
};
|
|
@@ -58,17 +58,17 @@ var ImpressionCountsCacheInRedis = /** @class */ (function (_super) {
|
|
|
58
58
|
(0, lang_1.forOwn)(counts, function (count, key) {
|
|
59
59
|
var nameAndTime = key.split('::');
|
|
60
60
|
if (nameAndTime.length !== 2) {
|
|
61
|
-
_this.log.error(constants_1.LOG_PREFIX
|
|
61
|
+
_this.log.error("".concat(constants_1.LOG_PREFIX, "Error spliting key ").concat(key));
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
var timeFrame = parseInt(nameAndTime[1]);
|
|
65
65
|
if (isNaN(timeFrame)) {
|
|
66
|
-
_this.log.error(constants_1.LOG_PREFIX
|
|
66
|
+
_this.log.error("".concat(constants_1.LOG_PREFIX, "Error parsing time frame ").concat(nameAndTime[1]));
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
var rawCount = parseInt(count);
|
|
70
70
|
if (isNaN(rawCount)) {
|
|
71
|
-
_this.log.error(constants_1.LOG_PREFIX
|
|
71
|
+
_this.log.error("".concat(constants_1.LOG_PREFIX, "Error parsing raw count ").concat(count));
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
pf.push({
|
|
@@ -14,7 +14,7 @@ var ImpressionsCacheInRedis = /** @class */ (function () {
|
|
|
14
14
|
ImpressionsCacheInRedis.prototype.track = function (impressions) {
|
|
15
15
|
var _a;
|
|
16
16
|
var _this = this;
|
|
17
|
-
return (_a = this.redis).rpush.apply(_a,
|
|
17
|
+
return (_a = this.redis).rpush.apply(_a, tslib_1.__spreadArray([this.key], (0, utils_1.impressionsToJSON)(impressions, this.metadata), false)).then(function (queuedCount) {
|
|
18
18
|
// If this is the creation of the key on Redis, set the expiration for it in 1hr.
|
|
19
19
|
if (queuedCount === impressions.length) {
|
|
20
20
|
return _this.redis.expire(_this.key, IMPRESSIONS_TTL_REFRESH);
|
|
@@ -49,7 +49,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
49
49
|
this._runningCommands = new Set();
|
|
50
50
|
// Instantiate the client using the dynamic constructor
|
|
51
51
|
var librarySettings = RedisAdapter._defineLibrarySettings(options);
|
|
52
|
-
this.client = new (RedisConstructor.bind.apply(RedisConstructor,
|
|
52
|
+
this.client = new (RedisConstructor.bind.apply(RedisConstructor, tslib_1.__spreadArray([void 0], librarySettings, false)))();
|
|
53
53
|
this._listenToEvents();
|
|
54
54
|
this._setTimeoutWrappers();
|
|
55
55
|
this._setDisconnectWrapper();
|
|
@@ -61,9 +61,9 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
61
61
|
var _this = this;
|
|
62
62
|
this.client.once('ready', function () {
|
|
63
63
|
var commandsCount = _this._notReadyCommandsQueue ? _this._notReadyCommandsQueue.length : 0;
|
|
64
|
-
_this.log.info(LOG_PREFIX +
|
|
64
|
+
_this.log.info(LOG_PREFIX + "Redis connection established. Queued commands: ".concat(commandsCount, "."));
|
|
65
65
|
_this._notReadyCommandsQueue && _this._notReadyCommandsQueue.forEach(function (queued) {
|
|
66
|
-
_this.log.info(LOG_PREFIX +
|
|
66
|
+
_this.log.info(LOG_PREFIX + "Executing queued ".concat(queued.name, " command."));
|
|
67
67
|
queued.command().then(queued.resolve).catch(queued.reject);
|
|
68
68
|
});
|
|
69
69
|
// After the SDK is ready for the first time we'll stop queueing commands. This is just so we can keep handling BUR for them.
|
|
@@ -85,7 +85,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
85
85
|
params[_i] = arguments[_i];
|
|
86
86
|
}
|
|
87
87
|
function commandWrapper() {
|
|
88
|
-
instance.log.debug(LOG_PREFIX
|
|
88
|
+
instance.log.debug("".concat(LOG_PREFIX, "Executing ").concat(methodName, "."));
|
|
89
89
|
var result = originalMethod.apply(bindTarget, params);
|
|
90
90
|
if ((0, thenable_1.thenable)(result)) {
|
|
91
91
|
// For handling pending commands on disconnect, add to the set and remove once finished.
|
|
@@ -97,7 +97,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
97
97
|
// Both success and error remove from queue.
|
|
98
98
|
result.then(cleanUpRunningCommandsCb, cleanUpRunningCommandsCb);
|
|
99
99
|
return (0, timeout_1.timeout)(instance._options.operationTimeout, result).catch(function (err) {
|
|
100
|
-
instance.log.error(""
|
|
100
|
+
instance.log.error("".concat(LOG_PREFIX).concat(methodName, " operation threw an error or exceeded configured timeout of ").concat(instance._options.operationTimeout, "ms. Message: ").concat(err));
|
|
101
101
|
// Handling is not the adapter responsibility.
|
|
102
102
|
throw err;
|
|
103
103
|
});
|
|
@@ -135,7 +135,7 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
135
135
|
}
|
|
136
136
|
var res = originalFn.apply(instance.client, args);
|
|
137
137
|
var originalExec = res.exec;
|
|
138
|
-
res.exec = wrapCommand(originalExec, methodName
|
|
138
|
+
res.exec = wrapCommand(originalExec, "".concat(methodName, ".exec"), res);
|
|
139
139
|
return res;
|
|
140
140
|
};
|
|
141
141
|
});
|
|
@@ -150,14 +150,14 @@ var RedisAdapter = /** @class */ (function () {
|
|
|
150
150
|
}
|
|
151
151
|
setTimeout(function deferredDisconnect() {
|
|
152
152
|
if (instance._runningCommands.size > 0) {
|
|
153
|
-
instance.log.info(LOG_PREFIX +
|
|
153
|
+
instance.log.info(LOG_PREFIX + "Attempting to disconnect but there are ".concat(instance._runningCommands.size, " commands still waiting for resolution. Defering disconnection until those finish."));
|
|
154
154
|
Promise.all((0, sets_1.setToArray)(instance._runningCommands))
|
|
155
155
|
.then(function () {
|
|
156
156
|
instance.log.debug(LOG_PREFIX + 'Pending commands finished successfully, disconnecting.');
|
|
157
157
|
originalMethod.apply(instance.client, params);
|
|
158
158
|
})
|
|
159
159
|
.catch(function (e) {
|
|
160
|
-
instance.log.warn(LOG_PREFIX +
|
|
160
|
+
instance.log.warn(LOG_PREFIX + "Pending commands finished with error: ".concat(e, ". Proceeding with disconnection."));
|
|
161
161
|
originalMethod.apply(instance.client, params);
|
|
162
162
|
});
|
|
163
163
|
}
|