@splitsoftware/splitio-commons 1.2.1-rc.0 → 1.2.1-rc.4
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/evaluator/Engine.js +6 -6
- package/cjs/evaluator/combiners/and.js +1 -1
- package/cjs/evaluator/combiners/ifelseif.js +2 -2
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/condition/index.js +4 -4
- package/cjs/evaluator/index.js +5 -5
- package/cjs/evaluator/matchers/cont_all.js +1 -1
- package/cjs/evaluator/matchers/cont_any.js +1 -1
- package/cjs/evaluator/matchers/cont_str.js +1 -1
- package/cjs/evaluator/matchers/dependency.js +1 -1
- package/cjs/evaluator/matchers/eq_set.js +1 -1
- package/cjs/evaluator/matchers/ew.js +3 -3
- package/cjs/evaluator/matchers/part_of.js +1 -1
- package/cjs/evaluator/matchers/segment.js +1 -1
- package/cjs/evaluator/matchers/sw.js +1 -1
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/evaluator/matchersTransform/index.js +12 -12
- package/cjs/evaluator/parser/index.js +6 -6
- package/cjs/evaluator/treatments/index.js +1 -1
- package/cjs/evaluator/value/index.js +1 -1
- package/cjs/evaluator/value/sanitize.js +4 -4
- package/cjs/integrations/browser.js +3 -3
- package/cjs/integrations/ga/GaToSplit.js +14 -14
- package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +5 -3
- package/cjs/integrations/ga/SplitToGa.js +1 -1
- package/cjs/integrations/ga/SplitToGoogleAnalytics.js +4 -2
- package/cjs/listeners/browser.js +1 -1
- package/cjs/listeners/node.js +1 -1
- package/cjs/logger/constants.js +4 -2
- package/cjs/logger/index.js +2 -2
- package/cjs/logger/messages/debug.js +1 -1
- package/cjs/logger/messages/error.js +2 -2
- package/cjs/logger/messages/info.js +3 -3
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/logger/sdkLogger.js +1 -1
- package/cjs/readiness/readinessManager.js +2 -2
- package/cjs/readiness/sdkReadinessManager.js +4 -4
- package/cjs/sdkClient/client.js +9 -9
- package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
- package/cjs/sdkClient/clientCS.js +2 -2
- package/cjs/sdkClient/clientInputValidation.js +14 -14
- package/cjs/sdkClient/sdkClient.js +3 -3
- package/cjs/sdkClient/sdkClientMethod.js +1 -1
- package/cjs/sdkClient/sdkClientMethodCS.js +6 -6
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +8 -8
- package/cjs/sdkFactory/index.js +9 -8
- package/cjs/sdkManager/index.js +11 -11
- package/cjs/services/splitApi.js +3 -2
- package/cjs/services/splitHttpClient.js +2 -2
- package/cjs/storages/KeyBuilder.js +2 -2
- package/cjs/storages/KeyBuilderCS.js +2 -2
- package/cjs/storages/KeyBuilderSS.js +1 -1
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
- package/cjs/storages/inLocalStorage/index.js +4 -4
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/cjs/storages/inMemory/LatenciesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -2
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/LatenciesCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +16 -10
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/index.js +1 -1
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/cjs/storages/pluggable/inMemoryWrapper.js +4 -4
- package/cjs/storages/pluggable/index.js +6 -6
- package/cjs/sync/offline/LocalhostFromFile.js +1 -1
- package/cjs/sync/offline/LocalhostFromObject.js +1 -1
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +13 -13
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +3 -3
- package/cjs/sync/offline/syncManagerOffline.js +1 -1
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerCS.js +8 -7
- package/cjs/sync/polling/pollingManagerSS.js +5 -4
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -2
- package/cjs/sync/streaming/AuthClient/index.js +3 -3
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +3 -3
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/cjs/sync/streaming/mySegmentsV2utils.js +1 -1
- package/cjs/sync/streaming/pushManager.js +27 -19
- package/cjs/sync/submitters/eventsSyncTask.js +4 -3
- package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionsSyncTask.js +11 -3
- package/cjs/sync/submitters/metricsSyncTask.js +3 -3
- package/cjs/sync/submitters/submitterManager.js +6 -5
- package/cjs/sync/submitters/submitterSyncTask.js +1 -1
- package/cjs/sync/syncManagerOnline.js +8 -13
- package/cjs/trackers/eventTracker.js +3 -3
- package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
- package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
- package/cjs/trackers/impressionsTracker.js +3 -3
- package/cjs/utils/MinEvents.js +2 -1
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +4 -4
- package/cjs/utils/inputValidation/attributes.js +2 -2
- package/cjs/utils/inputValidation/event.js +1 -1
- package/cjs/utils/inputValidation/eventProperties.js +7 -5
- package/cjs/utils/inputValidation/eventValue.js +1 -1
- package/cjs/utils/inputValidation/key.js +6 -5
- package/cjs/utils/inputValidation/preloadedData.js +8 -8
- package/cjs/utils/inputValidation/split.js +1 -1
- package/cjs/utils/inputValidation/splits.js +2 -2
- package/cjs/utils/inputValidation/trafficType.js +1 -1
- package/cjs/utils/inputValidation/trafficTypeExistance.js +1 -1
- package/cjs/utils/jwt/index.js +1 -1
- package/cjs/utils/key/index.js +3 -3
- package/cjs/utils/lang/index.js +2 -14
- package/cjs/utils/murmur3/common.js +1 -1
- package/cjs/utils/murmur3/murmur3.js +10 -10
- package/cjs/utils/murmur3/murmur3_128.js +1 -1
- package/cjs/utils/murmur3/murmur3_128_x86.js +37 -37
- package/cjs/utils/murmur3/murmur3_64.js +1 -1
- package/cjs/utils/settingsValidation/index.js +7 -10
- package/cjs/utils/settingsValidation/integrations/configurable.js +1 -1
- package/cjs/utils/settingsValidation/integrations/pluggable.js +1 -1
- package/cjs/utils/settingsValidation/localhost/builtin.js +2 -2
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +3 -3
- package/cjs/utils/settingsValidation/logger/commons.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/cjs/utils/settingsValidation/runtime.js +11 -0
- package/cjs/utils/settingsValidation/splitFilters.js +1 -1
- package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
- package/cjs/utils/timeTracker/index.js +3 -3
- package/esm/evaluator/matchers/ew.js +4 -4
- package/esm/integrations/ga/GoogleAnalyticsToSplit.js +4 -2
- package/esm/integrations/ga/SplitToGoogleAnalytics.js +4 -2
- package/esm/logger/constants.js +1 -1
- package/esm/logger/messages/error.js +1 -1
- package/esm/logger/messages/info.js +2 -2
- package/esm/sdkFactory/index.js +1 -0
- package/esm/services/splitApi.js +2 -1
- package/esm/storages/inLocalStorage/index.js +1 -1
- package/esm/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
- package/esm/storages/inMemory/InMemoryStorage.js +1 -1
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +7 -1
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +2 -2
- package/esm/sync/polling/pollingManagerCS.js +2 -1
- package/esm/sync/polling/pollingManagerSS.js +2 -1
- package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/esm/sync/streaming/pushManager.js +13 -5
- package/esm/sync/submitters/eventsSyncTask.js +5 -4
- package/esm/sync/submitters/impressionsSyncTask.js +9 -1
- package/esm/sync/submitters/submitterManager.js +2 -1
- package/esm/sync/syncManagerOnline.js +8 -13
- package/esm/utils/inputValidation/eventProperties.js +4 -2
- package/esm/utils/inputValidation/key.js +2 -1
- package/esm/utils/lang/index.js +2 -13
- package/esm/utils/settingsValidation/index.js +3 -6
- package/esm/utils/settingsValidation/runtime.js +7 -0
- package/package.json +6 -6
- package/src/evaluator/matchers/ew.ts +4 -4
- package/src/integrations/ga/GoogleAnalyticsToSplit.ts +7 -4
- package/src/integrations/ga/SplitToGoogleAnalytics.ts +7 -4
- package/src/integrations/types.ts +5 -0
- package/src/logger/constants.ts +1 -1
- package/src/logger/messages/error.ts +1 -1
- package/src/logger/messages/info.ts +2 -2
- package/src/logger/types.ts +4 -0
- package/src/sdkFactory/index.ts +1 -0
- package/src/storages/inLocalStorage/index.ts +1 -1
- package/src/storages/inMemory/ImpressionsCacheInMemory.ts +22 -1
- package/src/storages/inMemory/InMemoryStorage.ts +1 -1
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
- package/src/storages/pluggable/index.ts +2 -2
- package/src/storages/types.ts +6 -2
- package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -1
- package/src/sync/polling/fetchers/types.ts +1 -0
- package/src/sync/polling/pollingManagerCS.ts +3 -6
- package/src/sync/polling/pollingManagerSS.ts +3 -8
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +2 -1
- package/src/sync/polling/types.ts +0 -12
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -1
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
- package/src/sync/streaming/pushManager.ts +19 -16
- package/src/sync/streaming/types.ts +5 -25
- package/src/sync/submitters/eventsSyncTask.ts +6 -4
- package/src/sync/submitters/impressionsSyncTask.ts +12 -1
- package/src/sync/submitters/submitterManager.ts +4 -8
- package/src/sync/syncManagerOnline.ts +14 -24
- package/src/types.ts +15 -0
- package/src/utils/inputValidation/eventProperties.ts +4 -2
- package/src/utils/lang/index.ts +0 -14
- package/src/utils/settingsValidation/index.ts +3 -6
- package/src/utils/settingsValidation/runtime.ts +9 -0
- package/src/utils/settingsValidation/types.ts +6 -6
- package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +2 -2
- package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +2 -3
- package/types/integrations/types.d.ts +4 -0
- package/types/logger/constants.d.ts +1 -1
- package/types/logger/types.d.ts +4 -0
- package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
- package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +9 -0
- package/types/storages/inMemory/index.d.ts +10 -0
- package/types/storages/parseSegments.d.ts +6 -0
- package/types/storages/types.d.ts +3 -1
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +1 -1
- package/types/sync/polling/fetchers/types.d.ts +1 -1
- package/types/sync/polling/pollingManagerCS.d.ts +2 -5
- package/types/sync/polling/pollingManagerSS.d.ts +2 -5
- package/types/sync/polling/types.d.ts +0 -11
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
- package/types/sync/streaming/pushManager.d.ts +3 -7
- package/types/sync/streaming/pushManagerCS.d.ts +1 -12
- package/types/sync/streaming/pushManagerSS.d.ts +1 -11
- package/types/sync/streaming/types.d.ts +3 -23
- package/types/sync/submitters/submitterManager.d.ts +2 -4
- package/types/sync/syncManagerOnline.d.ts +3 -3
- package/types/types.d.ts +15 -0
- package/types/utils/lang/index.d.ts +0 -4
- package/types/utils/settingsValidation/runtime/browser.d.ts +2 -0
- package/types/utils/settingsValidation/runtime/node.d.ts +2 -0
- package/types/utils/settingsValidation/runtime.d.ts +2 -0
- package/types/utils/settingsValidation/types.d.ts +6 -6
|
@@ -6,7 +6,7 @@ var everythingAtTheEnd = /[^.]+$/;
|
|
|
6
6
|
var DEFAULT_PREFIX = 'SPLITIO';
|
|
7
7
|
function validatePrefix(prefix) {
|
|
8
8
|
return prefix && typeof prefix === 'string' ?
|
|
9
|
-
lang_1.endsWith(prefix, '.' + DEFAULT_PREFIX) ?
|
|
9
|
+
(0, lang_1.endsWith)(prefix, '.' + DEFAULT_PREFIX) ?
|
|
10
10
|
prefix : // suffix already appended
|
|
11
11
|
prefix + '.' + DEFAULT_PREFIX : // append suffix
|
|
12
12
|
DEFAULT_PREFIX; // use default prefix if none is provided
|
|
@@ -31,7 +31,7 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
31
31
|
// return `${this.prefix}.splits.ready`;
|
|
32
32
|
// }
|
|
33
33
|
KeyBuilder.prototype.isSplitKey = function (key) {
|
|
34
|
-
return lang_1.startsWith(key, this.prefix + ".split.");
|
|
34
|
+
return (0, lang_1.startsWith)(key, this.prefix + ".split.");
|
|
35
35
|
};
|
|
36
36
|
KeyBuilder.prototype.buildSplitKeyPrefix = function () {
|
|
37
37
|
return this.prefix + ".split.";
|
|
@@ -5,7 +5,7 @@ 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
|
-
tslib_1.__extends(KeyBuilderCS, _super);
|
|
8
|
+
(0, 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;
|
|
@@ -20,7 +20,7 @@ var KeyBuilderCS = /** @class */ (function (_super) {
|
|
|
20
20
|
};
|
|
21
21
|
KeyBuilderCS.prototype.extractSegmentName = function (builtSegmentKeyName) {
|
|
22
22
|
var prefix = this.matchingKey + "." + this.prefix + ".segment.";
|
|
23
|
-
if (lang_1.startsWith(builtSegmentKeyName, prefix))
|
|
23
|
+
if ((0, lang_1.startsWith)(builtSegmentKeyName, prefix))
|
|
24
24
|
return builtSegmentKeyName.substr(prefix.length);
|
|
25
25
|
};
|
|
26
26
|
KeyBuilderCS.prototype.buildLastUpdatedKey = function () {
|
|
@@ -7,7 +7,7 @@ var KeyBuilder_1 = require("./KeyBuilder");
|
|
|
7
7
|
// const everythingAfterCount = /count\.([^/]+)$/;
|
|
8
8
|
// const latencyMetricNameAndBucket = /latency\.([^/]+)\.bucket\.([0-9]+)$/;
|
|
9
9
|
var KeyBuilderSS = /** @class */ (function (_super) {
|
|
10
|
-
tslib_1.__extends(KeyBuilderSS, _super);
|
|
10
|
+
(0, tslib_1.__extends)(KeyBuilderSS, _super);
|
|
11
11
|
function KeyBuilderSS(prefix, metadata) {
|
|
12
12
|
var _this = _super.call(this, prefix) || this;
|
|
13
13
|
_this.metadata = metadata;
|
|
@@ -8,6 +8,6 @@ function findLatencyIndex(latency, min, max, base) {
|
|
|
8
8
|
if (max === void 0) { max = 23; }
|
|
9
9
|
if (base === void 0) { base = 1.5; }
|
|
10
10
|
var index = Math.min(max, Math.max(min, Math.floor(Math.log(latency) / Math.log(base))));
|
|
11
|
-
return lang_1.isNaNNumber(index) ? 0 : index; // index is NaN if latency is not a positive number
|
|
11
|
+
return (0, lang_1.isNaNNumber)(index) ? 0 : index; // index is NaN if latency is not a positive number
|
|
12
12
|
}
|
|
13
13
|
exports.findLatencyIndex = findLatencyIndex;
|
|
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var AbstractSegmentsCacheSync_1 = require("../AbstractSegmentsCacheSync");
|
|
6
6
|
var constants_1 = require("./constants");
|
|
7
7
|
var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
8
|
-
tslib_1.__extends(MySegmentsCacheInLocal, _super);
|
|
8
|
+
(0, tslib_1.__extends)(MySegmentsCacheInLocal, _super);
|
|
9
9
|
function MySegmentsCacheInLocal(log, keys) {
|
|
10
10
|
var _this = _super.call(this) || this;
|
|
11
11
|
_this.log = log;
|
|
@@ -9,7 +9,7 @@ var constants_1 = require("./constants");
|
|
|
9
9
|
* ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
|
|
10
10
|
*/
|
|
11
11
|
var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
12
|
-
tslib_1.__extends(SplitsCacheInLocal, _super);
|
|
12
|
+
(0, tslib_1.__extends)(SplitsCacheInLocal, _super);
|
|
13
13
|
/**
|
|
14
14
|
* @param {KeyBuilderCS} keys
|
|
15
15
|
* @param {number | undefined} expirationTimestamp
|
|
@@ -27,7 +27,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
27
27
|
return _this;
|
|
28
28
|
}
|
|
29
29
|
SplitsCacheInLocal.prototype._decrementCount = function (key) {
|
|
30
|
-
var count = lang_1.toNumber(localStorage.getItem(key)) - 1;
|
|
30
|
+
var count = (0, lang_1.toNumber)(localStorage.getItem(key)) - 1;
|
|
31
31
|
// @ts-expect-error
|
|
32
32
|
if (count > 0)
|
|
33
33
|
localStorage.setItem(key, count);
|
|
@@ -41,7 +41,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
41
41
|
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
42
42
|
this._decrementCount(ttKey);
|
|
43
43
|
}
|
|
44
|
-
if (AbstractSplitsCacheSync_1.usesSegments(split)) {
|
|
44
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split)) {
|
|
45
45
|
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
46
46
|
this._decrementCount(segmentsCountKey);
|
|
47
47
|
}
|
|
@@ -57,12 +57,12 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
57
57
|
if (split.trafficTypeName) {
|
|
58
58
|
var ttKey = this.keys.buildTrafficTypeKey(split.trafficTypeName);
|
|
59
59
|
// @ts-expect-error
|
|
60
|
-
localStorage.setItem(ttKey, lang_1.toNumber(localStorage.getItem(ttKey)) + 1);
|
|
60
|
+
localStorage.setItem(ttKey, (0, lang_1.toNumber)(localStorage.getItem(ttKey)) + 1);
|
|
61
61
|
}
|
|
62
|
-
if (AbstractSplitsCacheSync_1.usesSegments(split)) {
|
|
62
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(split)) {
|
|
63
63
|
var segmentsCountKey = this.keys.buildSplitsWithSegmentCountKey();
|
|
64
64
|
// @ts-expect-error
|
|
65
|
-
localStorage.setItem(segmentsCountKey, lang_1.toNumber(localStorage.getItem(segmentsCountKey)) + 1);
|
|
65
|
+
localStorage.setItem(segmentsCountKey, (0, lang_1.toNumber)(localStorage.getItem(segmentsCountKey)) + 1);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -161,7 +161,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
161
161
|
var value = localStorage.getItem(this.keys.buildSplitsTillKey());
|
|
162
162
|
if (value !== null) {
|
|
163
163
|
value = parseInt(value, 10);
|
|
164
|
-
return lang_1.isNaNNumber(value) ? n : value;
|
|
164
|
+
return (0, lang_1.isNaNNumber)(value) ? n : value;
|
|
165
165
|
}
|
|
166
166
|
return n;
|
|
167
167
|
};
|
|
@@ -178,16 +178,16 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
178
178
|
return accum;
|
|
179
179
|
};
|
|
180
180
|
SplitsCacheInLocal.prototype.trafficTypeExists = function (trafficType) {
|
|
181
|
-
var ttCount = lang_1.toNumber(localStorage.getItem(this.keys.buildTrafficTypeKey(trafficType)));
|
|
182
|
-
return lang_1.isFiniteNumber(ttCount) && ttCount > 0;
|
|
181
|
+
var ttCount = (0, lang_1.toNumber)(localStorage.getItem(this.keys.buildTrafficTypeKey(trafficType)));
|
|
182
|
+
return (0, lang_1.isFiniteNumber)(ttCount) && ttCount > 0;
|
|
183
183
|
};
|
|
184
184
|
SplitsCacheInLocal.prototype.usesSegments = function () {
|
|
185
185
|
// If cache hasn't been synchronized with the cloud, assume we need them.
|
|
186
186
|
if (!this.hasSync)
|
|
187
187
|
return true;
|
|
188
188
|
var storedCount = localStorage.getItem(this.keys.buildSplitsWithSegmentCountKey());
|
|
189
|
-
var splitsWithSegmentsCount = storedCount === null ? 0 : lang_1.toNumber(storedCount);
|
|
190
|
-
if (lang_1.isFiniteNumber(splitsWithSegmentsCount)) {
|
|
189
|
+
var splitsWithSegmentsCount = storedCount === null ? 0 : (0, lang_1.toNumber)(storedCount);
|
|
190
|
+
if ((0, lang_1.isFiniteNumber)(splitsWithSegmentsCount)) {
|
|
191
191
|
return splitsWithSegmentsCount > 0;
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
@@ -212,7 +212,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
212
212
|
var value = localStorage.getItem(this.keys.buildLastUpdatedKey());
|
|
213
213
|
if (value !== null) {
|
|
214
214
|
value = parseInt(value, 10);
|
|
215
|
-
if (!lang_1.isNaNNumber(value) && expirationTimestamp && value < expirationTimestamp)
|
|
215
|
+
if (!(0, lang_1.isNaNNumber)(value) && expirationTimestamp && value < expirationTimestamp)
|
|
216
216
|
this.clear();
|
|
217
217
|
}
|
|
218
218
|
};
|
|
@@ -20,12 +20,12 @@ var constants_2 = require("../../utils/constants");
|
|
|
20
20
|
*/
|
|
21
21
|
function InLocalStorage(options) {
|
|
22
22
|
if (options === void 0) { options = {}; }
|
|
23
|
-
var prefix = KeyBuilder_1.validatePrefix(options.prefix);
|
|
23
|
+
var prefix = (0, KeyBuilder_1.validatePrefix)(options.prefix);
|
|
24
24
|
function InLocalStorageCSFactory(params) {
|
|
25
25
|
// Fallback to InMemoryStorage if LocalStorage API is not available
|
|
26
|
-
if (!isLocalStorageAvailable_1.isLocalStorageAvailable()) {
|
|
26
|
+
if (!(0, isLocalStorageAvailable_1.isLocalStorageAvailable)()) {
|
|
27
27
|
params.log.warn(constants_1.LOG_PREFIX + 'LocalStorage API is unavailable. Fallbacking into default MEMORY storage');
|
|
28
|
-
return InMemoryStorageCS_1.InMemoryStorageCSFactory(params);
|
|
28
|
+
return (0, InMemoryStorageCS_1.InMemoryStorageCSFactory)(params);
|
|
29
29
|
}
|
|
30
30
|
var log = params.log;
|
|
31
31
|
var keys = new KeyBuilderCS_1.KeyBuilderCS(prefix, params.matchingKey);
|
|
@@ -33,7 +33,7 @@ function InLocalStorage(options) {
|
|
|
33
33
|
return {
|
|
34
34
|
splits: new SplitsCacheInLocal_1.SplitsCacheInLocal(log, keys, expirationTimestamp, params.splitFiltersValidation),
|
|
35
35
|
segments: new MySegmentsCacheInLocal_1.MySegmentsCacheInLocal(log, keys),
|
|
36
|
-
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(),
|
|
36
|
+
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
37
37
|
impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory_1.ImpressionCountsCacheInMemory() : undefined,
|
|
38
38
|
events: new EventsCacheInMemory_1.EventsCacheInMemory(params.eventsQueueSize),
|
|
39
39
|
destroy: function () {
|
|
@@ -33,7 +33,7 @@ var AttributesCacheInMemory = /** @class */ (function () {
|
|
|
33
33
|
* @returns {boolean} attributes were stored
|
|
34
34
|
*/
|
|
35
35
|
AttributesCacheInMemory.prototype.setAttributes = function (attributes) {
|
|
36
|
-
this.attributesCache = objectAssign_1.objectAssign(this.attributesCache, attributes);
|
|
36
|
+
this.attributesCache = (0, objectAssign_1.objectAssign)(this.attributesCache, attributes);
|
|
37
37
|
return true;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
@@ -10,7 +10,7 @@ var ImpressionCountsCacheInMemory = /** @class */ (function () {
|
|
|
10
10
|
* Builds key to be stored in the cache with the featureName and the timeFrame truncated.
|
|
11
11
|
*/
|
|
12
12
|
ImpressionCountsCacheInMemory.prototype._makeKey = function (featureName, timeFrame) {
|
|
13
|
-
return featureName + "::" + time_1.truncateTimeFrame(timeFrame);
|
|
13
|
+
return featureName + "::" + (0, time_1.truncateTimeFrame)(timeFrame);
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Increments the quantity of impressions with the passed featureName and timeFrame.
|
|
@@ -2,15 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImpressionsCacheInMemory = void 0;
|
|
4
4
|
var ImpressionsCacheInMemory = /** @class */ (function () {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param impressionsQueueSize number of queued impressions to call onFullQueueCb.
|
|
8
|
+
* Default value is 0, that means no maximum value, in case we want to avoid this being triggered.
|
|
9
|
+
*/
|
|
10
|
+
function ImpressionsCacheInMemory(impressionsQueueSize) {
|
|
11
|
+
if (impressionsQueueSize === void 0) { impressionsQueueSize = 0; }
|
|
12
|
+
this.maxQueue = impressionsQueueSize;
|
|
6
13
|
this.queue = [];
|
|
7
14
|
}
|
|
15
|
+
ImpressionsCacheInMemory.prototype.setOnFullQueueCb = function (cb) {
|
|
16
|
+
this.onFullQueue = cb;
|
|
17
|
+
};
|
|
8
18
|
/**
|
|
9
19
|
* Store impressions in sequential order
|
|
10
20
|
*/
|
|
11
21
|
ImpressionsCacheInMemory.prototype.track = function (data) {
|
|
12
22
|
var _a;
|
|
13
23
|
(_a = this.queue).push.apply(_a, data);
|
|
24
|
+
// Check if the cache queue is full and we need to flush it.
|
|
25
|
+
if (this.maxQueue > 0 && this.queue.length >= this.maxQueue && this.onFullQueue) {
|
|
26
|
+
this.onFullQueue();
|
|
27
|
+
}
|
|
14
28
|
};
|
|
15
29
|
/**
|
|
16
30
|
* Clear the data stored on the cache.
|
|
@@ -16,7 +16,7 @@ function InMemoryStorageFactory(params) {
|
|
|
16
16
|
return {
|
|
17
17
|
splits: new SplitsCacheInMemory_1.SplitsCacheInMemory(),
|
|
18
18
|
segments: new SegmentsCacheInMemory_1.SegmentsCacheInMemory(),
|
|
19
|
-
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(),
|
|
19
|
+
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
20
20
|
impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory_1.ImpressionCountsCacheInMemory() : undefined,
|
|
21
21
|
events: new EventsCacheInMemory_1.EventsCacheInMemory(params.eventsQueueSize),
|
|
22
22
|
// When using MEMORY we should clean all the caches to leave them empty
|
|
@@ -16,7 +16,7 @@ function InMemoryStorageCSFactory(params) {
|
|
|
16
16
|
return {
|
|
17
17
|
splits: new SplitsCacheInMemory_1.SplitsCacheInMemory(),
|
|
18
18
|
segments: new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory(),
|
|
19
|
-
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(),
|
|
19
|
+
impressions: new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(params.impressionsQueueSize),
|
|
20
20
|
impressionCounts: params.optimize ? new ImpressionCountsCacheInMemory_1.ImpressionCountsCacheInMemory() : undefined,
|
|
21
21
|
events: new EventsCacheInMemory_1.EventsCacheInMemory(params.eventsQueueSize),
|
|
22
22
|
// When using MEMORY we should clean all the caches to leave them empty
|
|
@@ -17,7 +17,7 @@ var LatenciesCacheInMemory = /** @class */ (function () {
|
|
|
17
17
|
];
|
|
18
18
|
}
|
|
19
19
|
// +1 based on the latency number
|
|
20
|
-
this.counters[metricName][findLatencyIndex_1.findLatencyIndex(latency)]++;
|
|
20
|
+
this.counters[metricName][(0, findLatencyIndex_1.findLatencyIndex)(latency)]++;
|
|
21
21
|
return true;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -8,7 +8,7 @@ var AbstractSegmentsCacheSync_1 = require("../AbstractSegmentsCacheSync");
|
|
|
8
8
|
* Supported by all JS runtimes.
|
|
9
9
|
*/
|
|
10
10
|
var MySegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
11
|
-
tslib_1.__extends(MySegmentsCacheInMemory, _super);
|
|
11
|
+
(0, tslib_1.__extends)(MySegmentsCacheInMemory, _super);
|
|
12
12
|
function MySegmentsCacheInMemory() {
|
|
13
13
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
14
14
|
_this.segmentCache = {};
|
|
@@ -10,7 +10,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
10
10
|
* Supported by all JS runtimes.
|
|
11
11
|
*/
|
|
12
12
|
var SegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
13
|
-
tslib_1.__extends(SegmentsCacheInMemory, _super);
|
|
13
|
+
(0, tslib_1.__extends)(SegmentsCacheInMemory, _super);
|
|
14
14
|
function SegmentsCacheInMemory() {
|
|
15
15
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
16
16
|
_this.segmentCache = {};
|
|
@@ -63,7 +63,7 @@ var SegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
|
63
63
|
};
|
|
64
64
|
SegmentsCacheInMemory.prototype.getChangeNumber = function (name) {
|
|
65
65
|
var value = this.segmentChangeNumber[name];
|
|
66
|
-
return lang_1.isIntegerNumber(value) ? value : -1;
|
|
66
|
+
return (0, lang_1.isIntegerNumber)(value) ? value : -1;
|
|
67
67
|
};
|
|
68
68
|
return SegmentsCacheInMemory;
|
|
69
69
|
}(AbstractSegmentsCacheSync_1.AbstractSegmentsCacheSync));
|
|
@@ -9,7 +9,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
9
9
|
* Supported by all JS runtimes.
|
|
10
10
|
*/
|
|
11
11
|
var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
12
|
-
tslib_1.__extends(SplitsCacheInMemory, _super);
|
|
12
|
+
(0, tslib_1.__extends)(SplitsCacheInMemory, _super);
|
|
13
13
|
function SplitsCacheInMemory() {
|
|
14
14
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
15
15
|
_this.splitsCache = {};
|
|
@@ -34,7 +34,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
34
34
|
if (!this.ttCache[previousTtName])
|
|
35
35
|
delete this.ttCache[previousTtName];
|
|
36
36
|
}
|
|
37
|
-
if (AbstractSplitsCacheSync_1.usesSegments(previousSplit)) { // Substract from segments count for the previous version of this Split.
|
|
37
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(previousSplit)) { // Substract from segments count for the previous version of this Split.
|
|
38
38
|
this.splitsWithSegmentsCount--;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -50,7 +50,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
50
50
|
this.ttCache[ttName]++;
|
|
51
51
|
}
|
|
52
52
|
// Add to segments count for the new version of the Split
|
|
53
|
-
if (AbstractSplitsCacheSync_1.usesSegments(parsedSplit))
|
|
53
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(parsedSplit))
|
|
54
54
|
this.splitsWithSegmentsCount++;
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
@@ -71,7 +71,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
71
71
|
delete this.ttCache[ttName];
|
|
72
72
|
}
|
|
73
73
|
// Update the segments count.
|
|
74
|
-
if (AbstractSplitsCacheSync_1.usesSegments(parsedSplit))
|
|
74
|
+
if ((0, AbstractSplitsCacheSync_1.usesSegments)(parsedSplit))
|
|
75
75
|
this.splitsWithSegmentsCount--;
|
|
76
76
|
return true;
|
|
77
77
|
}
|
|
@@ -93,7 +93,7 @@ var SplitsCacheInMemory = /** @class */ (function (_super) {
|
|
|
93
93
|
return Object.keys(this.splitsCache);
|
|
94
94
|
};
|
|
95
95
|
SplitsCacheInMemory.prototype.trafficTypeExists = function (trafficType) {
|
|
96
|
-
return lang_1.isFiniteNumber(this.ttCache[trafficType]) && this.ttCache[trafficType] > 0;
|
|
96
|
+
return (0, lang_1.isFiniteNumber)(this.ttCache[trafficType]) && this.ttCache[trafficType] > 0;
|
|
97
97
|
};
|
|
98
98
|
SplitsCacheInMemory.prototype.usesSegments = function () {
|
|
99
99
|
return this.getChangeNumber() === -1 || this.splitsWithSegmentsCount > 0;
|
|
@@ -8,7 +8,7 @@ var LatenciesCacheInRedis = /** @class */ (function () {
|
|
|
8
8
|
this.redis = redis;
|
|
9
9
|
}
|
|
10
10
|
LatenciesCacheInRedis.prototype.track = function (metricName, latency) {
|
|
11
|
-
var bucketNumber = findLatencyIndex_1.findLatencyIndex(latency);
|
|
11
|
+
var bucketNumber = (0, findLatencyIndex_1.findLatencyIndex)(latency);
|
|
12
12
|
return this.redis.incr(this.keys.buildLatencyKey(metricName, bucketNumber)).catch(function () {
|
|
13
13
|
// noop, for telemetry metrics there's no need to throw.
|
|
14
14
|
}).then(function () { return true; });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RedisAdapter = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var ioredis_1 = tslib_1.__importDefault(require("ioredis"));
|
|
5
|
+
var ioredis_1 = (0, tslib_1.__importDefault)(require("ioredis"));
|
|
6
6
|
var lang_1 = require("../../utils/lang");
|
|
7
7
|
var sets_1 = require("../../utils/lang/sets");
|
|
8
8
|
var thenable_1 = require("../../utils/promise/thenable");
|
|
@@ -25,7 +25,7 @@ var DEFAULT_LIBRARY_OPTIONS = {
|
|
|
25
25
|
* Redis adapter on top of the library of choice (written with ioredis) for some extra control.
|
|
26
26
|
*/
|
|
27
27
|
var RedisAdapter = /** @class */ (function (_super) {
|
|
28
|
-
tslib_1.__extends(RedisAdapter, _super);
|
|
28
|
+
(0, tslib_1.__extends)(RedisAdapter, _super);
|
|
29
29
|
function RedisAdapter(log, storageSettings) {
|
|
30
30
|
var _this = this;
|
|
31
31
|
var options = RedisAdapter._defineOptions(storageSettings);
|
|
@@ -66,7 +66,7 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
66
66
|
instance.log.debug(LOG_PREFIX + ("Executing " + method + "."));
|
|
67
67
|
// Return original method
|
|
68
68
|
var result = originalMethod.apply(instance, params);
|
|
69
|
-
if (thenable_1.thenable(result)) {
|
|
69
|
+
if ((0, thenable_1.thenable)(result)) {
|
|
70
70
|
// For handling pending commands on disconnect, add to the set and remove once finished.
|
|
71
71
|
// On sync commands there's no need, only thenables.
|
|
72
72
|
instance._runningCommands.add(result);
|
|
@@ -75,7 +75,7 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
75
75
|
};
|
|
76
76
|
// Both success and error remove from queue.
|
|
77
77
|
result.then(cleanUpRunningCommandsCb, cleanUpRunningCommandsCb);
|
|
78
|
-
return timeout_1.timeout(instance._options.operationTimeout, result).catch(function (err) {
|
|
78
|
+
return (0, timeout_1.timeout)(instance._options.operationTimeout, result).catch(function (err) {
|
|
79
79
|
instance.log.error(LOG_PREFIX + (method + " operation threw an error or exceeded configured timeout of " + instance._options.operationTimeout + "ms. Message: " + err));
|
|
80
80
|
// Handling is not the adapter responsibility.
|
|
81
81
|
throw err;
|
|
@@ -110,7 +110,7 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
110
110
|
setTimeout(function deferedDisconnect() {
|
|
111
111
|
if (instance._runningCommands.size > 0) {
|
|
112
112
|
instance.log.info(LOG_PREFIX + ("Attempting to disconnect but there are " + instance._runningCommands.size + " commands still waiting for resolution. Defering disconnection until those finish."));
|
|
113
|
-
Promise.all(sets_1.setToArray(instance._runningCommands))
|
|
113
|
+
Promise.all((0, sets_1.setToArray)(instance._runningCommands))
|
|
114
114
|
.then(function () {
|
|
115
115
|
instance.log.debug(LOG_PREFIX + 'Pending commands finished successfully, disconnecting.');
|
|
116
116
|
originalMethod.apply(instance, params);
|
|
@@ -133,10 +133,10 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
133
133
|
* Keeping both redis setup options for backwards compatibility.
|
|
134
134
|
*/
|
|
135
135
|
RedisAdapter._defineLibrarySettings = function (options) {
|
|
136
|
-
var opts = lang_1.merge({}, DEFAULT_LIBRARY_OPTIONS);
|
|
136
|
+
var opts = (0, lang_1.merge)({}, DEFAULT_LIBRARY_OPTIONS);
|
|
137
137
|
var result = [opts];
|
|
138
|
-
if (!lang_1.isString(options.url)) {
|
|
139
|
-
lang_1.merge(opts, {
|
|
138
|
+
if (!(0, lang_1.isString)(options.url)) {
|
|
139
|
+
(0, lang_1.merge)(opts, {
|
|
140
140
|
host: options.host,
|
|
141
141
|
port: options.port,
|
|
142
142
|
db: options.db,
|
|
@@ -154,9 +154,15 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
154
154
|
RedisAdapter._defineOptions = function (_a) {
|
|
155
155
|
var connectionTimeout = _a.connectionTimeout, operationTimeout = _a.operationTimeout, url = _a.url, host = _a.host, port = _a.port, db = _a.db, pass = _a.pass;
|
|
156
156
|
var parsedOptions = {
|
|
157
|
-
connectionTimeout: connectionTimeout,
|
|
157
|
+
connectionTimeout: connectionTimeout,
|
|
158
|
+
operationTimeout: operationTimeout,
|
|
159
|
+
url: url,
|
|
160
|
+
host: host,
|
|
161
|
+
port: port,
|
|
162
|
+
db: db,
|
|
163
|
+
pass: pass
|
|
158
164
|
};
|
|
159
|
-
return lang_1.merge({}, DEFAULT_OPTIONS, parsedOptions);
|
|
165
|
+
return (0, lang_1.merge)({}, DEFAULT_OPTIONS, parsedOptions);
|
|
160
166
|
};
|
|
161
167
|
return RedisAdapter;
|
|
162
168
|
}(ioredis_1.default));
|
|
@@ -37,7 +37,7 @@ var SegmentsCacheInRedis = /** @class */ (function () {
|
|
|
37
37
|
var _this = this;
|
|
38
38
|
return this.redis.get(this.keys.buildSegmentTillKey(name)).then(function (value) {
|
|
39
39
|
var i = parseInt(value, 10);
|
|
40
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
40
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
41
41
|
}).catch(function (e) {
|
|
42
42
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from segments storage. Error: ' + e);
|
|
43
43
|
return -1;
|
|
@@ -20,7 +20,7 @@ function processPipelineAnswer(results) {
|
|
|
20
20
|
* Supported by Node.
|
|
21
21
|
*/
|
|
22
22
|
var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
23
|
-
tslib_1.__extends(SplitsCacheInRedis, _super);
|
|
23
|
+
(0, tslib_1.__extends)(SplitsCacheInRedis, _super);
|
|
24
24
|
function SplitsCacheInRedis(log, keys, redis) {
|
|
25
25
|
var _this = _super.call(this) || this;
|
|
26
26
|
_this.log = log;
|
|
@@ -142,7 +142,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
142
142
|
var _this = this;
|
|
143
143
|
return this.redis.get(this.keys.buildSplitsTillKey()).then(function (value) {
|
|
144
144
|
var i = parseInt(value, 10);
|
|
145
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
145
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
146
146
|
}).catch(function (e) {
|
|
147
147
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from storage. Error: ' + e);
|
|
148
148
|
return -1;
|
|
@@ -183,7 +183,7 @@ var SplitsCacheInRedis = /** @class */ (function (_super) {
|
|
|
183
183
|
if (ttCount === null)
|
|
184
184
|
return false; // if entry doesn't exist, means that TT doesn't exist
|
|
185
185
|
ttCount = parseInt(ttCount, 10);
|
|
186
|
-
if (!lang_1.isFiniteNumber(ttCount) || ttCount < 0) {
|
|
186
|
+
if (!(0, lang_1.isFiniteNumber)(ttCount) || ttCount < 0) {
|
|
187
187
|
_this.log.info(constants_1.LOG_PREFIX + ("Could not validate traffic type existance of " + trafficType + " due to data corruption of some sorts."));
|
|
188
188
|
return false;
|
|
189
189
|
}
|
|
@@ -17,7 +17,7 @@ var constants_1 = require("../../utils/constants");
|
|
|
17
17
|
*/
|
|
18
18
|
function InRedisStorage(options) {
|
|
19
19
|
if (options === void 0) { options = {}; }
|
|
20
|
-
var prefix = KeyBuilder_1.validatePrefix(options.prefix);
|
|
20
|
+
var prefix = (0, KeyBuilder_1.validatePrefix)(options.prefix);
|
|
21
21
|
function InRedisStorageFactory(_a) {
|
|
22
22
|
var log = _a.log, metadata = _a.metadata, onReadyCb = _a.onReadyCb;
|
|
23
23
|
var keys = new KeyBuilderSS_1.KeyBuilderSS(prefix, metadata);
|
|
@@ -66,7 +66,7 @@ var SegmentsCachePluggable = /** @class */ (function () {
|
|
|
66
66
|
var _this = this;
|
|
67
67
|
return this.wrapper.get(this.keys.buildSegmentTillKey(name)).then(function (value) {
|
|
68
68
|
var i = parseInt(value, 10);
|
|
69
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
69
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
70
70
|
}).catch(function (e) {
|
|
71
71
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from segments storage. Error: ' + e);
|
|
72
72
|
return -1;
|
|
@@ -9,7 +9,7 @@ var AbstractSplitsCacheAsync_1 = require("../AbstractSplitsCacheAsync");
|
|
|
9
9
|
* ISplitsCacheAsync implementation for pluggable storages.
|
|
10
10
|
*/
|
|
11
11
|
var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
12
|
-
tslib_1.__extends(SplitsCachePluggable, _super);
|
|
12
|
+
(0, tslib_1.__extends)(SplitsCachePluggable, _super);
|
|
13
13
|
/**
|
|
14
14
|
* Create a SplitsCache that uses a storage wrapper.
|
|
15
15
|
* @param log Logger instance.
|
|
@@ -154,7 +154,7 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
154
154
|
if (ttCount === null)
|
|
155
155
|
return false; // if entry doesn't exist, means that TT doesn't exist
|
|
156
156
|
ttCount = parseInt(ttCount, 10);
|
|
157
|
-
if (!lang_1.isFiniteNumber(ttCount) || ttCount < 0) {
|
|
157
|
+
if (!(0, lang_1.isFiniteNumber)(ttCount) || ttCount < 0) {
|
|
158
158
|
_this.log.info(constants_1.LOG_PREFIX + ("Could not validate traffic type existence of " + trafficType + " due to data corruption of some sorts."));
|
|
159
159
|
return false;
|
|
160
160
|
}
|
|
@@ -182,7 +182,7 @@ var SplitsCachePluggable = /** @class */ (function (_super) {
|
|
|
182
182
|
var _this = this;
|
|
183
183
|
return this.wrapper.get(this.keys.buildSplitsTillKey()).then(function (value) {
|
|
184
184
|
var i = parseInt(value, 10);
|
|
185
|
-
return lang_1.isNaNNumber(i) ? -1 : i;
|
|
185
|
+
return (0, lang_1.isNaNNumber)(i) ? -1 : i;
|
|
186
186
|
}).catch(function (e) {
|
|
187
187
|
_this.log.error(constants_1.LOG_PREFIX + 'Could not retrieve changeNumber from storage. Error: ' + e);
|
|
188
188
|
return -1;
|
|
@@ -35,11 +35,11 @@ function inMemoryWrapperFactory(connDelay) {
|
|
|
35
35
|
return Promise.resolve(result);
|
|
36
36
|
},
|
|
37
37
|
getKeysByPrefix: function (prefix) {
|
|
38
|
-
return Promise.resolve(Object.keys(_cache).filter(function (key) { return lang_1.startsWith(key, prefix); }));
|
|
38
|
+
return Promise.resolve(Object.keys(_cache).filter(function (key) { return (0, lang_1.startsWith)(key, prefix); }));
|
|
39
39
|
},
|
|
40
40
|
incr: function (key) {
|
|
41
41
|
if (key in _cache) {
|
|
42
|
-
var count = lang_1.toNumber(_cache[key]) + 1;
|
|
42
|
+
var count = (0, lang_1.toNumber)(_cache[key]) + 1;
|
|
43
43
|
if (isNaN(count))
|
|
44
44
|
return Promise.reject('Given key is not a number');
|
|
45
45
|
_cache[key] = count + '';
|
|
@@ -52,7 +52,7 @@ function inMemoryWrapperFactory(connDelay) {
|
|
|
52
52
|
},
|
|
53
53
|
decr: function (key) {
|
|
54
54
|
if (key in _cache) {
|
|
55
|
-
var count = lang_1.toNumber(_cache[key]) - 1;
|
|
55
|
+
var count = (0, lang_1.toNumber)(_cache[key]) - 1;
|
|
56
56
|
if (isNaN(count))
|
|
57
57
|
return Promise.reject('Given key is not a number');
|
|
58
58
|
_cache[key] = count + '';
|
|
@@ -117,7 +117,7 @@ function inMemoryWrapperFactory(connDelay) {
|
|
|
117
117
|
if (!set)
|
|
118
118
|
return Promise.resolve([]);
|
|
119
119
|
if (set instanceof sets_1._Set)
|
|
120
|
-
return Promise.resolve(sets_1.setToArray(set));
|
|
120
|
+
return Promise.resolve((0, sets_1.setToArray)(set));
|
|
121
121
|
return Promise.reject('key is not a set');
|
|
122
122
|
},
|
|
123
123
|
// always connects and disconnects
|
|
@@ -23,7 +23,7 @@ var NO_VALID_WRAPPER_INTERFACE = 'The provided wrapper instance doesn’t follow
|
|
|
23
23
|
* @throws Will throw an error if the options are invalid. Example: wrapper is not provided or doesn't have some methods.
|
|
24
24
|
*/
|
|
25
25
|
function validatePluggableStorageOptions(options) {
|
|
26
|
-
if (!lang_1.isObject(options) || !lang_1.isObject(options.wrapper))
|
|
26
|
+
if (!(0, lang_1.isObject)(options) || !(0, lang_1.isObject)(options.wrapper))
|
|
27
27
|
throw new Error(NO_VALID_WRAPPER);
|
|
28
28
|
var wrapper = options.wrapper;
|
|
29
29
|
var missingMethods = wrapperAdapter_1.METHODS_TO_PROMISE_WRAP.filter(function (method) { return typeof wrapper[method] !== 'function'; });
|
|
@@ -52,18 +52,18 @@ function promisifyEventsTrack(events) {
|
|
|
52
52
|
*/
|
|
53
53
|
function PluggableStorage(options) {
|
|
54
54
|
validatePluggableStorageOptions(options);
|
|
55
|
-
var prefix = KeyBuilder_1.validatePrefix(options.prefix);
|
|
55
|
+
var prefix = (0, KeyBuilder_1.validatePrefix)(options.prefix);
|
|
56
56
|
function PluggableStorageFactory(_a) {
|
|
57
|
-
var log = _a.log, metadata = _a.metadata, onReadyCb = _a.onReadyCb, mode = _a.mode, eventsQueueSize = _a.eventsQueueSize, optimize = _a.optimize;
|
|
57
|
+
var log = _a.log, metadata = _a.metadata, onReadyCb = _a.onReadyCb, mode = _a.mode, eventsQueueSize = _a.eventsQueueSize, impressionsQueueSize = _a.impressionsQueueSize, optimize = _a.optimize;
|
|
58
58
|
var keys = new KeyBuilderSS_1.KeyBuilderSS(prefix, metadata);
|
|
59
|
-
var wrapper = wrapperAdapter_1.wrapperAdapter(log, options.wrapper);
|
|
59
|
+
var wrapper = (0, wrapperAdapter_1.wrapperAdapter)(log, options.wrapper);
|
|
60
60
|
var isPartialConsumer = mode === constants_1.CONSUMER_PARTIAL_MODE;
|
|
61
61
|
// Connects to wrapper and emits SDK_READY event on main client
|
|
62
62
|
wrapperConnect(wrapper, onReadyCb);
|
|
63
63
|
return {
|
|
64
64
|
splits: new SplitsCachePluggable_1.SplitsCachePluggable(log, keys, wrapper),
|
|
65
65
|
segments: new SegmentsCachePluggable_1.SegmentsCachePluggable(log, keys, wrapper),
|
|
66
|
-
impressions: isPartialConsumer ? new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory() : new ImpressionsCachePluggable_1.ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
|
|
66
|
+
impressions: isPartialConsumer ? new ImpressionsCacheInMemory_1.ImpressionsCacheInMemory(impressionsQueueSize) : new ImpressionsCachePluggable_1.ImpressionsCachePluggable(log, keys.buildImpressionsKey(), wrapper, metadata),
|
|
67
67
|
impressionCounts: optimize ? new ImpressionCountsCacheInMemory_1.ImpressionCountsCacheInMemory() : undefined,
|
|
68
68
|
events: isPartialConsumer ? promisifyEventsTrack(new EventsCacheInMemory_1.EventsCacheInMemory(eventsQueueSize)) : new EventsCachePluggable_1.EventsCachePluggable(log, keys.buildEventsKey(), wrapper, metadata),
|
|
69
69
|
// @TODO add telemetry cache when required
|
|
@@ -74,7 +74,7 @@ function PluggableStorage(options) {
|
|
|
74
74
|
// emits SDK_READY event on shared clients and returns a reference to the storage
|
|
75
75
|
shared: function (_, onReadyCb) {
|
|
76
76
|
wrapperConnect(wrapper, onReadyCb);
|
|
77
|
-
return tslib_1.__assign(tslib_1.__assign({}, this), {
|
|
77
|
+
return (0, tslib_1.__assign)((0, tslib_1.__assign)({}, this), {
|
|
78
78
|
// no-op destroy, to disconnect the wrapper only when the main client is destroyed
|
|
79
79
|
destroy: function () { } });
|
|
80
80
|
}
|
|
@@ -5,7 +5,7 @@ var splitsParserFromFile_1 = require("./splitsParser/splitsParserFromFile");
|
|
|
5
5
|
var syncManagerOffline_1 = require("./syncManagerOffline");
|
|
6
6
|
// Singleton instance of the factory function for offline SyncManager from YAML file (a.k.a. localhostFromFile)
|
|
7
7
|
// Requires Node 'fs' and 'path' APIs.
|
|
8
|
-
var localhostFromFile = syncManagerOffline_1.syncManagerOfflineFactory(splitsParserFromFile_1.splitsParserFromFileFactory);
|
|
8
|
+
var localhostFromFile = (0, syncManagerOffline_1.syncManagerOfflineFactory)(splitsParserFromFile_1.splitsParserFromFileFactory);
|
|
9
9
|
localhostFromFile.type = 'LocalhostFromFile';
|
|
10
10
|
function LocalhostFromFile() {
|
|
11
11
|
return localhostFromFile;
|
|
@@ -5,7 +5,7 @@ var splitsParserFromSettings_1 = require("./splitsParser/splitsParserFromSetting
|
|
|
5
5
|
var syncManagerOffline_1 = require("./syncManagerOffline");
|
|
6
6
|
// Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
|
|
7
7
|
// SDK instances instantiate their SyncManagers with the same factory
|
|
8
|
-
var localhostFromObject = syncManagerOffline_1.syncManagerOfflineFactory(splitsParserFromSettings_1.splitsParserFromSettingsFactory);
|
|
8
|
+
var localhostFromObject = (0, syncManagerOffline_1.syncManagerOfflineFactory)(splitsParserFromSettings_1.splitsParserFromSettingsFactory);
|
|
9
9
|
localhostFromObject.type = 'LocalhostFromObject';
|
|
10
10
|
function LocalhostFromObject() {
|
|
11
11
|
return localhostFromObject;
|