@splitsoftware/splitio-commons 1.6.2-rc.1 → 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/sdkClient/client.js +19 -7
- package/cjs/sdkClient/sdkClient.js +3 -1
- package/cjs/sdkFactory/index.js +15 -6
- package/cjs/sdkManager/index.js +3 -11
- package/cjs/services/splitApi.js +6 -6
- 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/telemetrySubmitter.js +8 -4
- package/cjs/sync/submitters/uniqueKeysSubmitter.js +16 -59
- package/cjs/trackers/impressionsTracker.js +17 -15
- package/cjs/trackers/strategy/strategyNone.js +1 -1
- package/cjs/trackers/strategy/strategyOptimized.js +2 -1
- package/cjs/trackers/telemetryTracker.js +6 -0
- package/cjs/trackers/uniqueKeysTracker.js +11 -42
- package/cjs/utils/constants/index.js +3 -2
- package/cjs/utils/lang/maps.js +15 -7
- package/cjs/utils/redis/RedisMock.js +31 -0
- package/cjs/utils/settingsValidation/index.js +0 -3
- package/esm/consent/sdkUserConsent.js +2 -2
- package/esm/evaluator/index.js +15 -16
- package/esm/integrations/ga/GaToSplit.js +8 -5
- package/esm/sdkClient/client.js +19 -7
- package/esm/sdkClient/sdkClient.js +3 -1
- package/esm/sdkFactory/index.js +16 -7
- package/esm/sdkManager/index.js +3 -11
- package/esm/services/splitApi.js +6 -6
- 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/telemetrySubmitter.js +9 -5
- package/esm/sync/submitters/uniqueKeysSubmitter.js +15 -56
- package/esm/trackers/impressionsTracker.js +17 -15
- package/esm/trackers/strategy/strategyNone.js +1 -1
- package/esm/trackers/strategy/strategyOptimized.js +2 -1
- package/esm/trackers/telemetryTracker.js +6 -0
- package/esm/trackers/uniqueKeysTracker.js +11 -42
- package/esm/utils/constants/index.js +1 -0
- package/esm/utils/lang/maps.js +15 -7
- package/esm/utils/redis/RedisMock.js +28 -0
- package/esm/utils/settingsValidation/index.js +0 -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/logger/.DS_Store +0 -0
- package/src/sdkClient/client.ts +21 -8
- package/src/sdkClient/sdkClient.ts +3 -1
- package/src/sdkFactory/index.ts +17 -7
- package/src/sdkManager/index.ts +3 -12
- package/src/services/splitApi.ts +6 -6
- package/src/services/types.ts +2 -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 +38 -30
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +5 -6
- package/src/sync/polling/updaters/splitChangesUpdater.ts +2 -2
- package/src/sync/submitters/telemetrySubmitter.ts +15 -8
- package/src/sync/submitters/types.ts +18 -6
- package/src/sync/submitters/uniqueKeysSubmitter.ts +18 -61
- package/src/trackers/impressionsTracker.ts +16 -15
- package/src/trackers/strategy/strategyNone.ts +1 -1
- package/src/trackers/strategy/strategyOptimized.ts +1 -1
- package/src/trackers/telemetryTracker.ts +7 -2
- package/src/trackers/types.ts +9 -7
- package/src/trackers/uniqueKeysTracker.ts +15 -47
- package/src/types.ts +0 -1
- package/src/utils/constants/index.ts +1 -0
- package/src/utils/lang/maps.ts +20 -8
- package/src/utils/redis/RedisMock.ts +33 -0
- package/src/utils/settingsValidation/index.ts +1 -4
- package/types/integrations/types.d.ts +2 -1
- package/types/services/types.d.ts +2 -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 +35 -35
- 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 +12 -6
- package/types/sync/submitters/uniqueKeysSubmitter.d.ts +0 -14
- package/types/trackers/types.d.ts +9 -11
- package/types/trackers/uniqueKeysTracker.d.ts +3 -3
- package/types/types.d.ts +0 -1
- package/types/utils/constants/index.d.ts +1 -0
- package/types/utils/lang/maps.d.ts +6 -2
- package/types/utils/redis/RedisMock.d.ts +4 -0
- package/types/utils/settingsValidation/index.d.ts +0 -1
- package/types/sdkClient/types.d.ts +0 -18
- package/types/storages/inMemory/CountsCacheInMemory.d.ts +0 -20
- package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +0 -20
- package/types/storages/inRedis/CountsCacheInRedis.d.ts +0 -9
- package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +0 -9
- package/types/sync/offline/LocalhostFromFile.d.ts +0 -2
- package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +0 -2
- package/types/sync/submitters/eventsSyncTask.d.ts +0 -8
- package/types/sync/submitters/impressionCountsSyncTask.d.ts +0 -13
- package/types/sync/submitters/impressionsSyncTask.d.ts +0 -14
- package/types/sync/submitters/metricsSyncTask.d.ts +0 -12
- package/types/sync/submitters/submitterSyncTask.d.ts +0 -10
- package/types/sync/syncTaskComposite.d.ts +0 -5
- package/types/trackers/filter/bloomFilter.d.ts +0 -10
- package/types/trackers/filter/dictionaryFilter.d.ts +0 -8
- package/types/trackers/filter/types.d.ts +0 -5
- package/types/utils/timeTracker/index.d.ts +0 -70
|
@@ -2,67 +2,36 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.uniqueKeysTrackerFactory = void 0;
|
|
4
4
|
var constants_1 = require("../logger/constants");
|
|
5
|
-
var sets_1 = require("../utils/lang/sets");
|
|
6
5
|
var noopFilterAdapter = {
|
|
7
6
|
add: function () { return true; },
|
|
8
7
|
contains: function () { return true; },
|
|
9
8
|
clear: function () { }
|
|
10
9
|
};
|
|
11
|
-
var DEFAULT_CACHE_SIZE = 30000;
|
|
12
10
|
/**
|
|
13
11
|
* Trackes uniques keys
|
|
14
12
|
* Unique Keys Tracker will be in charge of checking if the MTK was already sent to the BE in the last period
|
|
15
13
|
* or schedule to be sent; if not it will be added in an internal cache and sent in the next post.
|
|
16
14
|
*
|
|
17
15
|
* @param log Logger instance
|
|
16
|
+
* @param uniqueKeysCache cache to save unique keys
|
|
18
17
|
* @param filterAdapter filter adapter
|
|
19
|
-
* @param cacheSize optional internal cache size
|
|
20
|
-
* @param maxBulkSize optional max MTKs bulk size
|
|
21
18
|
*/
|
|
22
|
-
function uniqueKeysTrackerFactory(log,
|
|
19
|
+
function uniqueKeysTrackerFactory(log, uniqueKeysCache, filterAdapter) {
|
|
23
20
|
if (filterAdapter === void 0) { filterAdapter = noopFilterAdapter; }
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
var intervalId;
|
|
22
|
+
if (filterAdapter.refreshRate) {
|
|
23
|
+
intervalId = setInterval(filterAdapter.clear, filterAdapter.refreshRate);
|
|
24
|
+
}
|
|
27
25
|
return {
|
|
28
|
-
track: function (
|
|
29
|
-
if (!filterAdapter.add(
|
|
26
|
+
track: function (key, featureName) {
|
|
27
|
+
if (!filterAdapter.add(key, featureName)) {
|
|
30
28
|
log.debug(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER + "The feature " + featureName + " and key " + key + " exist in the filter");
|
|
31
29
|
return;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
uniqueKeysTracker[featureName] = new sets_1._Set();
|
|
35
|
-
var tracker = uniqueKeysTracker[featureName];
|
|
36
|
-
if (!tracker.has(key)) {
|
|
37
|
-
tracker.add(key);
|
|
38
|
-
log.debug(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER + "Key " + key + " added to feature " + featureName);
|
|
39
|
-
uniqueTrackerSize++;
|
|
40
|
-
}
|
|
41
|
-
if (uniqueTrackerSize >= cacheSize) {
|
|
42
|
-
log.warn(constants_1.LOG_PREFIX_UNIQUE_KEYS_TRACKER + "The UniqueKeysTracker size reached the maximum limit");
|
|
43
|
-
// @TODO trigger event to submitter to send mtk
|
|
44
|
-
uniqueTrackerSize = 0;
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
/**
|
|
48
|
-
* Pop the collected data, used as payload for posting.
|
|
49
|
-
*/
|
|
50
|
-
pop: function () {
|
|
51
|
-
var data = uniqueKeysTracker;
|
|
52
|
-
uniqueKeysTracker = {};
|
|
53
|
-
return data;
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Clear the data stored on the cache.
|
|
57
|
-
*/
|
|
58
|
-
clear: function () {
|
|
59
|
-
uniqueKeysTracker = {};
|
|
31
|
+
uniqueKeysCache.track(key, featureName);
|
|
60
32
|
},
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*/
|
|
64
|
-
isEmpty: function () {
|
|
65
|
-
return Object.keys(uniqueKeysTracker).length === 0;
|
|
33
|
+
stop: function () {
|
|
34
|
+
clearInterval(intervalId);
|
|
66
35
|
}
|
|
67
36
|
};
|
|
68
37
|
}
|
|
@@ -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 = exports.AUTH_REJECTION = 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 = {
|
|
@@ -42,6 +42,7 @@ exports.CONSUMER_ENUM = 1;
|
|
|
42
42
|
exports.CONSUMER_PARTIAL_ENUM = 2;
|
|
43
43
|
exports.OPTIMIZED_ENUM = 0;
|
|
44
44
|
exports.DEBUG_ENUM = 1;
|
|
45
|
+
exports.NONE_ENUM = 2;
|
|
45
46
|
exports.SPLITS = 'sp';
|
|
46
47
|
exports.IMPRESSIONS = 'im';
|
|
47
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;
|
|
@@ -34,8 +34,6 @@ exports.base = {
|
|
|
34
34
|
telemetryRefreshRate: 3600,
|
|
35
35
|
// publish evaluations each 300 sec (default value for OPTIMIZED impressions mode)
|
|
36
36
|
impressionsRefreshRate: 300,
|
|
37
|
-
// publish unique Keys each 900 sec (15 min)
|
|
38
|
-
uniqueKeysRefreshRate: 900,
|
|
39
37
|
// fetch offline changes each 15 sec
|
|
40
38
|
offlineRefreshRate: 15,
|
|
41
39
|
// publish events every 60 seconds after the first flush
|
|
@@ -114,7 +112,6 @@ function settingsValidation(config, validationParams) {
|
|
|
114
112
|
scheduler.segmentsRefreshRate = fromSecondsToMillis(scheduler.segmentsRefreshRate);
|
|
115
113
|
scheduler.offlineRefreshRate = fromSecondsToMillis(scheduler.offlineRefreshRate);
|
|
116
114
|
scheduler.eventsPushRate = fromSecondsToMillis(scheduler.eventsPushRate);
|
|
117
|
-
scheduler.uniqueKeysRefreshRate = fromSecondsToMillis(scheduler.uniqueKeysRefreshRate);
|
|
118
115
|
scheduler.telemetryRefreshRate = fromSecondsToMillis(validateMinValue('telemetryRefreshRate', scheduler.telemetryRefreshRate, 60));
|
|
119
116
|
// Default impressionsRefreshRate for DEBUG mode is 60 secs
|
|
120
117
|
if ((0, lang_1.get)(config, 'scheduler.impressionsRefreshRate') === undefined && withDefaults.sync.impressionsMode === constants_1.DEBUG)
|
|
@@ -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/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
|
});
|
package/esm/sdkFactory/index.js
CHANGED
|
@@ -14,14 +14,13 @@ import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
|
|
|
14
14
|
import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
|
|
15
15
|
import { strategyNoneFactory } from '../trackers/strategy/strategyNone';
|
|
16
16
|
import { uniqueKeysTrackerFactory } from '../trackers/uniqueKeysTracker';
|
|
17
|
-
import { NONE } from '../utils/constants';
|
|
17
|
+
import { NONE, OPTIMIZED } from '../utils/constants';
|
|
18
18
|
/**
|
|
19
19
|
* Modular SDK factory
|
|
20
20
|
*/
|
|
21
21
|
export function sdkFactory(params) {
|
|
22
22
|
var settings = params.settings, platform = params.platform, storageFactory = params.storageFactory, splitApiFactory = params.splitApiFactory, extraProps = params.extraProps, syncManagerFactory = params.syncManagerFactory, SignalListener = params.SignalListener, impressionsObserverFactory = params.impressionsObserverFactory, integrationsManagerFactory = params.integrationsManagerFactory, sdkManagerFactory = params.sdkManagerFactory, sdkClientMethodFactory = params.sdkClientMethodFactory, filterAdapterFactory = params.filterAdapterFactory;
|
|
23
23
|
var log = settings.log;
|
|
24
|
-
var impressionsMode = settings.sync.impressionsMode;
|
|
25
24
|
// @TODO handle non-recoverable errors, such as, global `fetch` not available, invalid API Key, etc.
|
|
26
25
|
// On non-recoverable errors, we should mark the SDK as destroyed and not start synchronization.
|
|
27
26
|
// We will just log and allow for the SDK to end up throwing an SDK_TIMEOUT event for devs to handle.
|
|
@@ -38,6 +37,7 @@ export function sdkFactory(params) {
|
|
|
38
37
|
splitFiltersValidation: settings.sync.__splitFiltersValidation,
|
|
39
38
|
// ATM, only used by PluggableStorage
|
|
40
39
|
mode: settings.mode,
|
|
40
|
+
impressionsMode: settings.sync.impressionsMode,
|
|
41
41
|
// Callback used to emit SDK_READY in consumer mode, where `syncManagerFactory` is undefined,
|
|
42
42
|
// or partial consumer mode, where it only has submitters, and therefore it doesn't emit readiness events.
|
|
43
43
|
onReadyCb: function (error) {
|
|
@@ -51,14 +51,23 @@ export function sdkFactory(params) {
|
|
|
51
51
|
};
|
|
52
52
|
var storage = storageFactory(storageFactoryParams);
|
|
53
53
|
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
54
|
-
var
|
|
54
|
+
var telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
55
|
+
var integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings: settings, storage: storage, telemetryTracker: telemetryTracker });
|
|
55
56
|
var observer = impressionsObserverFactory();
|
|
56
|
-
var uniqueKeysTracker = impressionsMode === NONE ? uniqueKeysTrackerFactory(log, filterAdapterFactory && filterAdapterFactory()) : undefined;
|
|
57
|
-
var strategy
|
|
58
|
-
|
|
57
|
+
var uniqueKeysTracker = storageFactoryParams.impressionsMode === NONE ? uniqueKeysTrackerFactory(log, storage.uniqueKeys, filterAdapterFactory && filterAdapterFactory()) : undefined;
|
|
58
|
+
var strategy;
|
|
59
|
+
switch (storageFactoryParams.impressionsMode) {
|
|
60
|
+
case OPTIMIZED:
|
|
61
|
+
strategy = strategyOptimizedFactory(observer, storage.impressionCounts);
|
|
62
|
+
break;
|
|
63
|
+
case NONE:
|
|
64
|
+
strategy = strategyNoneFactory(storage.impressionCounts, uniqueKeysTracker);
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
strategy = strategyDebugFactory(observer);
|
|
68
|
+
}
|
|
59
69
|
var impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, strategy, integrationsManager, storage.telemetry);
|
|
60
70
|
var eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
|
|
61
|
-
var telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
62
71
|
// splitApi is used by SyncManager and Browser signal listener
|
|
63
72
|
var splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
|
|
64
73
|
var ctx = { splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker, uniqueKeysTracker: uniqueKeysTracker, sdkReadinessManager: sdkReadinessManager, readiness: readiness, settings: settings, storage: storage, platform: platform };
|
package/esm/sdkManager/index.js
CHANGED
|
@@ -12,15 +12,7 @@ function collectTreatments(splitObject) {
|
|
|
12
12
|
// Then extract the treatments from the partitions
|
|
13
13
|
return allTreatmentsCondition ? allTreatmentsCondition.partitions.map(function (v) { return v.treatment; }) : [];
|
|
14
14
|
}
|
|
15
|
-
function objectToView(
|
|
16
|
-
var splitObject;
|
|
17
|
-
try {
|
|
18
|
-
// @ts-expect-error
|
|
19
|
-
splitObject = JSON.parse(json);
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
15
|
+
function objectToView(splitObject) {
|
|
24
16
|
if (!splitObject)
|
|
25
17
|
return null;
|
|
26
18
|
return {
|
|
@@ -32,9 +24,9 @@ function objectToView(json) {
|
|
|
32
24
|
configs: splitObject.configurations || {}
|
|
33
25
|
};
|
|
34
26
|
}
|
|
35
|
-
function objectsToViews(
|
|
27
|
+
function objectsToViews(splitObjects) {
|
|
36
28
|
var views = [];
|
|
37
|
-
|
|
29
|
+
splitObjects.forEach(function (split) {
|
|
38
30
|
var view = objectToView(split);
|
|
39
31
|
if (view)
|
|
40
32
|
views.push(view);
|
package/esm/services/splitApi.js
CHANGED
|
@@ -94,7 +94,7 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
94
94
|
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
95
95
|
*/
|
|
96
96
|
postUniqueKeysBulkCs: function (body, headers) {
|
|
97
|
-
var url = urls.telemetry + "/
|
|
97
|
+
var url = urls.telemetry + "/v1/keys/cs";
|
|
98
98
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(TELEMETRY));
|
|
99
99
|
},
|
|
100
100
|
/**
|
|
@@ -104,16 +104,16 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
104
104
|
* @param headers Optionals headers to overwrite default ones. For example, it is used in producer mode to overwrite metadata headers.
|
|
105
105
|
*/
|
|
106
106
|
postUniqueKeysBulkSs: function (body, headers) {
|
|
107
|
-
var url = urls.telemetry + "/
|
|
107
|
+
var url = urls.telemetry + "/v1/keys/ss";
|
|
108
108
|
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(TELEMETRY));
|
|
109
109
|
},
|
|
110
|
-
postMetricsConfig: function (body) {
|
|
110
|
+
postMetricsConfig: function (body, headers) {
|
|
111
111
|
var url = urls.telemetry + "/v1/metrics/config";
|
|
112
|
-
return splitHttpClient(url, { method: 'POST', body: body }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
112
|
+
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
113
113
|
},
|
|
114
|
-
postMetricsUsage: function (body) {
|
|
114
|
+
postMetricsUsage: function (body, headers) {
|
|
115
115
|
var url = urls.telemetry + "/v1/metrics/usage";
|
|
116
|
-
return splitHttpClient(url, { method: 'POST', body: body }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
116
|
+
return splitHttpClient(url, { method: 'POST', body: body, headers: headers }, telemetryTracker.trackHttp(TELEMETRY), true);
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
1
2
|
/**
|
|
2
3
|
* This class provides a skeletal implementation of the ISplitsCacheAsync interface
|
|
3
4
|
* to minimize the effort required to implement this interface.
|
|
@@ -24,22 +25,19 @@ var AbstractSplitsCacheAsync = /** @class */ (function () {
|
|
|
24
25
|
* @param {string} name
|
|
25
26
|
* @param {string} defaultTreatment
|
|
26
27
|
* @param {number} changeNumber
|
|
27
|
-
* @returns {Promise} a promise that is resolved once the split kill operation is performed. The fulfillment value is a boolean: `true` if the
|
|
28
|
+
* @returns {Promise} a promise that is resolved once the split kill operation is performed. The fulfillment value is a boolean: `true` if the operation successed updating the split or `false` if no split is updated,
|
|
28
29
|
* for instance, if the `changeNumber` is old, or if the split is not found (e.g., `/splitchanges` hasn't been fetched yet), or if the storage fails to apply the update.
|
|
29
30
|
* The promise will never be rejected.
|
|
30
31
|
*/
|
|
31
32
|
AbstractSplitsCacheAsync.prototype.killLocally = function (name, defaultTreatment, changeNumber) {
|
|
32
33
|
var _this = this;
|
|
33
34
|
return this.getSplit(name).then(function (split) {
|
|
34
|
-
if (split) {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var newSplit = JSON.stringify(parsedSplit);
|
|
41
|
-
return _this.addSplit(name, newSplit);
|
|
42
|
-
}
|
|
35
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
36
|
+
var newSplit = objectAssign({}, split);
|
|
37
|
+
newSplit.killed = true;
|
|
38
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
39
|
+
newSplit.changeNumber = changeNumber;
|
|
40
|
+
return _this.addSplit(name, newSplit);
|
|
43
41
|
}
|
|
44
42
|
return false;
|
|
45
43
|
}).catch(function () { return false; });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { objectAssign } from '../utils/lang/objectAssign';
|
|
1
2
|
/**
|
|
2
3
|
* This class provides a skeletal implementation of the ISplitsCacheSync interface
|
|
3
4
|
* to minimize the effort required to implement this interface.
|
|
@@ -39,20 +40,17 @@ var AbstractSplitsCacheSync = /** @class */ (function () {
|
|
|
39
40
|
* @param {string} name
|
|
40
41
|
* @param {string} defaultTreatment
|
|
41
42
|
* @param {number} changeNumber
|
|
42
|
-
* @returns {
|
|
43
|
+
* @returns {boolean} `true` if the operation successed updating the split, or `false` if no split is updated,
|
|
43
44
|
* for instance, if the `changeNumber` is old, or if the split is not found (e.g., `/splitchanges` hasn't been fetched yet), or if the storage fails to apply the update.
|
|
44
45
|
*/
|
|
45
46
|
AbstractSplitsCacheSync.prototype.killLocally = function (name, defaultTreatment, changeNumber) {
|
|
46
47
|
var split = this.getSplit(name);
|
|
47
|
-
if (split) {
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var newSplit = JSON.stringify(parsedSplit);
|
|
54
|
-
return this.addSplit(name, newSplit);
|
|
55
|
-
}
|
|
48
|
+
if (split && (!split.changeNumber || split.changeNumber < changeNumber)) {
|
|
49
|
+
var newSplit = objectAssign({}, split);
|
|
50
|
+
newSplit.killed = true;
|
|
51
|
+
newSplit.defaultTreatment = defaultTreatment;
|
|
52
|
+
newSplit.changeNumber = changeNumber;
|
|
53
|
+
return this.addSplit(name, newSplit);
|
|
56
54
|
}
|
|
57
55
|
return false;
|
|
58
56
|
};
|