@splitsoftware/splitio-commons 1.17.1-rc.2 → 2.0.0-rc.0
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 +7 -3
- package/cjs/evaluator/index.js +2 -2
- package/cjs/evaluator/matchers/semver_inlist.js +1 -2
- package/cjs/evaluator/matchers/whitelist.js +1 -2
- package/cjs/listeners/browser.js +1 -2
- package/cjs/logger/browser/DebugLogger.js +1 -2
- package/cjs/logger/browser/ErrorLogger.js +1 -2
- package/cjs/logger/browser/InfoLogger.js +1 -2
- package/cjs/logger/browser/WarnLogger.js +1 -2
- package/cjs/logger/index.js +1 -2
- package/cjs/sdkClient/clientCS.js +5 -8
- package/cjs/sdkClient/sdkClientMethodCS.js +1 -1
- package/cjs/sdkFactory/index.js +1 -3
- package/cjs/services/decorateHeaders.js +1 -2
- package/cjs/storages/AbstractSplitsCacheAsync.js +7 -0
- package/cjs/storages/AbstractSplitsCacheSync.js +7 -0
- package/cjs/storages/KeyBuilderCS.js +0 -9
- package/cjs/storages/dataLoader.js +32 -65
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/cjs/storages/inLocalStorage/index.js +1 -4
- package/cjs/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +3 -4
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
- package/cjs/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
- package/cjs/storages/inRedis/RedisAdapter.js +2 -3
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
- package/cjs/storages/pluggable/SplitsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
- package/cjs/storages/pluggable/inMemoryWrapper.js +7 -8
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +7 -2
- package/cjs/sync/polling/pollingManagerSS.js +3 -3
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +13 -5
- package/cjs/sync/streaming/parseUtils.js +0 -1
- package/cjs/sync/streaming/pushManager.js +2 -3
- package/cjs/utils/LRUCache/index.js +1 -2
- package/cjs/utils/constants/browser.js +1 -4
- package/cjs/utils/lang/index.js +6 -9
- package/cjs/utils/lang/objectAssign.js +12 -77
- package/cjs/utils/lang/sets.js +3 -110
- package/cjs/utils/settingsValidation/index.js +0 -9
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/cjs/utils/settingsValidation/storage/storageCS.js +12 -1
- package/esm/evaluator/index.js +3 -3
- package/esm/evaluator/matchers/semver_inlist.js +1 -2
- package/esm/evaluator/matchers/whitelist.js +1 -2
- package/esm/listeners/browser.js +1 -2
- package/esm/logger/browser/DebugLogger.js +1 -2
- package/esm/logger/browser/ErrorLogger.js +1 -2
- package/esm/logger/browser/InfoLogger.js +1 -2
- package/esm/logger/browser/WarnLogger.js +1 -2
- package/esm/logger/index.js +1 -2
- package/esm/sdkClient/clientCS.js +5 -8
- package/esm/sdkClient/sdkClientMethodCS.js +1 -1
- package/esm/sdkFactory/index.js +2 -4
- package/esm/services/decorateHeaders.js +1 -2
- package/esm/storages/AbstractSplitsCacheAsync.js +7 -0
- package/esm/storages/AbstractSplitsCacheSync.js +7 -0
- package/esm/storages/KeyBuilderCS.js +0 -9
- package/esm/storages/dataLoader.js +30 -62
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/esm/storages/inLocalStorage/index.js +2 -5
- package/esm/storages/inMemory/InMemoryStorageCS.js +4 -16
- package/esm/storages/inMemory/SegmentsCacheInMemory.js +3 -4
- package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -3
- package/esm/storages/inMemory/UniqueKeysCacheInMemory.js +2 -3
- package/esm/storages/inMemory/UniqueKeysCacheInMemoryCS.js +2 -3
- package/esm/storages/inRedis/RedisAdapter.js +2 -3
- package/esm/storages/inRedis/SplitsCacheInRedis.js +2 -2
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +3 -4
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -2
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +6 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -2
- package/esm/storages/pluggable/inMemoryWrapper.js +7 -8
- package/esm/sync/offline/syncTasks/fromObjectSyncTask.js +8 -3
- package/esm/sync/polling/pollingManagerSS.js +3 -3
- package/esm/sync/polling/updaters/splitChangesUpdater.js +14 -6
- package/esm/sync/streaming/parseUtils.js +0 -1
- package/esm/sync/streaming/pushManager.js +2 -3
- package/esm/utils/LRUCache/index.js +1 -2
- package/esm/utils/constants/browser.js +0 -3
- package/esm/utils/lang/index.js +6 -9
- package/esm/utils/lang/objectAssign.js +12 -77
- package/esm/utils/lang/sets.js +2 -107
- package/esm/utils/settingsValidation/index.js +0 -9
- package/esm/utils/settingsValidation/logger/builtinLogger.js +1 -2
- package/esm/utils/settingsValidation/storage/storageCS.js +10 -0
- package/package.json +2 -2
- package/src/evaluator/index.ts +5 -5
- package/src/evaluator/matchers/semver_inlist.ts +1 -2
- package/src/evaluator/matchers/whitelist.ts +1 -3
- package/src/listeners/browser.ts +1 -2
- package/src/logger/browser/DebugLogger.ts +1 -2
- package/src/logger/browser/ErrorLogger.ts +1 -2
- package/src/logger/browser/InfoLogger.ts +1 -2
- package/src/logger/browser/WarnLogger.ts +1 -2
- package/src/logger/index.ts +3 -4
- package/src/sdkClient/clientCS.ts +5 -8
- package/src/sdkClient/sdkClientMethodCS.ts +1 -1
- package/src/sdkFactory/index.ts +2 -5
- package/src/sdkFactory/types.ts +1 -1
- package/src/services/decorateHeaders.ts +1 -2
- package/src/storages/AbstractSplitsCacheAsync.ts +9 -2
- package/src/storages/AbstractSplitsCacheSync.ts +9 -2
- package/src/storages/KeyBuilderCS.ts +0 -13
- package/src/storages/dataLoader.ts +32 -63
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -21
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +16 -8
- package/src/storages/inLocalStorage/index.ts +2 -6
- package/src/storages/inMemory/InMemoryStorageCS.ts +4 -19
- package/src/storages/inMemory/SegmentsCacheInMemory.ts +4 -5
- package/src/storages/inMemory/SplitsCacheInMemory.ts +4 -5
- package/src/storages/inMemory/UniqueKeysCacheInMemory.ts +4 -5
- package/src/storages/inMemory/UniqueKeysCacheInMemoryCS.ts +4 -5
- package/src/storages/inRedis/RedisAdapter.ts +3 -4
- package/src/storages/inRedis/SplitsCacheInRedis.ts +3 -3
- package/src/storages/inRedis/TelemetryCacheInRedis.ts +3 -4
- package/src/storages/inRedis/UniqueKeysCacheInRedis.ts +1 -2
- package/src/storages/pluggable/SegmentsCachePluggable.ts +0 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +3 -3
- package/src/storages/pluggable/TelemetryCachePluggable.ts +6 -7
- package/src/storages/pluggable/UniqueKeysCachePluggable.ts +1 -2
- package/src/storages/pluggable/inMemoryWrapper.ts +8 -9
- package/src/storages/types.ts +9 -5
- package/src/sync/offline/syncTasks/fromObjectSyncTask.ts +7 -3
- package/src/sync/polling/pollingManagerSS.ts +2 -3
- package/src/sync/polling/updaters/splitChangesUpdater.ts +15 -8
- package/src/sync/streaming/parseUtils.ts +0 -1
- package/src/sync/streaming/pushManager.ts +3 -4
- package/src/sync/submitters/types.ts +3 -4
- package/src/types.ts +9 -18
- package/src/utils/LRUCache/index.ts +2 -3
- package/src/utils/constants/browser.ts +0 -4
- package/src/utils/lang/index.ts +6 -7
- package/src/utils/lang/objectAssign.ts +13 -92
- package/src/utils/lang/sets.ts +3 -125
- package/src/utils/settingsValidation/index.ts +0 -10
- package/src/utils/settingsValidation/logger/builtinLogger.ts +1 -2
- package/src/utils/settingsValidation/storage/storageCS.ts +13 -0
- package/src/utils/settingsValidation/types.ts +0 -2
- package/types/logger/index.d.ts +1 -2
- package/types/sdkClient/clientCS.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +1 -1
- package/types/storages/AbstractSplitsCacheAsync.d.ts +6 -2
- package/types/storages/AbstractSplitsCacheSync.d.ts +6 -2
- package/types/storages/KeyBuilderCS.d.ts +0 -2
- package/types/storages/dataLoader.d.ts +6 -17
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +7 -2
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -2
- package/types/storages/inMemory/UniqueKeysCacheInMemory.d.ts +2 -3
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +1 -2
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +1 -2
- package/types/storages/pluggable/inMemoryWrapper.d.ts +1 -2
- package/types/storages/types.d.ts +7 -5
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -2
- package/types/sync/submitters/types.d.ts +3 -4
- package/types/types.d.ts +9 -17
- package/types/utils/LRUCache/index.d.ts +1 -2
- package/types/utils/constants/browser.d.ts +0 -2
- package/types/utils/lang/objectAssign.d.ts +3 -0
- package/types/utils/lang/sets.d.ts +1 -61
- package/types/utils/settingsValidation/index.d.ts +0 -1
- package/types/utils/settingsValidation/storage/storageCS.d.ts +5 -0
- package/types/utils/settingsValidation/types.d.ts +0 -2
- package/cjs/integrations/browser.js +0 -31
- package/cjs/integrations/ga/GaToSplit.js +0 -257
- package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +0 -14
- package/cjs/integrations/ga/SplitToGa.js +0 -123
- package/cjs/integrations/ga/SplitToGoogleAnalytics.js +0 -14
- package/cjs/integrations/ga/types.js +0 -2
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +0 -76
- package/cjs/utils/lang/maps.js +0 -96
- package/esm/integrations/browser.js +0 -27
- package/esm/integrations/ga/GaToSplit.js +0 -250
- package/esm/integrations/ga/GoogleAnalyticsToSplit.js +0 -10
- package/esm/integrations/ga/SplitToGa.js +0 -120
- package/esm/integrations/ga/SplitToGoogleAnalytics.js +0 -10
- package/esm/integrations/ga/types.js +0 -1
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +0 -72
- package/esm/utils/lang/maps.js +0 -92
- package/src/integrations/browser.ts +0 -35
- package/src/integrations/ga/GaToSplit.ts +0 -299
- package/src/integrations/ga/GoogleAnalyticsToSplit.ts +0 -14
- package/src/integrations/ga/SplitToGa.ts +0 -135
- package/src/integrations/ga/SplitToGoogleAnalytics.ts +0 -14
- package/src/integrations/ga/autoRequire.js +0 -33
- package/src/integrations/ga/types.ts +0 -153
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +0 -98
- package/src/utils/lang/maps.ts +0 -108
package/cjs/utils/lang/sets.js
CHANGED
|
@@ -1,120 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Set implementation based on es6-set polyfill (https://github.com/medikoo/es6-set/blob/master/polyfill.js),
|
|
4
|
-
* with the minimal features used by the SDK.
|
|
5
|
-
|
|
6
|
-
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
|
|
7
|
-
|
|
8
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
-
in the Software without restriction, including without limitation the rights
|
|
11
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
-
furnished to do so, subject to the following conditions:
|
|
14
|
-
|
|
15
|
-
The above copyright notice and this permission notice shall be included in
|
|
16
|
-
all copies or substantial portions of the Software.
|
|
17
|
-
|
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
-
THE SOFTWARE.
|
|
25
|
-
**/
|
|
26
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.returnDifference = exports.returnSetsUnion =
|
|
28
|
-
var SetPoly = /** @class */ (function () {
|
|
29
|
-
// unlike ES6 `Set`, it only accepts an array as first argument iterable
|
|
30
|
-
function SetPoly(values) {
|
|
31
|
-
var _this = this;
|
|
32
|
-
this.__setData__ = [];
|
|
33
|
-
if (Array.isArray(values))
|
|
34
|
-
values.forEach(function (value) { _this.add(value); });
|
|
35
|
-
}
|
|
36
|
-
SetPoly.prototype.clear = function () {
|
|
37
|
-
if (!this.__setData__.length)
|
|
38
|
-
return;
|
|
39
|
-
this.__setData__.length = 0;
|
|
40
|
-
};
|
|
41
|
-
SetPoly.prototype.add = function (value) {
|
|
42
|
-
if (this.has(value))
|
|
43
|
-
return this;
|
|
44
|
-
this.__setData__.push(value);
|
|
45
|
-
return this;
|
|
46
|
-
};
|
|
47
|
-
SetPoly.prototype.delete = function (value) {
|
|
48
|
-
var index = this.__setData__.indexOf(value);
|
|
49
|
-
if (index === -1)
|
|
50
|
-
return false;
|
|
51
|
-
this.__setData__.splice(index, 1);
|
|
52
|
-
return true;
|
|
53
|
-
};
|
|
54
|
-
SetPoly.prototype.has = function (value) {
|
|
55
|
-
return this.__setData__.indexOf(value) !== -1;
|
|
56
|
-
};
|
|
57
|
-
SetPoly.prototype.forEach = function (callbackfn, thisArg) {
|
|
58
|
-
if (typeof callbackfn !== 'function')
|
|
59
|
-
throw new TypeError(callbackfn + ' is not a function');
|
|
60
|
-
for (var i = 0; i < this.__setData__.length; i++) {
|
|
61
|
-
var value = this.__setData__[i];
|
|
62
|
-
callbackfn.call(thisArg, value, value, this);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
Object.defineProperty(SetPoly.prototype, "size", {
|
|
66
|
-
get: function () {
|
|
67
|
-
return this.__setData__.length;
|
|
68
|
-
},
|
|
69
|
-
enumerable: false,
|
|
70
|
-
configurable: true
|
|
71
|
-
});
|
|
72
|
-
return SetPoly;
|
|
73
|
-
}());
|
|
74
|
-
exports.SetPoly = SetPoly;
|
|
75
|
-
/**
|
|
76
|
-
* return an array containing the items of the given set.
|
|
77
|
-
* @param set Set or SetPoly instance
|
|
78
|
-
*/
|
|
79
|
-
function setToArray(set) {
|
|
80
|
-
if (set instanceof SetPoly) {
|
|
81
|
-
return set.__setData__.slice();
|
|
82
|
-
}
|
|
83
|
-
// if not using SetPoly as set, it means Array.from is supported
|
|
84
|
-
// eslint-disable-next-line compat/compat
|
|
85
|
-
return Array.from(set);
|
|
86
|
-
}
|
|
87
|
-
exports.setToArray = setToArray;
|
|
88
|
-
/**
|
|
89
|
-
* return the Set constructor to use. If `Array.from` built-in or native Set is not available or it doesn't support the required features,
|
|
90
|
-
* a ponyfill with minimal features is returned instead.
|
|
91
|
-
*
|
|
92
|
-
* Exported for testing purposes only.
|
|
93
|
-
*/
|
|
94
|
-
function __getSetConstructor() {
|
|
95
|
-
// eslint-disable-next-line compat/compat
|
|
96
|
-
if (typeof Array.from === 'function' && typeof Set === 'function' && Set.prototype && Set.prototype.values) {
|
|
97
|
-
return Set;
|
|
98
|
-
}
|
|
99
|
-
return SetPoly;
|
|
100
|
-
}
|
|
101
|
-
exports.__getSetConstructor = __getSetConstructor;
|
|
102
|
-
exports._Set = __getSetConstructor();
|
|
3
|
+
exports.returnDifference = exports.returnSetsUnion = void 0;
|
|
103
4
|
function returnSetsUnion(set, set2) {
|
|
104
|
-
|
|
105
|
-
set2.forEach(function (value) {
|
|
106
|
-
result.add(value);
|
|
107
|
-
});
|
|
108
|
-
return result;
|
|
5
|
+
return new Set(Array.from(set).concat(Array.from(set2)));
|
|
109
6
|
}
|
|
110
7
|
exports.returnSetsUnion = returnSetsUnion;
|
|
111
8
|
function returnDifference(list, list2) {
|
|
112
9
|
if (list === void 0) { list = []; }
|
|
113
10
|
if (list2 === void 0) { list2 = []; }
|
|
114
|
-
|
|
115
|
-
list2.forEach(function (item) {
|
|
116
|
-
result.delete(item);
|
|
117
|
-
});
|
|
118
|
-
return setToArray(result);
|
|
11
|
+
return list.filter(function (item) { return list2.indexOf(item) === -1; });
|
|
119
12
|
}
|
|
120
13
|
exports.returnDifference = returnDifference;
|
|
@@ -7,7 +7,6 @@ var splitFilters_1 = require("./splitFilters");
|
|
|
7
7
|
var constants_1 = require("../constants");
|
|
8
8
|
var impressionsMode_1 = require("./impressionsMode");
|
|
9
9
|
var key_1 = require("../inputValidation/key");
|
|
10
|
-
var trafficType_1 = require("../inputValidation/trafficType");
|
|
11
10
|
var constants_2 = require("../../logger/constants");
|
|
12
11
|
// Exported for telemetry
|
|
13
12
|
exports.base = {
|
|
@@ -18,8 +17,6 @@ exports.base = {
|
|
|
18
17
|
authorizationKey: undefined,
|
|
19
18
|
// key used in your system (only required for browser version)
|
|
20
19
|
key: undefined,
|
|
21
|
-
// traffic type for the given key (only used on browser version)
|
|
22
|
-
trafficType: undefined,
|
|
23
20
|
// toggle impressions tracking of labels
|
|
24
21
|
labelsEnabled: true,
|
|
25
22
|
// toggle sendind (true) or not sending (false) IP and Host Name with impressions, events, and telemetries requests (only used on nodejs version)
|
|
@@ -148,12 +145,6 @@ function settingsValidation(config, validationParams) {
|
|
|
148
145
|
// @ts-ignore, @TODO handle invalid keys as a non-recoverable error?
|
|
149
146
|
withDefaults.core.key = (0, key_1.validateKey)(log, maybeKey, constants_2.LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
150
147
|
}
|
|
151
|
-
if (validationParams.acceptTT) {
|
|
152
|
-
var maybeTT = withDefaults.core.trafficType;
|
|
153
|
-
if (maybeTT !== undefined) { // @ts-ignore
|
|
154
|
-
withDefaults.core.trafficType = (0, trafficType_1.validateTrafficType)(log, maybeTT, constants_2.LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
148
|
}
|
|
158
149
|
else {
|
|
159
150
|
// On server-side, key is undefined and used to distinguish from client-side
|
|
@@ -5,9 +5,8 @@ var logger_1 = require("../../../logger");
|
|
|
5
5
|
var isLocalStorageAvailable_1 = require("../../env/isLocalStorageAvailable");
|
|
6
6
|
var isNode_1 = require("../../env/isNode");
|
|
7
7
|
var debug_1 = require("../../../logger/messages/debug");
|
|
8
|
-
var maps_1 = require("../../lang/maps");
|
|
9
8
|
var commons_1 = require("./commons");
|
|
10
|
-
var allCodes = new
|
|
9
|
+
var allCodes = new Map(debug_1.codesDebug);
|
|
11
10
|
// @TODO set default debug setting instead of initialLogLevel when integrating in JS and Node packages
|
|
12
11
|
var LS_KEY = 'splitio_debug';
|
|
13
12
|
var ENV_VAR_KEY = 'SPLITIO_DEBUG';
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateStorageCS = void 0;
|
|
3
|
+
exports.validateStorageCS = exports.__InLocalStorageMockFactory = void 0;
|
|
4
4
|
var InMemoryStorageCS_1 = require("../../../storages/inMemory/InMemoryStorageCS");
|
|
5
5
|
var constants_1 = require("../../../logger/constants");
|
|
6
6
|
var constants_2 = require("../../../utils/constants");
|
|
7
|
+
function __InLocalStorageMockFactory(params) {
|
|
8
|
+
var result = (0, InMemoryStorageCS_1.InMemoryStorageCSFactory)(params);
|
|
9
|
+
result.splits.checkCache = function () { return true; }; // to emit SDK_READY_FROM_CACHE
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
exports.__InLocalStorageMockFactory = __InLocalStorageMockFactory;
|
|
13
|
+
__InLocalStorageMockFactory.type = constants_2.STORAGE_MEMORY;
|
|
7
14
|
/**
|
|
8
15
|
* This function validates `settings.storage` object
|
|
9
16
|
*
|
|
@@ -20,6 +27,10 @@ function validateStorageCS(settings) {
|
|
|
20
27
|
storage = InMemoryStorageCS_1.InMemoryStorageCSFactory;
|
|
21
28
|
log.error(constants_1.ERROR_STORAGE_INVALID);
|
|
22
29
|
}
|
|
30
|
+
// In localhost mode with InLocalStorage, fallback to a mock InLocalStorage to emit SDK_READY_FROM_CACHE
|
|
31
|
+
if (mode === constants_2.LOCALHOST_MODE && storage.type === constants_2.STORAGE_LOCALSTORAGE) {
|
|
32
|
+
return __InLocalStorageMockFactory;
|
|
33
|
+
}
|
|
23
34
|
if ([constants_2.LOCALHOST_MODE, constants_2.STANDALONE_MODE].indexOf(mode) === -1) {
|
|
24
35
|
// Consumer modes require an async storage
|
|
25
36
|
if (storage.type !== constants_2.STORAGE_PLUGGABLE)
|
package/esm/evaluator/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Engine } from './Engine';
|
|
|
2
2
|
import { thenable } from '../utils/promise/thenable';
|
|
3
3
|
import { EXCEPTION, SPLIT_NOT_FOUND } from '../utils/labels';
|
|
4
4
|
import { CONTROL } from '../utils/constants';
|
|
5
|
-
import {
|
|
5
|
+
import { returnSetsUnion } from '../utils/lang/sets';
|
|
6
6
|
import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
|
|
7
7
|
var treatmentException = {
|
|
8
8
|
treatment: CONTROL,
|
|
@@ -54,7 +54,7 @@ export function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
|
54
54
|
export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage, method) {
|
|
55
55
|
var storedFlagNames;
|
|
56
56
|
function evaluate(featureFlagsByFlagSets) {
|
|
57
|
-
var featureFlags = new
|
|
57
|
+
var featureFlags = new Set();
|
|
58
58
|
for (var i = 0; i < flagSets.length; i++) {
|
|
59
59
|
var featureFlagByFlagSet = featureFlagsByFlagSets[i];
|
|
60
60
|
if (featureFlagByFlagSet.size) {
|
|
@@ -65,7 +65,7 @@ export function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, stora
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
return featureFlags.size ?
|
|
68
|
-
evaluateFeatures(log, key,
|
|
68
|
+
evaluateFeatures(log, key, Array.from(featureFlags), attributes, storage) :
|
|
69
69
|
{};
|
|
70
70
|
}
|
|
71
71
|
// get features by flag sets
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { _Set } from '../../utils/lang/sets';
|
|
2
1
|
import { Semver } from '../../utils/Semver';
|
|
3
2
|
export function inListSemverMatcherContext(ruleAttr) {
|
|
4
3
|
// @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
|
|
5
4
|
if (!ruleAttr || ruleAttr.length === 0)
|
|
6
5
|
throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
|
|
7
|
-
var listOfSemvers = new
|
|
6
|
+
var listOfSemvers = new Set(ruleAttr.map(function (version) { return new Semver(version).version; }));
|
|
8
7
|
return function inListSemverMatcher(runtimeAttr) {
|
|
9
8
|
var runtimeSemver = new Semver(runtimeAttr).version;
|
|
10
9
|
var isInList = listOfSemvers.has(runtimeSemver);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { _Set } from '../../utils/lang/sets';
|
|
2
1
|
export function whitelistMatcherContext(ruleAttr) {
|
|
3
|
-
var whitelistSet = new
|
|
2
|
+
var whitelistSet = new Set(ruleAttr);
|
|
4
3
|
return function whitelistMatcher(runtimeAttr) {
|
|
5
4
|
var isInWhitelist = whitelistSet.has(runtimeAttr);
|
|
6
5
|
return isInWhitelist;
|
package/esm/listeners/browser.js
CHANGED
|
@@ -97,7 +97,6 @@ var BrowserSignalListener = /** @class */ (function () {
|
|
|
97
97
|
* Returns true if beacon API was used successfully, false otherwise.
|
|
98
98
|
*/
|
|
99
99
|
BrowserSignalListener.prototype._sendBeacon = function (url, data, extraMetadata) {
|
|
100
|
-
// eslint-disable-next-line compat/compat
|
|
101
100
|
if (typeof navigator !== 'undefined' && navigator.sendBeacon) {
|
|
102
101
|
var json = {
|
|
103
102
|
entries: data,
|
|
@@ -110,7 +109,7 @@ var BrowserSignalListener = /** @class */ (function () {
|
|
|
110
109
|
// Stringify the payload
|
|
111
110
|
var payload = JSON.stringify(json);
|
|
112
111
|
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
113
|
-
try {
|
|
112
|
+
try {
|
|
114
113
|
return navigator.sendBeacon(url, payload);
|
|
115
114
|
}
|
|
116
115
|
catch (e) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesDebug } from '../messages/debug';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
export function DebugLogger() {
|
|
5
|
-
return new Logger({ logLevel: 'DEBUG' }, new
|
|
4
|
+
return new Logger({ logLevel: 'DEBUG' }, new Map(codesDebug));
|
|
6
5
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesError } from '../messages/error';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
export function ErrorLogger() {
|
|
5
|
-
return new Logger({ logLevel: 'ERROR' }, new
|
|
4
|
+
return new Logger({ logLevel: 'ERROR' }, new Map(codesError));
|
|
6
5
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesInfo } from '../messages/info';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
export function InfoLogger() {
|
|
5
|
-
return new Logger({ logLevel: 'INFO' }, new
|
|
4
|
+
return new Logger({ logLevel: 'INFO' }, new Map(codesInfo));
|
|
6
5
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesWarn } from '../messages/warn';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
export function WarnLogger() {
|
|
5
|
-
return new Logger({ logLevel: 'WARN' }, new
|
|
4
|
+
return new Logger({ logLevel: 'WARN' }, new Map(codesWarn));
|
|
6
5
|
}
|
package/esm/logger/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
2
|
import { find, isObject } from '../utils/lang';
|
|
3
|
-
import { _Map } from '../utils/lang/maps';
|
|
4
3
|
export var LogLevels = {
|
|
5
4
|
DEBUG: 'DEBUG',
|
|
6
5
|
INFO: 'INFO',
|
|
@@ -42,7 +41,7 @@ var defaultOptions = {
|
|
|
42
41
|
var Logger = /** @class */ (function () {
|
|
43
42
|
function Logger(options, codes) {
|
|
44
43
|
this.options = objectAssign({}, defaultOptions, options);
|
|
45
|
-
this.codes = codes || new
|
|
44
|
+
this.codes = codes || new Map();
|
|
46
45
|
this.logLevel = LogLevelIndexes[this.options.logLevel];
|
|
47
46
|
}
|
|
48
47
|
Logger.prototype.setLogLevel = function (logLevel) {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
2
2
|
import { clientAttributesDecoration } from './clientAttributesDecoration';
|
|
3
3
|
/**
|
|
4
|
-
* Decorator that binds a key
|
|
4
|
+
* Decorator that binds a key to client methods
|
|
5
5
|
*
|
|
6
6
|
* @param client sync client instance
|
|
7
7
|
* @param key validated split key
|
|
8
|
-
* @param trafficType validated traffic type
|
|
9
8
|
*/
|
|
10
|
-
export function clientCSDecorator(log, client, key
|
|
9
|
+
export function clientCSDecorator(log, client, key) {
|
|
11
10
|
var clientCS = clientAttributesDecoration(log, client);
|
|
12
11
|
return objectAssign(clientCS, {
|
|
13
|
-
// In the client-side API, we bind a key to the client `getTreatment*` methods
|
|
12
|
+
// In the client-side API, we bind a key to the client `getTreatment*` and `track` methods
|
|
14
13
|
getTreatment: clientCS.getTreatment.bind(clientCS, key),
|
|
15
14
|
getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key),
|
|
16
15
|
getTreatments: clientCS.getTreatments.bind(clientCS, key),
|
|
@@ -19,11 +18,9 @@ export function clientCSDecorator(log, client, key, trafficType) {
|
|
|
19
18
|
getTreatmentsWithConfigByFlagSets: clientCS.getTreatmentsWithConfigByFlagSets.bind(clientCS, key),
|
|
20
19
|
getTreatmentsByFlagSet: clientCS.getTreatmentsByFlagSet.bind(clientCS, key),
|
|
21
20
|
getTreatmentsWithConfigByFlagSet: clientCS.getTreatmentsWithConfigByFlagSet.bind(clientCS, key),
|
|
22
|
-
|
|
23
|
-
track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
|
|
21
|
+
track: clientCS.track.bind(clientCS, key),
|
|
24
22
|
// Not part of the public API. These properties are used to support other modules (e.g., Split Suite)
|
|
25
23
|
isClientSide: true,
|
|
26
|
-
key: key
|
|
27
|
-
trafficType: trafficType
|
|
24
|
+
key: key
|
|
28
25
|
});
|
|
29
26
|
}
|
|
@@ -22,7 +22,7 @@ export function sdkClientMethodCSFactory(params) {
|
|
|
22
22
|
log.debug(RETRIEVE_CLIENT_DEFAULT);
|
|
23
23
|
return mainClientInstance;
|
|
24
24
|
}
|
|
25
|
-
// Validate the key value
|
|
25
|
+
// Validate the key value
|
|
26
26
|
var validKey = validateKey(log, key, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
27
27
|
if (validKey === false) {
|
|
28
28
|
throw new Error('Shared Client needs a valid key.');
|
package/esm/sdkFactory/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { telemetryTrackerFactory } from '../trackers/telemetryTracker';
|
|
|
5
5
|
import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
|
|
6
6
|
import { createLoggerAPI } from '../logger/sdkLogger';
|
|
7
7
|
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
8
|
-
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED
|
|
8
|
+
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
9
9
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
10
10
|
import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
|
|
11
11
|
import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
|
|
@@ -35,10 +35,8 @@ export function sdkFactory(params) {
|
|
|
35
35
|
readiness.splits.emit(SDK_SPLITS_ARRIVED);
|
|
36
36
|
readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
37
37
|
},
|
|
38
|
-
onReadyFromCacheCb: function () {
|
|
39
|
-
readiness.splits.emit(SDK_SPLITS_CACHE_LOADED);
|
|
40
|
-
}
|
|
41
38
|
});
|
|
39
|
+
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
42
40
|
var clients = {};
|
|
43
41
|
var telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
44
42
|
var integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings: settings, storage: storage, telemetryTracker: telemetryTracker });
|
|
@@ -11,6 +11,13 @@ var AbstractSplitsCacheAsync = /** @class */ (function () {
|
|
|
11
11
|
AbstractSplitsCacheAsync.prototype.usesSegments = function () {
|
|
12
12
|
return Promise.resolve(true);
|
|
13
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Check if the splits information is already stored in cache.
|
|
16
|
+
* Noop, just keeping the interface. This is used by client-side implementations only.
|
|
17
|
+
*/
|
|
18
|
+
AbstractSplitsCacheAsync.prototype.checkCache = function () {
|
|
19
|
+
return Promise.resolve(false);
|
|
20
|
+
};
|
|
14
21
|
/**
|
|
15
22
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
16
23
|
* Used for SPLIT_KILL push notifications.
|
|
@@ -27,6 +27,13 @@ var AbstractSplitsCacheSync = /** @class */ (function () {
|
|
|
27
27
|
var _this = this;
|
|
28
28
|
return this.getSplitNames().map(function (key) { return _this.getSplit(key); });
|
|
29
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Check if the splits information is already stored in cache. This data can be preloaded.
|
|
32
|
+
* It is used as condition to emit SDK_SPLITS_CACHE_LOADED, and then SDK_READY_FROM_CACHE.
|
|
33
|
+
*/
|
|
34
|
+
AbstractSplitsCacheSync.prototype.checkCache = function () {
|
|
35
|
+
return false;
|
|
36
|
+
};
|
|
30
37
|
/**
|
|
31
38
|
* Kill `name` split and set `defaultTreatment` and `changeNumber`.
|
|
32
39
|
* Used for SPLIT_KILL push notifications.
|
|
@@ -20,12 +20,6 @@ var KeyBuilderCS = /** @class */ (function (_super) {
|
|
|
20
20
|
if (startsWith(builtSegmentKeyName, prefix))
|
|
21
21
|
return builtSegmentKeyName.substr(prefix.length);
|
|
22
22
|
};
|
|
23
|
-
// @BREAKING: The key used to start with the matching key instead of the prefix, this was changed on version 10.17.3
|
|
24
|
-
KeyBuilderCS.prototype.extractOldSegmentKey = function (builtSegmentKeyName) {
|
|
25
|
-
var prefix = this.matchingKey + "." + this.prefix + ".segment.";
|
|
26
|
-
if (startsWith(builtSegmentKeyName, prefix))
|
|
27
|
-
return builtSegmentKeyName.substr(prefix.length);
|
|
28
|
-
};
|
|
29
23
|
KeyBuilderCS.prototype.buildLastUpdatedKey = function () {
|
|
30
24
|
return this.prefix + ".splits.lastUpdated";
|
|
31
25
|
};
|
|
@@ -48,9 +42,6 @@ export function myLargeSegmentsKeyBuilder(prefix, matchingKey) {
|
|
|
48
42
|
if (startsWith(builtSegmentKeyName, p))
|
|
49
43
|
return builtSegmentKeyName.substr(p.length);
|
|
50
44
|
},
|
|
51
|
-
extractOldSegmentKey: function () {
|
|
52
|
-
return undefined;
|
|
53
|
-
},
|
|
54
45
|
buildTillKey: function () {
|
|
55
46
|
return prefix + "." + matchingKey + ".largeSegments.till";
|
|
56
47
|
}
|
|
@@ -1,79 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_CACHE_EXPIRATION_IN_MILLIS } from '../utils/constants/browser';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
|
|
3
|
+
* Factory of client-side storage loader
|
|
5
4
|
*
|
|
6
|
-
* @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
* @TODO extend to load largeSegments
|
|
11
|
-
* @TODO extend to load data on shared mySegments storages. Be specific when emitting SDK_READY_FROM_CACHE on shared clients. Maybe the serializer should provide the `useSegments` flag.
|
|
12
|
-
* @TODO add logs, and input validation in this module, in favor of size reduction.
|
|
13
|
-
* @TODO unit tests
|
|
5
|
+
* @param preloadedData validated data following the format proposed in https://github.com/godaddy/split-javascript-data-loader
|
|
6
|
+
* and extended with a `mySegmentsData` property.
|
|
7
|
+
* @returns function to preload the storage
|
|
14
8
|
*/
|
|
15
|
-
export function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
export function dataLoaderFactory(preloadedData) {
|
|
10
|
+
/**
|
|
11
|
+
* Storage-agnostic adaptation of `loadDataIntoLocalStorage` function
|
|
12
|
+
* (https://github.com/godaddy/split-javascript-data-loader/blob/master/src/load-data.js)
|
|
13
|
+
*
|
|
14
|
+
* @param storage object containing `splits` and `segments` cache (client-side variant)
|
|
15
|
+
* @param userId user key string of the provided MySegmentsCache
|
|
16
|
+
*
|
|
17
|
+
* @TODO extend to support SegmentsCache (server-side variant) by making `userId` optional and adding the corresponding logic.
|
|
18
|
+
* @TODO extend to load data on shared mySegments storages. Be specific when emitting SDK_READY_FROM_CACHE on shared clients. Maybe the serializer should provide the `useSegments` flag.
|
|
19
|
+
*/
|
|
20
|
+
return function loadData(storage, userId) {
|
|
21
|
+
// Do not load data if current preloadedData is empty
|
|
22
|
+
if (Object.keys(preloadedData).length === 0)
|
|
23
|
+
return;
|
|
24
|
+
var _a = preloadedData.lastUpdated, lastUpdated = _a === void 0 ? -1 : _a, _b = preloadedData.segmentsData, segmentsData = _b === void 0 ? {} : _b, _c = preloadedData.since, since = _c === void 0 ? -1 : _c, _d = preloadedData.splitsData, splitsData = _d === void 0 ? {} : _d;
|
|
21
25
|
var storedSince = storage.splits.getChangeNumber();
|
|
22
|
-
|
|
23
|
-
if
|
|
26
|
+
var expirationTimestamp = Date.now() - DEFAULT_CACHE_EXPIRATION_IN_MILLIS;
|
|
27
|
+
// Do not load data if current localStorage data is more recent,
|
|
28
|
+
// or if its `lastUpdated` timestamp is older than the given `expirationTimestamp`,
|
|
29
|
+
if (storedSince > since || lastUpdated < expirationTimestamp)
|
|
24
30
|
return;
|
|
25
31
|
// cleaning up the localStorage data, since some cached splits might need be part of the preloaded data
|
|
26
32
|
storage.splits.clear();
|
|
27
33
|
storage.splits.setChangeNumber(since);
|
|
28
34
|
// splitsData in an object where the property is the split name and the pertaining value is a stringified json of its data
|
|
29
|
-
storage.splits.addSplits(splitsData.map(function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var mySegmentsData = preloadedData.mySegmentsData && preloadedData.mySegmentsData[userKey];
|
|
35
|
+
storage.splits.addSplits(Object.keys(splitsData).map(function (splitName) { return JSON.parse(splitsData[splitName]); }));
|
|
36
|
+
// add mySegments data
|
|
37
|
+
var mySegmentsData = preloadedData.mySegmentsData && preloadedData.mySegmentsData[userId];
|
|
33
38
|
if (!mySegmentsData) {
|
|
34
39
|
// segmentsData in an object where the property is the segment name and the pertaining value is a stringified object that contains the `added` array of userIds
|
|
35
40
|
mySegmentsData = Object.keys(segmentsData).filter(function (segmentName) {
|
|
36
|
-
var
|
|
37
|
-
return
|
|
41
|
+
var userIds = JSON.parse(segmentsData[segmentName]).added;
|
|
42
|
+
return Array.isArray(userIds) && userIds.indexOf(userId) > -1;
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
storage.segments.resetSegments({ k: mySegmentsData.map(function (s) { return ({ n: s }); }) });
|
|
41
|
-
}
|
|
42
|
-
else { // add segments data (server-side)
|
|
43
|
-
Object.keys(segmentsData).filter(function (segmentName) {
|
|
44
|
-
var userKeys = segmentsData[segmentName];
|
|
45
|
-
storage.segments.addToSegment(segmentName, userKeys);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export function getSnapshot(storage, userKeys) {
|
|
50
|
-
return {
|
|
51
|
-
// lastUpdated: Date.now(),
|
|
52
|
-
// @ts-ignore accessing private prop
|
|
53
|
-
since: storage.splits.changeNumber,
|
|
54
|
-
splitsData: storage.splits.getAll(),
|
|
55
|
-
segmentsData: userKeys ?
|
|
56
|
-
undefined : // @ts-ignore accessing private prop
|
|
57
|
-
Object.keys(storage.segments.segmentCache).reduce(function (prev, cur) {
|
|
58
|
-
prev[cur] = setToArray(storage.segments.segmentCache[cur]);
|
|
59
|
-
return prev;
|
|
60
|
-
}, {}),
|
|
61
|
-
mySegmentsData: userKeys ?
|
|
62
|
-
userKeys.reduce(function (prev, userKey) {
|
|
63
|
-
// @ts-ignore accessing private prop
|
|
64
|
-
prev[userKey] = storage.shared ?
|
|
65
|
-
// Client-side segments
|
|
66
|
-
// @ts-ignore accessing private prop
|
|
67
|
-
Object.keys(storage.shared(userKey).segments.segmentCache) :
|
|
68
|
-
// Server-side segments
|
|
69
|
-
// @ts-ignore accessing private prop
|
|
70
|
-
Object.keys(storage.segments.segmentCache).reduce(function (prev, segmentName) {
|
|
71
|
-
return storage.segments.segmentCache[segmentName].has(userKey) ?
|
|
72
|
-
prev.concat(segmentName) :
|
|
73
|
-
prev;
|
|
74
|
-
}, []);
|
|
75
|
-
return prev;
|
|
76
|
-
}, {}) :
|
|
77
|
-
undefined
|
|
78
46
|
};
|
|
79
47
|
}
|
|
@@ -45,28 +45,8 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
45
45
|
// Scan current values from localStorage
|
|
46
46
|
return Object.keys(localStorage).reduce(function (accum, key) {
|
|
47
47
|
var segmentName = _this.keys.extractSegmentName(key);
|
|
48
|
-
if (segmentName)
|
|
48
|
+
if (segmentName)
|
|
49
49
|
accum.push(segmentName);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
// @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
|
|
53
|
-
segmentName = _this.keys.extractOldSegmentKey(key);
|
|
54
|
-
if (segmentName) { // this was an old segment key, let's clean up.
|
|
55
|
-
var newSegmentKey = _this.keys.buildSegmentNameKey(segmentName);
|
|
56
|
-
try {
|
|
57
|
-
// If the new format key is not there, create it.
|
|
58
|
-
if (!localStorage.getItem(newSegmentKey)) {
|
|
59
|
-
localStorage.setItem(newSegmentKey, DEFINED);
|
|
60
|
-
// we are migrating a segment, let's track it.
|
|
61
|
-
accum.push(segmentName);
|
|
62
|
-
}
|
|
63
|
-
localStorage.removeItem(key); // we migrated the current key, let's delete it.
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
_this.log.error(e);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
50
|
return accum;
|
|
71
51
|
}, []);
|
|
72
52
|
};
|