@splitsoftware/splitio-commons 1.17.1-rc.3 → 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/readiness/readinessManager.js +5 -7
- package/cjs/sdkClient/clientCS.js +5 -8
- package/cjs/sdkClient/sdkClientMethodCS.js +5 -8
- package/cjs/sdkFactory/index.js +10 -33
- 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 -64
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/cjs/storages/inLocalStorage/index.js +1 -6
- 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 +3 -4
- 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/storages/pluggable/index.js +32 -37
- 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/trackers/eventTracker.js +9 -11
- package/cjs/trackers/impressionsTracker.js +13 -15
- package/cjs/trackers/uniqueKeysTracker.js +3 -5
- 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/readiness/readinessManager.js +5 -7
- package/esm/sdkClient/clientCS.js +5 -8
- package/esm/sdkClient/sdkClientMethodCS.js +5 -8
- package/esm/sdkFactory/index.js +11 -34
- 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 -61
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -21
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +14 -7
- package/esm/storages/inLocalStorage/index.js +2 -7
- 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 +3 -4
- 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/storages/pluggable/index.js +32 -37
- 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/trackers/eventTracker.js +9 -11
- package/esm/trackers/impressionsTracker.js +13 -15
- package/esm/trackers/uniqueKeysTracker.js +3 -5
- 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/readiness/readinessManager.ts +7 -9
- package/src/readiness/types.ts +0 -1
- package/src/sdkClient/clientCS.ts +5 -8
- package/src/sdkClient/sdkClientMethodCS.ts +3 -6
- package/src/sdkFactory/index.ts +12 -37
- package/src/sdkFactory/types.ts +1 -4
- 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 -62
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +1 -21
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +16 -8
- package/src/storages/inLocalStorage/index.ts +2 -8
- 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 +4 -5
- 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/pluggable/index.ts +33 -38
- package/src/storages/types.ts +9 -6
- 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/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +9 -12
- package/src/trackers/types.ts +0 -1
- package/src/trackers/uniqueKeysTracker.ts +4 -6
- 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/readiness/types.d.ts +0 -1
- package/types/sdkClient/clientCS.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +1 -3
- 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 -6
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -2
- package/types/sync/submitters/types.d.ts +3 -4
- package/types/trackers/eventTracker.d.ts +1 -1
- package/types/trackers/impressionsTracker.d.ts +1 -1
- package/types/trackers/types.d.ts +0 -1
- 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 -79
- 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 -75
- 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 -101
- package/src/utils/lang/maps.ts +0 -108
|
@@ -1,82 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
object-assign
|
|
7
|
-
(c) Sindre Sorhus
|
|
8
|
-
@license MIT
|
|
9
|
-
*/
|
|
10
|
-
/* eslint-disable */
|
|
11
|
-
// @ts-nocheck
|
|
12
|
-
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
13
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
14
|
-
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
15
|
-
function toObject(val) {
|
|
16
|
-
if (val === null || val === undefined) {
|
|
1
|
+
/**
|
|
2
|
+
* A tiny polyfill for Object.assign
|
|
3
|
+
*/
|
|
4
|
+
export var objectAssign = Object.assign || function (target) {
|
|
5
|
+
if (target === null || target === undefined)
|
|
17
6
|
throw new TypeError('Object.assign cannot be called with null or undefined');
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
// Detect buggy property enumeration order in older V8 versions.
|
|
27
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
|
|
28
|
-
var test1 = new String('abc');
|
|
29
|
-
test1[5] = 'de';
|
|
30
|
-
if (Object.getOwnPropertyNames(test1)[0] === '5') {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
34
|
-
var test2 = {};
|
|
35
|
-
for (var i = 0; i < 10; i++) {
|
|
36
|
-
test2['_' + String.fromCharCode(i)] = i;
|
|
37
|
-
}
|
|
38
|
-
var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
|
|
39
|
-
return test2[n];
|
|
40
|
-
});
|
|
41
|
-
if (order2.join('') !== '0123456789') {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
|
|
45
|
-
var test3 = {};
|
|
46
|
-
'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
|
|
47
|
-
test3[letter] = letter;
|
|
48
|
-
});
|
|
49
|
-
if (Object.keys(Object.assign({}, test3)).join('') !==
|
|
50
|
-
'abcdefghijklmnopqrst') {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
catch (err) {
|
|
56
|
-
// We don't expect any of the above to throw, but better to be safe.
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
export var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
|
|
61
|
-
var from;
|
|
62
|
-
var to = toObject(target);
|
|
63
|
-
var symbols;
|
|
64
|
-
for (var s = 1; s < arguments.length; s++) {
|
|
65
|
-
from = Object(arguments[s]);
|
|
66
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
67
|
-
for (var key in from) {
|
|
68
|
-
if (hasOwnProperty.call(from, key)) {
|
|
69
|
-
to[key] = from[key];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (getOwnPropertySymbols) {
|
|
73
|
-
symbols = getOwnPropertySymbols(from);
|
|
74
|
-
for (var i = 0; i < symbols.length; i++) {
|
|
75
|
-
if (propIsEnumerable.call(from, symbols[i])) {
|
|
76
|
-
to[symbols[i]] = from[symbols[i]];
|
|
77
|
-
}
|
|
7
|
+
target = Object(target);
|
|
8
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
9
|
+
var source = Object(arguments[i]); // eslint-disable-next-line no-restricted-syntax
|
|
10
|
+
for (var key in source) {
|
|
11
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
12
|
+
target[key] = source[key];
|
|
78
13
|
}
|
|
79
14
|
}
|
|
80
15
|
}
|
|
81
|
-
return
|
|
16
|
+
return target;
|
|
82
17
|
};
|
package/esm/utils/lang/sets.js
CHANGED
|
@@ -1,113 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set implementation based on es6-set polyfill (https://github.com/medikoo/es6-set/blob/master/polyfill.js),
|
|
3
|
-
* with the minimal features used by the SDK.
|
|
4
|
-
|
|
5
|
-
Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
**/
|
|
25
|
-
var SetPoly = /** @class */ (function () {
|
|
26
|
-
// unlike ES6 `Set`, it only accepts an array as first argument iterable
|
|
27
|
-
function SetPoly(values) {
|
|
28
|
-
var _this = this;
|
|
29
|
-
this.__setData__ = [];
|
|
30
|
-
if (Array.isArray(values))
|
|
31
|
-
values.forEach(function (value) { _this.add(value); });
|
|
32
|
-
}
|
|
33
|
-
SetPoly.prototype.clear = function () {
|
|
34
|
-
if (!this.__setData__.length)
|
|
35
|
-
return;
|
|
36
|
-
this.__setData__.length = 0;
|
|
37
|
-
};
|
|
38
|
-
SetPoly.prototype.add = function (value) {
|
|
39
|
-
if (this.has(value))
|
|
40
|
-
return this;
|
|
41
|
-
this.__setData__.push(value);
|
|
42
|
-
return this;
|
|
43
|
-
};
|
|
44
|
-
SetPoly.prototype.delete = function (value) {
|
|
45
|
-
var index = this.__setData__.indexOf(value);
|
|
46
|
-
if (index === -1)
|
|
47
|
-
return false;
|
|
48
|
-
this.__setData__.splice(index, 1);
|
|
49
|
-
return true;
|
|
50
|
-
};
|
|
51
|
-
SetPoly.prototype.has = function (value) {
|
|
52
|
-
return this.__setData__.indexOf(value) !== -1;
|
|
53
|
-
};
|
|
54
|
-
SetPoly.prototype.forEach = function (callbackfn, thisArg) {
|
|
55
|
-
if (typeof callbackfn !== 'function')
|
|
56
|
-
throw new TypeError(callbackfn + ' is not a function');
|
|
57
|
-
for (var i = 0; i < this.__setData__.length; i++) {
|
|
58
|
-
var value = this.__setData__[i];
|
|
59
|
-
callbackfn.call(thisArg, value, value, this);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
Object.defineProperty(SetPoly.prototype, "size", {
|
|
63
|
-
get: function () {
|
|
64
|
-
return this.__setData__.length;
|
|
65
|
-
},
|
|
66
|
-
enumerable: false,
|
|
67
|
-
configurable: true
|
|
68
|
-
});
|
|
69
|
-
return SetPoly;
|
|
70
|
-
}());
|
|
71
|
-
export { SetPoly };
|
|
72
|
-
/**
|
|
73
|
-
* return an array containing the items of the given set.
|
|
74
|
-
* @param set Set or SetPoly instance
|
|
75
|
-
*/
|
|
76
|
-
export function setToArray(set) {
|
|
77
|
-
if (set instanceof SetPoly) {
|
|
78
|
-
return set.__setData__.slice();
|
|
79
|
-
}
|
|
80
|
-
// if not using SetPoly as set, it means Array.from is supported
|
|
81
|
-
// eslint-disable-next-line compat/compat
|
|
82
|
-
return Array.from(set);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* 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,
|
|
86
|
-
* a ponyfill with minimal features is returned instead.
|
|
87
|
-
*
|
|
88
|
-
* Exported for testing purposes only.
|
|
89
|
-
*/
|
|
90
|
-
export function __getSetConstructor() {
|
|
91
|
-
// eslint-disable-next-line compat/compat
|
|
92
|
-
if (typeof Array.from === 'function' && typeof Set === 'function' && Set.prototype && Set.prototype.values) {
|
|
93
|
-
return Set;
|
|
94
|
-
}
|
|
95
|
-
return SetPoly;
|
|
96
|
-
}
|
|
97
|
-
export var _Set = __getSetConstructor();
|
|
98
1
|
export function returnSetsUnion(set, set2) {
|
|
99
|
-
|
|
100
|
-
set2.forEach(function (value) {
|
|
101
|
-
result.add(value);
|
|
102
|
-
});
|
|
103
|
-
return result;
|
|
2
|
+
return new Set(Array.from(set).concat(Array.from(set2)));
|
|
104
3
|
}
|
|
105
4
|
export function returnDifference(list, list2) {
|
|
106
5
|
if (list === void 0) { list = []; }
|
|
107
6
|
if (list2 === void 0) { list2 = []; }
|
|
108
|
-
|
|
109
|
-
list2.forEach(function (item) {
|
|
110
|
-
result.delete(item);
|
|
111
|
-
});
|
|
112
|
-
return setToArray(result);
|
|
7
|
+
return list.filter(function (item) { return list2.indexOf(item) === -1; });
|
|
113
8
|
}
|
|
@@ -4,7 +4,6 @@ import { validateSplitFilters } from './splitFilters';
|
|
|
4
4
|
import { STANDALONE_MODE, OPTIMIZED, LOCALHOST_MODE, DEBUG, FLAG_SPEC_VERSION } from '../constants';
|
|
5
5
|
import { validImpressionsMode } from './impressionsMode';
|
|
6
6
|
import { validateKey } from '../inputValidation/key';
|
|
7
|
-
import { validateTrafficType } from '../inputValidation/trafficType';
|
|
8
7
|
import { ERROR_MIN_CONFIG_PARAM, LOG_PREFIX_CLIENT_INSTANTIATION } from '../../logger/constants';
|
|
9
8
|
// Exported for telemetry
|
|
10
9
|
export var base = {
|
|
@@ -15,8 +14,6 @@ export var base = {
|
|
|
15
14
|
authorizationKey: undefined,
|
|
16
15
|
// key used in your system (only required for browser version)
|
|
17
16
|
key: undefined,
|
|
18
|
-
// traffic type for the given key (only used on browser version)
|
|
19
|
-
trafficType: undefined,
|
|
20
17
|
// toggle impressions tracking of labels
|
|
21
18
|
labelsEnabled: true,
|
|
22
19
|
// toggle sendind (true) or not sending (false) IP and Host Name with impressions, events, and telemetries requests (only used on nodejs version)
|
|
@@ -145,12 +142,6 @@ export function settingsValidation(config, validationParams) {
|
|
|
145
142
|
// @ts-ignore, @TODO handle invalid keys as a non-recoverable error?
|
|
146
143
|
withDefaults.core.key = validateKey(log, maybeKey, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
147
144
|
}
|
|
148
|
-
if (validationParams.acceptTT) {
|
|
149
|
-
var maybeTT = withDefaults.core.trafficType;
|
|
150
|
-
if (maybeTT !== undefined) { // @ts-ignore
|
|
151
|
-
withDefaults.core.trafficType = validateTrafficType(log, maybeTT, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
145
|
}
|
|
155
146
|
else {
|
|
156
147
|
// On server-side, key is undefined and used to distinguish from client-side
|
|
@@ -2,9 +2,8 @@ import { isLogLevelString, Logger, LogLevels } from '../../../logger';
|
|
|
2
2
|
import { isLocalStorageAvailable } from '../../env/isLocalStorageAvailable';
|
|
3
3
|
import { isNode } from '../../env/isNode';
|
|
4
4
|
import { codesDebug } from '../../../logger/messages/debug';
|
|
5
|
-
import { _Map } from '../../lang/maps';
|
|
6
5
|
import { getLogLevel } from './commons';
|
|
7
|
-
var allCodes = new
|
|
6
|
+
var allCodes = new Map(codesDebug);
|
|
8
7
|
// @TODO set default debug setting instead of initialLogLevel when integrating in JS and Node packages
|
|
9
8
|
var LS_KEY = 'splitio_debug';
|
|
10
9
|
var ENV_VAR_KEY = 'SPLITIO_DEBUG';
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { InMemoryStorageCSFactory } from '../../../storages/inMemory/InMemoryStorageCS';
|
|
2
2
|
import { ERROR_STORAGE_INVALID } from '../../../logger/constants';
|
|
3
3
|
import { LOCALHOST_MODE, STANDALONE_MODE, STORAGE_PLUGGABLE, STORAGE_LOCALSTORAGE, STORAGE_MEMORY } from '../../../utils/constants';
|
|
4
|
+
export function __InLocalStorageMockFactory(params) {
|
|
5
|
+
var result = InMemoryStorageCSFactory(params);
|
|
6
|
+
result.splits.checkCache = function () { return true; }; // to emit SDK_READY_FROM_CACHE
|
|
7
|
+
return result;
|
|
8
|
+
}
|
|
9
|
+
__InLocalStorageMockFactory.type = STORAGE_MEMORY;
|
|
4
10
|
/**
|
|
5
11
|
* This function validates `settings.storage` object
|
|
6
12
|
*
|
|
@@ -17,6 +23,10 @@ export function validateStorageCS(settings) {
|
|
|
17
23
|
storage = InMemoryStorageCSFactory;
|
|
18
24
|
log.error(ERROR_STORAGE_INVALID);
|
|
19
25
|
}
|
|
26
|
+
// In localhost mode with InLocalStorage, fallback to a mock InLocalStorage to emit SDK_READY_FROM_CACHE
|
|
27
|
+
if (mode === LOCALHOST_MODE && storage.type === STORAGE_LOCALSTORAGE) {
|
|
28
|
+
return __InLocalStorageMockFactory;
|
|
29
|
+
}
|
|
20
30
|
if ([LOCALHOST_MODE, STANDALONE_MODE].indexOf(mode) === -1) {
|
|
21
31
|
// Consumer modes require an async storage
|
|
22
32
|
if (storage.type !== STORAGE_PLUGGABLE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-commons",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"description": "Split JavaScript SDK common components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@typescript-eslint/parser": "^6.6.0",
|
|
65
65
|
"cross-env": "^7.0.2",
|
|
66
66
|
"eslint": "^8.48.0",
|
|
67
|
-
"eslint-plugin-compat": "^
|
|
67
|
+
"eslint-plugin-compat": "^6.0.1",
|
|
68
68
|
"eslint-plugin-import": "^2.25.3",
|
|
69
69
|
"fetch-mock": "^9.11.0",
|
|
70
70
|
"ioredis": "^4.28.0",
|
package/src/evaluator/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
|
7
7
|
import { IEvaluationResult } from './types';
|
|
8
8
|
import { SplitIO } from '../types';
|
|
9
9
|
import { ILogger } from '../logger/types';
|
|
10
|
-
import {
|
|
10
|
+
import { returnSetsUnion } from '../utils/lang/sets';
|
|
11
11
|
import { WARN_FLAGSET_WITHOUT_FLAGS } from '../logger/constants';
|
|
12
12
|
|
|
13
13
|
const treatmentException = {
|
|
@@ -97,12 +97,12 @@ export function evaluateFeaturesByFlagSets(
|
|
|
97
97
|
storage: IStorageSync | IStorageAsync,
|
|
98
98
|
method: string,
|
|
99
99
|
): MaybeThenable<Record<string, IEvaluationResult>> {
|
|
100
|
-
let storedFlagNames: MaybeThenable<
|
|
100
|
+
let storedFlagNames: MaybeThenable<Set<string>[]>;
|
|
101
101
|
|
|
102
102
|
function evaluate(
|
|
103
|
-
featureFlagsByFlagSets:
|
|
103
|
+
featureFlagsByFlagSets: Set<string>[],
|
|
104
104
|
) {
|
|
105
|
-
let featureFlags = new
|
|
105
|
+
let featureFlags = new Set<string>();
|
|
106
106
|
for (let i = 0; i < flagSets.length; i++) {
|
|
107
107
|
const featureFlagByFlagSet = featureFlagsByFlagSets[i];
|
|
108
108
|
if (featureFlagByFlagSet.size) {
|
|
@@ -113,7 +113,7 @@ export function evaluateFeaturesByFlagSets(
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
return featureFlags.size ?
|
|
116
|
-
evaluateFeatures(log, key,
|
|
116
|
+
evaluateFeatures(log, key, Array.from(featureFlags), attributes, storage) :
|
|
117
117
|
{};
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { _Set } from '../../utils/lang/sets';
|
|
2
1
|
import { Semver } from '../../utils/Semver';
|
|
3
2
|
|
|
4
3
|
export function inListSemverMatcherContext(ruleAttr: string[]) {
|
|
5
4
|
// @TODO ruleAttr validation should be done at the `parser` or `matchersTransform` level to reuse for all matchers
|
|
6
5
|
if (!ruleAttr || ruleAttr.length === 0) throw new Error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type');
|
|
7
6
|
|
|
8
|
-
const listOfSemvers = new
|
|
7
|
+
const listOfSemvers = new Set(ruleAttr.map((version) => new Semver(version).version));
|
|
9
8
|
|
|
10
9
|
return function inListSemverMatcher(runtimeAttr: string): boolean {
|
|
11
10
|
const runtimeSemver = new Semver(runtimeAttr).version;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { _Set } from '../../utils/lang/sets';
|
|
2
|
-
|
|
3
1
|
export function whitelistMatcherContext(ruleAttr: string[]) {
|
|
4
|
-
const whitelistSet = new
|
|
2
|
+
const whitelistSet = new Set(ruleAttr);
|
|
5
3
|
|
|
6
4
|
return function whitelistMatcher(runtimeAttr: string): boolean {
|
|
7
5
|
const isInWhitelist = whitelistSet.has(runtimeAttr);
|
package/src/listeners/browser.ts
CHANGED
|
@@ -115,7 +115,6 @@ export class BrowserSignalListener implements ISignalListener {
|
|
|
115
115
|
* Returns true if beacon API was used successfully, false otherwise.
|
|
116
116
|
*/
|
|
117
117
|
private _sendBeacon(url: string, data: any, extraMetadata?: {}) {
|
|
118
|
-
// eslint-disable-next-line compat/compat
|
|
119
118
|
if (typeof navigator !== 'undefined' && navigator.sendBeacon) {
|
|
120
119
|
const json = {
|
|
121
120
|
entries: data,
|
|
@@ -130,7 +129,7 @@ export class BrowserSignalListener implements ISignalListener {
|
|
|
130
129
|
const payload = JSON.stringify(json);
|
|
131
130
|
|
|
132
131
|
// https://xgwang.me/posts/you-may-not-know-beacon/#it-may-throw-error%2C-be-sure-to-catch
|
|
133
|
-
try {
|
|
132
|
+
try {
|
|
134
133
|
return navigator.sendBeacon(url, payload);
|
|
135
134
|
} catch (e) {
|
|
136
135
|
return false;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesDebug } from '../messages/debug';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function DebugLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'DEBUG' }, new
|
|
5
|
+
return new Logger({ logLevel: 'DEBUG' }, new Map(codesDebug));
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesError } from '../messages/error';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function ErrorLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'ERROR' }, new
|
|
5
|
+
return new Logger({ logLevel: 'ERROR' }, new Map(codesError));
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesInfo } from '../messages/info';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function InfoLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'INFO' }, new
|
|
5
|
+
return new Logger({ logLevel: 'INFO' }, new Map(codesInfo));
|
|
7
6
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Logger } from '../index';
|
|
2
2
|
import { codesWarn } from '../messages/warn';
|
|
3
|
-
import { _Map } from '../../utils/lang/maps';
|
|
4
3
|
|
|
5
4
|
export function WarnLogger() {
|
|
6
|
-
return new Logger({ logLevel: 'WARN' }, new
|
|
5
|
+
return new Logger({ logLevel: 'WARN' }, new Map(codesWarn));
|
|
7
6
|
}
|
package/src/logger/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { objectAssign } from '../utils/lang/objectAssign';
|
|
|
2
2
|
import { ILoggerOptions, ILogger } from './types';
|
|
3
3
|
import { find, isObject } from '../utils/lang';
|
|
4
4
|
import { LogLevel } from '../types';
|
|
5
|
-
import { IMap, _Map } from '../utils/lang/maps';
|
|
6
5
|
|
|
7
6
|
export const LogLevels: { [level: string]: LogLevel } = {
|
|
8
7
|
DEBUG: 'DEBUG',
|
|
@@ -47,12 +46,12 @@ const defaultOptions = {
|
|
|
47
46
|
export class Logger implements ILogger {
|
|
48
47
|
|
|
49
48
|
private options: Required<ILoggerOptions>;
|
|
50
|
-
private codes:
|
|
49
|
+
private codes: Map<number, string>;
|
|
51
50
|
private logLevel: number;
|
|
52
51
|
|
|
53
|
-
constructor(options?: ILoggerOptions, codes?:
|
|
52
|
+
constructor(options?: ILoggerOptions, codes?: Map<number, string>) {
|
|
54
53
|
this.options = objectAssign({}, defaultOptions, options);
|
|
55
|
-
this.codes = codes || new
|
|
54
|
+
this.codes = codes || new Map();
|
|
56
55
|
this.logLevel = LogLevelIndexes[this.options.logLevel];
|
|
57
56
|
}
|
|
58
57
|
|
|
@@ -55,15 +55,19 @@ export function readinessManagerFactory(
|
|
|
55
55
|
|
|
56
56
|
// emit SDK_READY_TIMED_OUT
|
|
57
57
|
let hasTimedout = false;
|
|
58
|
-
let readyTimeoutId: ReturnType<typeof setTimeout>;
|
|
59
58
|
|
|
60
|
-
function timeout() {
|
|
61
|
-
if (hasTimedout
|
|
59
|
+
function timeout() {
|
|
60
|
+
if (hasTimedout) return;
|
|
62
61
|
hasTimedout = true;
|
|
63
62
|
syncLastUpdate();
|
|
64
63
|
gate.emit(SDK_READY_TIMED_OUT, 'Split SDK emitted SDK_READY_TIMED_OUT event.');
|
|
65
64
|
}
|
|
66
65
|
|
|
66
|
+
let readyTimeoutId: ReturnType<typeof setTimeout>;
|
|
67
|
+
if (readyTimeout > 0) {
|
|
68
|
+
readyTimeoutId = setTimeout(timeout, readyTimeout);
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
// emit SDK_READY and SDK_UPDATE
|
|
68
72
|
let isReady = false;
|
|
69
73
|
splits.on(SDK_SPLITS_ARRIVED, checkIsReadyOrUpdate);
|
|
@@ -128,12 +132,6 @@ export function readinessManagerFactory(
|
|
|
128
132
|
// tracking and evaluations, while keeping event listeners to emit SDK_READY_TIMED_OUT event
|
|
129
133
|
setDestroyed() { isDestroyed = true; },
|
|
130
134
|
|
|
131
|
-
init() {
|
|
132
|
-
if (readyTimeout > 0) {
|
|
133
|
-
readyTimeoutId = setTimeout(timeout, readyTimeout);
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
|
|
137
135
|
destroy() {
|
|
138
136
|
isDestroyed = true;
|
|
139
137
|
syncLastUpdate();
|
package/src/readiness/types.ts
CHANGED
|
@@ -5,18 +5,17 @@ import { clientAttributesDecoration } from './clientAttributesDecoration';
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Decorator that binds a key
|
|
8
|
+
* Decorator that binds a key to client methods
|
|
9
9
|
*
|
|
10
10
|
* @param client sync client instance
|
|
11
11
|
* @param key validated split key
|
|
12
|
-
* @param trafficType validated traffic type
|
|
13
12
|
*/
|
|
14
|
-
export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: SplitIO.SplitKey
|
|
13
|
+
export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: SplitIO.SplitKey): SplitIO.ICsClient {
|
|
15
14
|
|
|
16
15
|
let clientCS = clientAttributesDecoration(log, client);
|
|
17
16
|
|
|
18
17
|
return objectAssign(clientCS, {
|
|
19
|
-
// In the client-side API, we bind a key to the client `getTreatment*` methods
|
|
18
|
+
// In the client-side API, we bind a key to the client `getTreatment*` and `track` methods
|
|
20
19
|
getTreatment: clientCS.getTreatment.bind(clientCS, key),
|
|
21
20
|
getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key),
|
|
22
21
|
getTreatments: clientCS.getTreatments.bind(clientCS, key),
|
|
@@ -26,12 +25,10 @@ export function clientCSDecorator(log: ILogger, client: SplitIO.IClient, key: Sp
|
|
|
26
25
|
getTreatmentsByFlagSet: clientCS.getTreatmentsByFlagSet.bind(clientCS, key),
|
|
27
26
|
getTreatmentsWithConfigByFlagSet: clientCS.getTreatmentsWithConfigByFlagSet.bind(clientCS, key),
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
|
|
28
|
+
track: clientCS.track.bind(clientCS, key),
|
|
31
29
|
|
|
32
30
|
// Not part of the public API. These properties are used to support other modules (e.g., Split Suite)
|
|
33
31
|
isClientSide: true,
|
|
34
|
-
key
|
|
35
|
-
trafficType
|
|
32
|
+
key
|
|
36
33
|
}) as SplitIO.ICsClient;
|
|
37
34
|
}
|
|
@@ -15,7 +15,7 @@ import { buildInstanceId } from './identity';
|
|
|
15
15
|
* Therefore, clients don't have a bound TT for the track method.
|
|
16
16
|
*/
|
|
17
17
|
export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey) => SplitIO.ICsClient {
|
|
18
|
-
const { clients, storage, syncManager, sdkReadinessManager, settings: { core: { key }, log }
|
|
18
|
+
const { clients, storage, syncManager, sdkReadinessManager, settings: { core: { key }, log } } = params;
|
|
19
19
|
|
|
20
20
|
const mainClientInstance = clientCSDecorator(
|
|
21
21
|
log,
|
|
@@ -35,7 +35,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
|
|
|
35
35
|
return mainClientInstance;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
// Validate the key value
|
|
38
|
+
// Validate the key value
|
|
39
39
|
const validKey = validateKey(log, key, LOG_PREFIX_CLIENT_INSTANTIATION);
|
|
40
40
|
if (validKey === false) {
|
|
41
41
|
throw new Error('Shared Client needs a valid key.');
|
|
@@ -75,10 +75,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
|
|
|
75
75
|
validKey
|
|
76
76
|
);
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
sharedSdkReadiness.readinessManager.init();
|
|
80
|
-
sharedSyncManager && sharedSyncManager.start();
|
|
81
|
-
});
|
|
78
|
+
sharedSyncManager && sharedSyncManager.start();
|
|
82
79
|
|
|
83
80
|
log.info(NEW_SHARED_CLIENT);
|
|
84
81
|
} else {
|
package/src/sdkFactory/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { IBasicClient, SplitIO } from '../types';
|
|
|
7
7
|
import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
|
|
8
8
|
import { createLoggerAPI } from '../logger/sdkLogger';
|
|
9
9
|
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
|
|
10
|
-
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED
|
|
10
|
+
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
|
|
11
11
|
import { objectAssign } from '../utils/lang/objectAssign';
|
|
12
12
|
import { strategyDebugFactory } from '../trackers/strategy/strategyDebug';
|
|
13
13
|
import { strategyOptimizedFactory } from '../trackers/strategy/strategyOptimized';
|
|
@@ -23,20 +23,14 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
23
23
|
const { settings, platform, storageFactory, splitApiFactory, extraProps,
|
|
24
24
|
syncManagerFactory, SignalListener, impressionsObserverFactory,
|
|
25
25
|
integrationsManagerFactory, sdkManagerFactory, sdkClientMethodFactory,
|
|
26
|
-
filterAdapterFactory
|
|
26
|
+
filterAdapterFactory } = params;
|
|
27
27
|
const { log, sync: { impressionsMode } } = settings;
|
|
28
28
|
|
|
29
29
|
// @TODO handle non-recoverable errors, such as, global `fetch` not available, invalid SDK Key, etc.
|
|
30
30
|
// On non-recoverable errors, we should mark the SDK as destroyed and not start synchronization.
|
|
31
31
|
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
const initCallbacks: (() => void)[] = [];
|
|
35
|
-
|
|
36
|
-
function whenInit(cb: () => void) {
|
|
37
|
-
if (isInit) cb();
|
|
38
|
-
else initCallbacks.push(cb);
|
|
39
|
-
}
|
|
32
|
+
// We will just log and allow for the SDK to end up throwing an SDK_TIMEOUT event for devs to handle.
|
|
33
|
+
validateAndTrackApiKey(log, settings.core.authorizationKey);
|
|
40
34
|
|
|
41
35
|
const sdkReadinessManager = sdkReadinessManagerFactory(platform.EventEmitter, settings);
|
|
42
36
|
const readiness = sdkReadinessManager.readinessManager;
|
|
@@ -52,11 +46,8 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
52
46
|
readiness.splits.emit(SDK_SPLITS_ARRIVED);
|
|
53
47
|
readiness.segments.emit(SDK_SEGMENTS_ARRIVED);
|
|
54
48
|
},
|
|
55
|
-
onReadyFromCacheCb: () => {
|
|
56
|
-
readiness.splits.emit(SDK_SPLITS_CACHE_LOADED);
|
|
57
|
-
}
|
|
58
49
|
});
|
|
59
|
-
|
|
50
|
+
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`
|
|
60
51
|
const clients: Record<string, IBasicClient> = {};
|
|
61
52
|
const telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
|
|
62
53
|
const integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings, storage, telemetryTracker });
|
|
@@ -76,13 +67,13 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
76
67
|
strategy = strategyDebugFactory(observer);
|
|
77
68
|
}
|
|
78
69
|
|
|
79
|
-
const impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, strategy,
|
|
80
|
-
const eventTracker = eventTrackerFactory(settings, storage.events,
|
|
70
|
+
const impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, strategy, integrationsManager, storage.telemetry);
|
|
71
|
+
const eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
|
|
81
72
|
|
|
82
73
|
// splitApi is used by SyncManager and Browser signal listener
|
|
83
74
|
const splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
|
|
84
75
|
|
|
85
|
-
const ctx: ISdkFactoryContext = { clients, splitApi, eventTracker, impressionsTracker, telemetryTracker, uniqueKeysTracker, sdkReadinessManager, readiness, settings, storage, platform
|
|
76
|
+
const ctx: ISdkFactoryContext = { clients, splitApi, eventTracker, impressionsTracker, telemetryTracker, uniqueKeysTracker, sdkReadinessManager, readiness, settings, storage, platform };
|
|
86
77
|
|
|
87
78
|
const syncManager = syncManagerFactory && syncManagerFactory(ctx as ISdkFactoryContextSync);
|
|
88
79
|
ctx.syncManager = syncManager;
|
|
@@ -94,24 +85,8 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
94
85
|
const clientMethod = sdkClientMethodFactory(ctx);
|
|
95
86
|
const managerInstance = sdkManagerFactory(settings, storage.splits, sdkReadinessManager);
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (isInit) return;
|
|
100
|
-
isInit = true;
|
|
101
|
-
|
|
102
|
-
// We will just log and allow for the SDK to end up throwing an SDK_TIMEOUT event for devs to handle.
|
|
103
|
-
validateAndTrackApiKey(log, settings.core.authorizationKey);
|
|
104
|
-
readiness.init();
|
|
105
|
-
storage.init && storage.init();
|
|
106
|
-
uniqueKeysTracker && uniqueKeysTracker.start();
|
|
107
|
-
syncManager && syncManager.start();
|
|
108
|
-
signalListener && signalListener.start();
|
|
109
|
-
|
|
110
|
-
initCallbacks.forEach((cb) => cb());
|
|
111
|
-
initCallbacks.length = 0;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (!isPure) init();
|
|
88
|
+
syncManager && syncManager.start();
|
|
89
|
+
signalListener && signalListener.start();
|
|
115
90
|
|
|
116
91
|
log.info(NEW_FACTORY);
|
|
117
92
|
|
|
@@ -132,7 +107,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
|
|
|
132
107
|
settings,
|
|
133
108
|
|
|
134
109
|
destroy() {
|
|
135
|
-
return Promise.all(Object.keys(clients).map(key => clients[key].destroy())).then(() => {
|
|
110
|
+
return Promise.all(Object.keys(clients).map(key => clients[key].destroy())).then(() => {});
|
|
136
111
|
}
|
|
137
|
-
}, extraProps && extraProps(ctx)
|
|
112
|
+
}, extraProps && extraProps(ctx));
|
|
138
113
|
}
|