@splitsoftware/splitio-commons 1.16.1-rc.10 → 1.16.1-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/logger/constants.js +2 -2
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/services/splitApi.js +1 -1
- package/cjs/storages/AbstractSegmentsCacheSync.js +41 -7
- package/cjs/storages/dataLoader.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +19 -63
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +5 -40
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +7 -17
- package/cjs/sync/streaming/AuthClient/index.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +5 -7
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +8 -6
- package/cjs/sync/streaming/constants.js +3 -3
- package/cjs/sync/streaming/pushManager.js +21 -24
- package/cjs/utils/constants/index.js +3 -4
- package/esm/logger/constants.js +1 -1
- package/esm/logger/messages/warn.js +1 -1
- package/esm/services/splitApi.js +2 -2
- package/esm/storages/AbstractSegmentsCacheSync.js +41 -7
- package/esm/storages/dataLoader.js +1 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +19 -63
- package/esm/storages/inMemory/MySegmentsCacheInMemory.js +5 -40
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +7 -17
- package/esm/sync/streaming/AuthClient/index.js +1 -1
- package/esm/sync/streaming/SSEHandler/index.js +6 -8
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +8 -6
- package/esm/sync/streaming/constants.js +2 -2
- package/esm/sync/streaming/pushManager.js +24 -27
- package/esm/utils/constants/index.js +1 -2
- package/package.json +1 -1
- package/src/dtos/types.ts +9 -12
- package/src/logger/constants.ts +1 -1
- package/src/logger/messages/warn.ts +1 -1
- package/src/services/splitApi.ts +2 -2
- package/src/storages/AbstractSegmentsCacheSync.ts +52 -7
- package/src/storages/AbstractSplitsCacheSync.ts +1 -1
- package/src/storages/dataLoader.ts +1 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +15 -69
- package/src/storages/inMemory/MySegmentsCacheInMemory.ts +6 -46
- package/src/storages/types.ts +5 -4
- package/src/sync/polling/types.ts +8 -9
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +9 -14
- package/src/sync/streaming/AuthClient/index.ts +1 -1
- package/src/sync/streaming/SSEHandler/index.ts +9 -11
- package/src/sync/streaming/SSEHandler/types.ts +6 -6
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +8 -7
- package/src/sync/streaming/constants.ts +2 -2
- package/src/sync/streaming/parseUtils.ts +2 -2
- package/src/sync/streaming/pushManager.ts +26 -29
- package/src/sync/streaming/types.ts +6 -6
- package/src/sync/submitters/types.ts +3 -4
- package/src/utils/constants/index.ts +1 -2
- package/types/dtos/types.d.ts +8 -12
- package/types/logger/constants.d.ts +1 -1
- package/types/storages/AbstractSegmentsCacheSync.d.ts +8 -6
- package/types/storages/AbstractSplitsCacheSync.d.ts +1 -1
- package/types/storages/inLocalStorage/MySegmentsCacheInLocal.d.ts +1 -12
- package/types/storages/inMemory/MySegmentsCacheInMemory.d.ts +1 -9
- package/types/storages/types.d.ts +5 -4
- package/types/sync/polling/types.d.ts +8 -6
- package/types/sync/streaming/SSEHandler/types.d.ts +6 -6
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +1 -2
- package/types/sync/streaming/constants.d.ts +2 -2
- package/types/sync/streaming/parseUtils.d.ts +2 -2
- package/types/sync/streaming/types.d.ts +5 -5
- package/types/sync/submitters/types.d.ts +3 -4
- package/types/utils/constants/index.d.ts +1 -2
package/cjs/logger/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ENGINE_VALUE_INVALID = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.ENGINE_MATCHER_RESULT = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_SEGMENTS = exports.SYNC_SPLITS_REMOVED = exports.SYNC_SPLITS_NEW = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
|
|
4
|
-
exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.
|
|
4
|
+
exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MEMBERSHIP_UPDATE = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = void 0;
|
|
5
5
|
exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* Message codes used to trim string log messages from commons and client-side API modules,
|
|
@@ -82,7 +82,7 @@ exports.WARN_SPLITS_FILTER_IGNORED = 219;
|
|
|
82
82
|
exports.WARN_SPLITS_FILTER_INVALID = 220;
|
|
83
83
|
exports.WARN_SPLITS_FILTER_EMPTY = 221;
|
|
84
84
|
exports.WARN_SDK_KEY = 222;
|
|
85
|
-
exports.
|
|
85
|
+
exports.STREAMING_PARSING_MEMBERSHIP_UPDATE = 223;
|
|
86
86
|
exports.STREAMING_PARSING_SPLIT_UPDATE = 224;
|
|
87
87
|
exports.WARN_INVALID_FLAGSET = 225;
|
|
88
88
|
exports.WARN_LOWERCASE_FLAGSET = 226;
|
|
@@ -34,7 +34,7 @@ exports.codesWarn = error_1.codesError.concat([
|
|
|
34
34
|
[c.WARN_SPLITS_FILTER_INVALID, c.LOG_PREFIX_SETTINGS + ': feature flag filter at position %s is invalid. It must be an object with a valid filter type ("bySet", "byName" or "byPrefix") and a list of "values".'],
|
|
35
35
|
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
|
|
36
36
|
[c.WARN_SDK_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
|
|
37
|
-
[c.
|
|
37
|
+
[c.STREAMING_PARSING_MEMBERSHIP_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching Memberships due to an error processing %s notification: %s'],
|
|
38
38
|
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing SPLIT_UPDATE notification: %s'],
|
|
39
39
|
[c.WARN_INVALID_FLAGSET, '%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.'],
|
|
40
40
|
[c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
|
package/cjs/services/splitApi.js
CHANGED
|
@@ -62,7 +62,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
62
62
|
* - match user keys with special characters. E.g.: 'foo%bar', 'foo/bar'
|
|
63
63
|
*/
|
|
64
64
|
var url = urls.sdk + "/memberships/" + encodeURIComponent(userMatchingKey);
|
|
65
|
-
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.
|
|
65
|
+
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.MEMBERSHIPS));
|
|
66
66
|
},
|
|
67
67
|
/**
|
|
68
68
|
* Post events.
|
|
@@ -9,20 +9,54 @@ var AbstractSegmentsCacheSync = /** @class */ (function () {
|
|
|
9
9
|
function AbstractSegmentsCacheSync() {
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
* For client-side synchronizer: the method is not used.
|
|
12
|
+
* clear the cache.
|
|
14
13
|
*/
|
|
15
|
-
AbstractSegmentsCacheSync.prototype.
|
|
14
|
+
AbstractSegmentsCacheSync.prototype.clear = function () {
|
|
15
|
+
this.resetSegments({});
|
|
16
|
+
};
|
|
16
17
|
/**
|
|
17
|
-
* For server-side synchronizer:
|
|
18
|
+
* For server-side synchronizer: add the given list of segments to the cache, with an empty list of keys. The segments that already exist are not modified.
|
|
18
19
|
* For client-side synchronizer: the method is not used.
|
|
19
20
|
*/
|
|
20
|
-
AbstractSegmentsCacheSync.prototype.
|
|
21
|
+
AbstractSegmentsCacheSync.prototype.registerSegments = function (names) { return false; };
|
|
21
22
|
/**
|
|
22
23
|
* For server-side synchronizer: the method is not used.
|
|
23
|
-
* For client-side synchronizer:
|
|
24
|
+
* For client-side synchronizer: it resets or updates the cache.
|
|
24
25
|
*/
|
|
25
|
-
AbstractSegmentsCacheSync.prototype.resetSegments = function (
|
|
26
|
+
AbstractSegmentsCacheSync.prototype.resetSegments = function (segmentsData) {
|
|
27
|
+
var _this = this;
|
|
28
|
+
this.setChangeNumber(undefined, segmentsData.cn);
|
|
29
|
+
var _a = segmentsData, added = _a.added, removed = _a.removed;
|
|
30
|
+
if (added && removed) {
|
|
31
|
+
var isDiff_1 = false;
|
|
32
|
+
added.forEach(function (segment) {
|
|
33
|
+
isDiff_1 = _this.addToSegment(segment) || isDiff_1;
|
|
34
|
+
});
|
|
35
|
+
removed.forEach(function (segment) {
|
|
36
|
+
isDiff_1 = _this.removeFromSegment(segment) || isDiff_1;
|
|
37
|
+
});
|
|
38
|
+
return isDiff_1;
|
|
39
|
+
}
|
|
40
|
+
var names = (segmentsData.k || []).map(function (s) { return s.n; }).sort();
|
|
41
|
+
var storedSegmentKeys = this.getRegisteredSegments().sort();
|
|
42
|
+
// Extreme fast => everything is empty
|
|
43
|
+
if (!names.length && !storedSegmentKeys.length)
|
|
44
|
+
return false;
|
|
45
|
+
var index = 0;
|
|
46
|
+
while (index < names.length && index < storedSegmentKeys.length && names[index] === storedSegmentKeys[index])
|
|
47
|
+
index++;
|
|
48
|
+
// Quick path => no changes
|
|
49
|
+
if (index === names.length && index === storedSegmentKeys.length)
|
|
50
|
+
return false;
|
|
51
|
+
// Slowest path => add and/or remove segments
|
|
52
|
+
for (var removeIndex = index; removeIndex < storedSegmentKeys.length; removeIndex++) {
|
|
53
|
+
this.removeFromSegment(storedSegmentKeys[removeIndex]);
|
|
54
|
+
}
|
|
55
|
+
for (var addIndex = index; addIndex < names.length; addIndex++) {
|
|
56
|
+
this.addToSegment(names[addIndex]);
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
26
60
|
return AbstractSegmentsCacheSync;
|
|
27
61
|
}());
|
|
28
62
|
exports.AbstractSegmentsCacheSync = AbstractSegmentsCacheSync;
|
|
@@ -45,7 +45,7 @@ function dataLoaderFactory(preloadedData) {
|
|
|
45
45
|
return Array.isArray(userIds) && userIds.indexOf(userId) > -1;
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
storage.segments.resetSegments(mySegmentsData);
|
|
48
|
+
storage.segments.resetSegments({ k: mySegmentsData.map(function (s) { return ({ n: s }); }) });
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
exports.dataLoaderFactory = dataLoaderFactory;
|
|
@@ -14,19 +14,11 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
14
14
|
return _this;
|
|
15
15
|
// There is not need to flush segments cache like splits cache, since resetSegments receives the up-to-date list of active segments
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Removes list of segments from localStorage
|
|
19
|
-
* @NOTE this method is not being used at the moment.
|
|
20
|
-
*/
|
|
21
|
-
MySegmentsCacheInLocal.prototype.clear = function () {
|
|
22
|
-
this.log.info(constants_1.LOG_PREFIX + 'Flushing MySegments data from localStorage');
|
|
23
|
-
// We cannot simply call `localStorage.clear()` since that implies removing user items from the storage
|
|
24
|
-
// We could optimize next sentence, since it implies iterating over all localStorage items
|
|
25
|
-
this.resetSegments([]);
|
|
26
|
-
};
|
|
27
17
|
MySegmentsCacheInLocal.prototype.addToSegment = function (name) {
|
|
28
18
|
var segmentKey = this.keys.buildSegmentNameKey(name);
|
|
29
19
|
try {
|
|
20
|
+
if (localStorage.getItem(segmentKey) === constants_1.DEFINED)
|
|
21
|
+
return false;
|
|
30
22
|
localStorage.setItem(segmentKey, constants_1.DEFINED);
|
|
31
23
|
return true;
|
|
32
24
|
}
|
|
@@ -38,6 +30,8 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
38
30
|
MySegmentsCacheInLocal.prototype.removeFromSegment = function (name) {
|
|
39
31
|
var segmentKey = this.keys.buildSegmentNameKey(name);
|
|
40
32
|
try {
|
|
33
|
+
if (localStorage.getItem(segmentKey) !== constants_1.DEFINED)
|
|
34
|
+
return false;
|
|
41
35
|
localStorage.removeItem(segmentKey);
|
|
42
36
|
return true;
|
|
43
37
|
}
|
|
@@ -49,41 +43,22 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
49
43
|
MySegmentsCacheInLocal.prototype.isInSegment = function (name) {
|
|
50
44
|
return localStorage.getItem(this.keys.buildSegmentNameKey(name)) === constants_1.DEFINED;
|
|
51
45
|
};
|
|
52
|
-
|
|
53
|
-
* Reset (update) the cached list of segments with the given list, removing and adding segments if necessary.
|
|
54
|
-
*
|
|
55
|
-
* @param {string[]} names list of segment names
|
|
56
|
-
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
57
|
-
*/
|
|
58
|
-
MySegmentsCacheInLocal.prototype.resetSegments = function (names, changeNumber) {
|
|
46
|
+
MySegmentsCacheInLocal.prototype.getRegisteredSegments = function () {
|
|
59
47
|
var _this = this;
|
|
60
|
-
try {
|
|
61
|
-
if (changeNumber) {
|
|
62
|
-
localStorage.setItem(this.keys.buildTillKey(), changeNumber + '');
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
localStorage.removeItem(this.keys.buildTillKey());
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
catch (e) {
|
|
69
|
-
this.log.error(e);
|
|
70
|
-
}
|
|
71
|
-
var isDiff = false;
|
|
72
|
-
var index;
|
|
73
48
|
// Scan current values from localStorage
|
|
74
|
-
|
|
49
|
+
return Object.keys(localStorage).reduce(function (accum, key) {
|
|
75
50
|
var segmentName = _this.keys.extractSegmentName(key);
|
|
76
51
|
if (segmentName) {
|
|
77
52
|
accum.push(segmentName);
|
|
78
53
|
}
|
|
79
54
|
else {
|
|
80
|
-
// @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
|
|
55
|
+
// @TODO @BREAKING: This is only to clean up "old" keys. Remove this whole else code block
|
|
81
56
|
segmentName = _this.keys.extractOldSegmentKey(key);
|
|
82
57
|
if (segmentName) { // this was an old segment key, let's clean up.
|
|
83
58
|
var newSegmentKey = _this.keys.buildSegmentNameKey(segmentName);
|
|
84
59
|
try {
|
|
85
60
|
// If the new format key is not there, create it.
|
|
86
|
-
if (!localStorage.getItem(newSegmentKey)
|
|
61
|
+
if (!localStorage.getItem(newSegmentKey)) {
|
|
87
62
|
localStorage.setItem(newSegmentKey, constants_1.DEFINED);
|
|
88
63
|
// we are migrating a segment, let's track it.
|
|
89
64
|
accum.push(segmentName);
|
|
@@ -97,40 +72,21 @@ var MySegmentsCacheInLocal = /** @class */ (function (_super) {
|
|
|
97
72
|
}
|
|
98
73
|
return accum;
|
|
99
74
|
}, []);
|
|
100
|
-
// Extreme fast => everything is empty
|
|
101
|
-
if (names.length === 0 && storedSegmentNames.length === names.length)
|
|
102
|
-
return isDiff;
|
|
103
|
-
// Quick path
|
|
104
|
-
if (storedSegmentNames.length !== names.length) {
|
|
105
|
-
isDiff = true;
|
|
106
|
-
storedSegmentNames.forEach(function (name) { return _this.removeFromSegment(name); });
|
|
107
|
-
names.forEach(function (name) { return _this.addToSegment(name); });
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// Slowest path => we need to find at least 1 difference because
|
|
111
|
-
for (index = 0; index < names.length && storedSegmentNames.indexOf(names[index]) !== -1; index++) {
|
|
112
|
-
// TODO: why empty statement?
|
|
113
|
-
}
|
|
114
|
-
if (index < names.length) {
|
|
115
|
-
isDiff = true;
|
|
116
|
-
storedSegmentNames.forEach(function (name) { return _this.removeFromSegment(name); });
|
|
117
|
-
names.forEach(function (name) { return _this.addToSegment(name); });
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return isDiff;
|
|
121
|
-
};
|
|
122
|
-
MySegmentsCacheInLocal.prototype.getRegisteredSegments = function () {
|
|
123
|
-
var _this = this;
|
|
124
|
-
return Object.keys(localStorage).reduce(function (accum, key) {
|
|
125
|
-
var segmentName = _this.keys.extractSegmentName(key);
|
|
126
|
-
if (segmentName)
|
|
127
|
-
accum.push(segmentName);
|
|
128
|
-
return accum;
|
|
129
|
-
}, []);
|
|
130
75
|
};
|
|
131
76
|
MySegmentsCacheInLocal.prototype.getKeysCount = function () {
|
|
132
77
|
return 1;
|
|
133
78
|
};
|
|
79
|
+
MySegmentsCacheInLocal.prototype.setChangeNumber = function (name, changeNumber) {
|
|
80
|
+
try {
|
|
81
|
+
if (changeNumber)
|
|
82
|
+
localStorage.setItem(this.keys.buildTillKey(), changeNumber + '');
|
|
83
|
+
else
|
|
84
|
+
localStorage.removeItem(this.keys.buildTillKey());
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
this.log.error(e);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
134
90
|
MySegmentsCacheInLocal.prototype.getChangeNumber = function () {
|
|
135
91
|
var n = -1;
|
|
136
92
|
var value = localStorage.getItem(this.keys.buildTillKey());
|
|
@@ -14,58 +14,23 @@ var MySegmentsCacheInMemory = /** @class */ (function (_super) {
|
|
|
14
14
|
_this.segmentCache = {};
|
|
15
15
|
return _this;
|
|
16
16
|
}
|
|
17
|
-
MySegmentsCacheInMemory.prototype.clear = function () {
|
|
18
|
-
this.segmentCache = {};
|
|
19
|
-
};
|
|
20
17
|
MySegmentsCacheInMemory.prototype.addToSegment = function (name) {
|
|
18
|
+
if (this.segmentCache[name])
|
|
19
|
+
return false;
|
|
21
20
|
this.segmentCache[name] = true;
|
|
22
21
|
return true;
|
|
23
22
|
};
|
|
24
23
|
MySegmentsCacheInMemory.prototype.removeFromSegment = function (name) {
|
|
24
|
+
if (!this.segmentCache[name])
|
|
25
|
+
return false;
|
|
25
26
|
delete this.segmentCache[name];
|
|
26
27
|
return true;
|
|
27
28
|
};
|
|
28
29
|
MySegmentsCacheInMemory.prototype.isInSegment = function (name) {
|
|
29
30
|
return this.segmentCache[name] === true;
|
|
30
31
|
};
|
|
31
|
-
|
|
32
|
-
* Reset (update) the cached list of segments with the given list, removing and adding segments if necessary.
|
|
33
|
-
* @NOTE based on the way we use segments in the browser, this way is the best option
|
|
34
|
-
*
|
|
35
|
-
* @param {string[]} names list of segment names
|
|
36
|
-
* @returns boolean indicating if the cache was updated (i.e., given list was different from the cached one)
|
|
37
|
-
*/
|
|
38
|
-
MySegmentsCacheInMemory.prototype.resetSegments = function (names, changeNumber) {
|
|
39
|
-
var _this = this;
|
|
32
|
+
MySegmentsCacheInMemory.prototype.setChangeNumber = function (name, changeNumber) {
|
|
40
33
|
this.cn = changeNumber;
|
|
41
|
-
var isDiff = false;
|
|
42
|
-
var index;
|
|
43
|
-
var storedSegmentKeys = Object.keys(this.segmentCache);
|
|
44
|
-
// Extreme fast => everything is empty
|
|
45
|
-
if (names.length === 0 && storedSegmentKeys.length === names.length)
|
|
46
|
-
return isDiff;
|
|
47
|
-
// Quick path
|
|
48
|
-
if (storedSegmentKeys.length !== names.length) {
|
|
49
|
-
isDiff = true;
|
|
50
|
-
this.segmentCache = {};
|
|
51
|
-
names.forEach(function (s) {
|
|
52
|
-
_this.addToSegment(s);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// Slowest path => we need to find at least 1 difference because
|
|
57
|
-
for (index = 0; index < names.length && this.isInSegment(names[index]); index++) {
|
|
58
|
-
// TODO: why empty statement?
|
|
59
|
-
}
|
|
60
|
-
if (index < names.length) {
|
|
61
|
-
isDiff = true;
|
|
62
|
-
this.segmentCache = {};
|
|
63
|
-
names.forEach(function (s) {
|
|
64
|
-
_this.addToSegment(s);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return isDiff;
|
|
69
34
|
};
|
|
70
35
|
MySegmentsCacheInMemory.prototype.getChangeNumber = function () {
|
|
71
36
|
return this.cn || -1;
|
|
@@ -4,6 +4,7 @@ exports.mySegmentsUpdaterFactory = void 0;
|
|
|
4
4
|
var timeout_1 = require("../../../utils/promise/timeout");
|
|
5
5
|
var constants_1 = require("../../../readiness/constants");
|
|
6
6
|
var constants_2 = require("../../../logger/constants");
|
|
7
|
+
var constants_3 = require("../../streaming/constants");
|
|
7
8
|
/**
|
|
8
9
|
* factory of MySegments updater, a task that:
|
|
9
10
|
* - fetches mySegments using `mySegmentsFetcher`
|
|
@@ -22,26 +23,15 @@ function mySegmentsUpdaterFactory(log, mySegmentsFetcher, storage, segmentsEvent
|
|
|
22
23
|
}
|
|
23
24
|
// @TODO if allowing pluggable storages, handle async execution
|
|
24
25
|
function updateSegments(segmentsData) {
|
|
25
|
-
var _a, _b, _c, _d;
|
|
26
26
|
var shouldNotifyUpdate;
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var cache = isLS ? largeSegments : segments;
|
|
32
|
-
if (cache.isInSegment(name) !== add) {
|
|
33
|
-
shouldNotifyUpdate = true;
|
|
34
|
-
if (add)
|
|
35
|
-
cache.addToSegment(name);
|
|
36
|
-
else
|
|
37
|
-
cache.removeFromSegment(name);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
27
|
+
if (segmentsData.type !== undefined) {
|
|
28
|
+
shouldNotifyUpdate = segmentsData.type === constants_3.MEMBERSHIP_LS_UPDATE ?
|
|
29
|
+
largeSegments.resetSegments(segmentsData) :
|
|
30
|
+
segments.resetSegments(segmentsData);
|
|
40
31
|
}
|
|
41
32
|
else {
|
|
42
|
-
|
|
43
|
-
shouldNotifyUpdate =
|
|
44
|
-
shouldNotifyUpdate = largeSegments.resetSegments((((_c = segmentsData.ls) === null || _c === void 0 ? void 0 : _c.k) || []).map(function (segment) { return segment.n; }), (_d = segmentsData.ls) === null || _d === void 0 ? void 0 : _d.cn) || shouldNotifyUpdate;
|
|
33
|
+
shouldNotifyUpdate = segments.resetSegments(segmentsData.ms || {});
|
|
34
|
+
shouldNotifyUpdate = largeSegments.resetSegments(segmentsData.ls || {}) || shouldNotifyUpdate;
|
|
45
35
|
}
|
|
46
36
|
// Notify update if required
|
|
47
37
|
if (splits.usesSegments() && (shouldNotifyUpdate || readyOnAlreadyExistentState)) {
|
|
@@ -13,7 +13,7 @@ var murmur3_1 = require("../../../utils/murmur3/murmur3");
|
|
|
13
13
|
function authenticateFactory(fetchAuth) {
|
|
14
14
|
/**
|
|
15
15
|
* Run authentication requests to Auth Server, and returns a promise that resolves with the decoded JTW token.
|
|
16
|
-
* @param {string[] | undefined} userKeys set of user Keys to track
|
|
16
|
+
* @param {string[] | undefined} userKeys set of user Keys to track membership updates. It is undefined for server-side API.
|
|
17
17
|
*/
|
|
18
18
|
return function authenticate(userKeys) {
|
|
19
19
|
return fetchAuth(userKeys)
|
|
@@ -69,18 +69,16 @@ function SSEHandlerFactory(log, pushEmitter, telemetryTracker) {
|
|
|
69
69
|
var parsedData = messageWithParsedData.parsedData, data = messageWithParsedData.data, channel = messageWithParsedData.channel, timestamp = messageWithParsedData.timestamp;
|
|
70
70
|
log.debug(constants_2.STREAMING_NEW_MESSAGE, [data]);
|
|
71
71
|
// we only handle update events if streaming is up
|
|
72
|
-
|
|
73
|
-
var type = parsedData.type || parsedData.t;
|
|
74
|
-
if (!notificationKeeper.isStreamingUp() && [constants_1.OCCUPANCY, constants_1.CONTROL].indexOf(type) === -1)
|
|
72
|
+
if (!notificationKeeper.isStreamingUp() && [constants_1.OCCUPANCY, constants_1.CONTROL].indexOf(parsedData.type) === -1)
|
|
75
73
|
return;
|
|
76
|
-
switch (type) {
|
|
74
|
+
switch (parsedData.type) {
|
|
77
75
|
/* update events */
|
|
78
76
|
case constants_1.SPLIT_UPDATE:
|
|
79
77
|
case constants_1.SEGMENT_UPDATE:
|
|
80
|
-
case constants_1.
|
|
81
|
-
case constants_1.
|
|
78
|
+
case constants_1.MEMBERSHIP_MS_UPDATE:
|
|
79
|
+
case constants_1.MEMBERSHIP_LS_UPDATE:
|
|
82
80
|
case constants_1.SPLIT_KILL:
|
|
83
|
-
pushEmitter.emit(type, parsedData);
|
|
81
|
+
pushEmitter.emit(parsedData.type, parsedData);
|
|
84
82
|
break;
|
|
85
83
|
/* occupancy & control events, handled by NotificationManagerKeeper */
|
|
86
84
|
case constants_1.OCCUPANCY:
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MySegmentsUpdateWorker = void 0;
|
|
4
4
|
var Backoff_1 = require("../../../utils/Backoff");
|
|
5
|
+
var constants_1 = require("../../../utils/constants");
|
|
5
6
|
/**
|
|
6
7
|
* MySegmentsUpdateWorker factory
|
|
7
8
|
*/
|
|
8
|
-
function MySegmentsUpdateWorker(mySegmentsSyncTask, telemetryTracker
|
|
9
|
+
function MySegmentsUpdateWorker(mySegmentsSyncTask, telemetryTracker) {
|
|
9
10
|
var maxChangeNumber = 0; // keeps the maximum changeNumber among queued events
|
|
10
11
|
var currentChangeNumber = -1;
|
|
11
12
|
var handleNewEvent = false;
|
|
@@ -33,7 +34,7 @@ function MySegmentsUpdateWorker(mySegmentsSyncTask, telemetryTracker, updateType
|
|
|
33
34
|
return; // halt if `stop` has been called
|
|
34
35
|
if (result !== false) { // Unlike `Splits|SegmentsUpdateWorker`, we cannot use `mySegmentsCache.getChangeNumber` since `/mySegments` endpoint doesn't provide this value.
|
|
35
36
|
if (_segmentsData)
|
|
36
|
-
telemetryTracker.trackUpdatesFromSSE(
|
|
37
|
+
telemetryTracker.trackUpdatesFromSSE(constants_1.MEMBERSHIPS);
|
|
37
38
|
currentChangeNumber = Math.max(currentChangeNumber, currentMaxChangeNumber_1); // use `currentMaxChangeNumber`, in case that `maxChangeNumber` was updated during fetch.
|
|
38
39
|
}
|
|
39
40
|
if (handleNewEvent) {
|
|
@@ -56,13 +57,14 @@ function MySegmentsUpdateWorker(mySegmentsSyncTask, telemetryTracker, updateType
|
|
|
56
57
|
* @param segmentsData data for KeyList or SegmentRemoval instant updates
|
|
57
58
|
* @param delay optional time to wait for BoundedFetchRequest or BoundedFetchRequest updates
|
|
58
59
|
*/
|
|
59
|
-
put: function (
|
|
60
|
+
put: function (mySegmentsData, payload, delay) {
|
|
61
|
+
var type = mySegmentsData.type, cn = mySegmentsData.cn;
|
|
60
62
|
// Ignore event if it is outdated or if there is a pending fetch request (_delay is set)
|
|
61
|
-
if (
|
|
63
|
+
if (cn <= currentChangeNumber || cn <= maxChangeNumber || _delay)
|
|
62
64
|
return;
|
|
63
|
-
maxChangeNumber =
|
|
65
|
+
maxChangeNumber = cn;
|
|
64
66
|
handleNewEvent = true;
|
|
65
|
-
_segmentsData =
|
|
67
|
+
_segmentsData = payload && { type: type, cn: cn, added: payload.added, removed: payload.removed };
|
|
66
68
|
_delay = delay;
|
|
67
69
|
if (backoff.timeoutID || !isHandlingEvent)
|
|
68
70
|
__handleMySegmentsUpdateCall();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ControlType = exports.OCCUPANCY = exports.CONTROL = exports.
|
|
3
|
+
exports.ControlType = exports.OCCUPANCY = exports.CONTROL = exports.SPLIT_UPDATE = exports.SPLIT_KILL = exports.SEGMENT_UPDATE = exports.MEMBERSHIP_LS_UPDATE = exports.MEMBERSHIP_MS_UPDATE = exports.PUSH_SUBSYSTEM_DOWN = exports.PUSH_SUBSYSTEM_UP = exports.PUSH_RETRYABLE_ERROR = exports.PUSH_NONRETRYABLE_ERROR = exports.SECONDS_BEFORE_EXPIRATION = void 0;
|
|
4
4
|
// time for refresh token
|
|
5
5
|
exports.SECONDS_BEFORE_EXPIRATION = 600;
|
|
6
6
|
// Internal SDK events, subscribed by SyncManager and PushManager
|
|
@@ -25,11 +25,11 @@ exports.PUSH_SUBSYSTEM_UP = 'PUSH_SUBSYSTEM_UP';
|
|
|
25
25
|
*/
|
|
26
26
|
exports.PUSH_SUBSYSTEM_DOWN = 'PUSH_SUBSYSTEM_DOWN';
|
|
27
27
|
// Update-type push notifications, handled by NotificationProcessor
|
|
28
|
-
exports.
|
|
28
|
+
exports.MEMBERSHIP_MS_UPDATE = 'MEMBERSHIP_MS_UPDATE';
|
|
29
|
+
exports.MEMBERSHIP_LS_UPDATE = 'MEMBERSHIP_LS_UPDATE';
|
|
29
30
|
exports.SEGMENT_UPDATE = 'SEGMENT_UPDATE';
|
|
30
31
|
exports.SPLIT_KILL = 'SPLIT_KILL';
|
|
31
32
|
exports.SPLIT_UPDATE = 'SPLIT_UPDATE';
|
|
32
|
-
exports.MY_LARGE_SEGMENTS_UPDATE = 'MY_LARGE_SEGMENTS_UPDATE';
|
|
33
33
|
// Control-type push notifications, handled by NotificationKeeper
|
|
34
34
|
exports.CONTROL = 'CONTROL';
|
|
35
35
|
exports.OCCUPANCY = 'OCCUPANCY';
|
|
@@ -48,10 +48,10 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
48
48
|
var segmentsUpdateWorker = userKey ? undefined : (0, SegmentsUpdateWorker_1.SegmentsUpdateWorker)(log, pollingManager.segmentsSyncTask, storage.segments);
|
|
49
49
|
// For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
|
|
50
50
|
var splitsUpdateWorker = (0, SplitsUpdateWorker_1.SplitsUpdateWorker)(log, storage.splits, pollingManager.splitsSyncTask, readiness.splits, telemetryTracker, userKey ? undefined : pollingManager.segmentsSyncTask);
|
|
51
|
-
// [Only for client-side] map of hashes to user keys, to dispatch
|
|
51
|
+
// [Only for client-side] map of hashes to user keys, to dispatch membership update events to the corresponding MySegmentsUpdateWorker
|
|
52
52
|
var userKeyHashes = {};
|
|
53
53
|
// [Only for client-side] map of user keys to their corresponding hash64 and MySegmentsUpdateWorkers.
|
|
54
|
-
// Hash64 is used to process
|
|
54
|
+
// Hash64 is used to process membership update events and dispatch actions to the corresponding MySegmentsUpdateWorker.
|
|
55
55
|
var clients = {};
|
|
56
56
|
// [Only for client-side] variable to flag that a new client was added. It is needed to reconnect streaming.
|
|
57
57
|
var connectForNewClient = false;
|
|
@@ -200,7 +200,7 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
200
200
|
splitsUpdateWorker.put(parsedData);
|
|
201
201
|
});
|
|
202
202
|
function handleMySegmentsUpdate(parsedData) {
|
|
203
|
-
var isLS = parsedData.
|
|
203
|
+
var isLS = parsedData.type === constants_1.MEMBERSHIP_LS_UPDATE;
|
|
204
204
|
switch (parsedData.u) {
|
|
205
205
|
case types_1.UpdateStrategy.BoundedFetchRequest: {
|
|
206
206
|
var bitmap_1;
|
|
@@ -208,13 +208,13 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
208
208
|
bitmap_1 = (0, parseUtils_1.parseBitmap)(parsedData.d, parsedData.c);
|
|
209
209
|
}
|
|
210
210
|
catch (e) {
|
|
211
|
-
log.warn(constants_2.
|
|
211
|
+
log.warn(constants_2.STREAMING_PARSING_MEMBERSHIP_UPDATE, ['BoundedFetchRequest', e]);
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
214
|
(0, lang_1.forOwn)(clients, function (_a, matchingKey) {
|
|
215
215
|
var hash64 = _a.hash64, worker = _a.worker, workerLarge = _a.workerLarge;
|
|
216
216
|
if ((0, parseUtils_1.isInBitmap)(bitmap_1, hash64.hex)) {
|
|
217
|
-
(isLS ? workerLarge : worker).put(parsedData
|
|
217
|
+
(isLS ? workerLarge : worker).put(parsedData, undefined, (0, parseUtils_1.getDelay)(parsedData, matchingKey));
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
return;
|
|
@@ -227,51 +227,48 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
227
227
|
removed_1 = new sets_1._Set(keyList.r);
|
|
228
228
|
}
|
|
229
229
|
catch (e) {
|
|
230
|
-
log.warn(constants_2.
|
|
230
|
+
log.warn(constants_2.STREAMING_PARSING_MEMBERSHIP_UPDATE, ['KeyList', e]);
|
|
231
231
|
break;
|
|
232
232
|
}
|
|
233
233
|
if (!parsedData.n || !parsedData.n.length) {
|
|
234
|
-
log.warn(constants_2.
|
|
234
|
+
log.warn(constants_2.STREAMING_PARSING_MEMBERSHIP_UPDATE, ['KeyList', 'No segment name was provided']);
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
237
|
(0, lang_1.forOwn)(clients, function (_a) {
|
|
238
238
|
var hash64 = _a.hash64, worker = _a.worker, workerLarge = _a.workerLarge;
|
|
239
239
|
var add = added_1.has(hash64.dec) ? true : removed_1.has(hash64.dec) ? false : undefined;
|
|
240
240
|
if (add !== undefined) {
|
|
241
|
-
(isLS ? workerLarge : worker).put(parsedData
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}]);
|
|
241
|
+
(isLS ? workerLarge : worker).put(parsedData, {
|
|
242
|
+
added: add ? [parsedData.n[0]] : [],
|
|
243
|
+
removed: add ? [] : [parsedData.n[0]]
|
|
244
|
+
});
|
|
246
245
|
}
|
|
247
246
|
});
|
|
248
247
|
return;
|
|
249
248
|
}
|
|
250
249
|
case types_1.UpdateStrategy.SegmentRemoval:
|
|
251
250
|
if (!parsedData.n || !parsedData.n.length) {
|
|
252
|
-
log.warn(constants_2.
|
|
251
|
+
log.warn(constants_2.STREAMING_PARSING_MEMBERSHIP_UPDATE, ['SegmentRemoval', 'No segment name was provided']);
|
|
253
252
|
break;
|
|
254
253
|
}
|
|
255
254
|
(0, lang_1.forOwn)(clients, function (_a) {
|
|
256
255
|
var worker = _a.worker, workerLarge = _a.workerLarge;
|
|
257
|
-
(isLS ? workerLarge : worker).put(parsedData
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
cn: parsedData.cn
|
|
262
|
-
}); }));
|
|
256
|
+
(isLS ? workerLarge : worker).put(parsedData, {
|
|
257
|
+
added: [],
|
|
258
|
+
removed: parsedData.n
|
|
259
|
+
});
|
|
263
260
|
});
|
|
264
261
|
return;
|
|
265
262
|
}
|
|
266
263
|
// `UpdateStrategy.UnboundedFetchRequest` and fallbacks of other cases
|
|
267
264
|
(0, lang_1.forOwn)(clients, function (_a, matchingKey) {
|
|
268
265
|
var worker = _a.worker, workerLarge = _a.workerLarge;
|
|
269
|
-
(isLS ? workerLarge : worker).put(parsedData
|
|
266
|
+
(isLS ? workerLarge : worker).put(parsedData, undefined, (0, parseUtils_1.getDelay)(parsedData, matchingKey));
|
|
270
267
|
});
|
|
271
268
|
}
|
|
272
269
|
if (userKey) {
|
|
273
|
-
pushEmitter.on(constants_1.
|
|
274
|
-
pushEmitter.on(constants_1.
|
|
270
|
+
pushEmitter.on(constants_1.MEMBERSHIP_MS_UPDATE, handleMySegmentsUpdate);
|
|
271
|
+
pushEmitter.on(constants_1.MEMBERSHIP_LS_UPDATE, handleMySegmentsUpdate);
|
|
275
272
|
}
|
|
276
273
|
else {
|
|
277
274
|
pushEmitter.on(constants_1.SEGMENT_UPDATE, segmentsUpdateWorker.put);
|
|
@@ -309,8 +306,8 @@ function pushManagerFactory(params, pollingManager) {
|
|
|
309
306
|
userKeyHashes[hash] = userKey;
|
|
310
307
|
clients[userKey] = {
|
|
311
308
|
hash64: (0, murmur3_64_1.hash64)(userKey),
|
|
312
|
-
worker: (0, MySegmentsUpdateWorker_1.MySegmentsUpdateWorker)(mySegmentsSyncTask, telemetryTracker
|
|
313
|
-
workerLarge: (0, MySegmentsUpdateWorker_1.MySegmentsUpdateWorker)(mySegmentsSyncTask, telemetryTracker
|
|
309
|
+
worker: (0, MySegmentsUpdateWorker_1.MySegmentsUpdateWorker)(mySegmentsSyncTask, telemetryTracker),
|
|
310
|
+
workerLarge: (0, MySegmentsUpdateWorker_1.MySegmentsUpdateWorker)(mySegmentsSyncTask, telemetryTracker)
|
|
314
311
|
};
|
|
315
312
|
connectForNewClient = true; // we must reconnect on start, to listen the channel for the new user key
|
|
316
313
|
// Reconnects in case of a new client.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.IN_LARGE_SEGMENT = exports.IN_SEGMENT = exports.FLAG_SPEC_VERSION = exports.PAUSED = exports.ENABLED = exports.DISABLED = exports.NON_REQUESTED = exports.REQUESTED = exports.POLLING = exports.STREAMING = exports.AUTH_REJECTION = exports.SYNC_MODE_UPDATE = 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_BY_FLAGSETS = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSET = exports.TREATMENTS_BY_FLAGSETS = exports.TREATMENTS_BY_FLAGSET = exports.TREATMENTS_WITH_CONFIG = exports.TREATMENT_WITH_CONFIG = exports.TREATMENTS = exports.TREATMENT =
|
|
3
|
+
exports.MEMBERSHIPS = 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.NAMES_FN_LABEL = exports.SPLITS_FN_LABEL = exports.SPLIT_FN_LABEL = exports.TRACK_FN_LABEL = exports.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS = exports.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET = exports.GET_TREATMENTS_BY_FLAG_SETS = exports.GET_TREATMENTS_BY_FLAG_SET = exports.GET_TREATMENTS_WITH_CONFIG = exports.GET_TREATMENT_WITH_CONFIG = exports.GET_TREATMENTS = exports.GET_TREATMENT = 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.IN_LARGE_SEGMENT = exports.IN_SEGMENT = exports.FLAG_SPEC_VERSION = exports.PAUSED = exports.ENABLED = exports.DISABLED = exports.NON_REQUESTED = exports.REQUESTED = exports.POLLING = exports.STREAMING = exports.AUTH_REJECTION = exports.SYNC_MODE_UPDATE = 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_BY_FLAGSETS = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSET = exports.TREATMENTS_BY_FLAGSETS = exports.TREATMENTS_BY_FLAGSET = exports.TREATMENTS_WITH_CONFIG = exports.TREATMENT_WITH_CONFIG = exports.TREATMENTS = exports.TREATMENT = void 0;
|
|
5
5
|
// Special treatments
|
|
6
6
|
exports.CONTROL = 'control';
|
|
7
7
|
exports.CONTROL_WITH_CONFIG = {
|
|
@@ -64,8 +64,7 @@ exports.EVENTS = 'ev';
|
|
|
64
64
|
exports.TELEMETRY = 'te';
|
|
65
65
|
exports.TOKEN = 'to';
|
|
66
66
|
exports.SEGMENT = 'se';
|
|
67
|
-
exports.
|
|
68
|
-
exports.MY_LARGE_SEGMENT = 'mls';
|
|
67
|
+
exports.MEMBERSHIPS = 'ms';
|
|
69
68
|
exports.TREATMENT = 't';
|
|
70
69
|
exports.TREATMENTS = 'ts';
|
|
71
70
|
exports.TREATMENT_WITH_CONFIG = 'tc';
|
package/esm/logger/constants.js
CHANGED
|
@@ -77,7 +77,7 @@ export var WARN_SPLITS_FILTER_IGNORED = 219;
|
|
|
77
77
|
export var WARN_SPLITS_FILTER_INVALID = 220;
|
|
78
78
|
export var WARN_SPLITS_FILTER_EMPTY = 221;
|
|
79
79
|
export var WARN_SDK_KEY = 222;
|
|
80
|
-
export var
|
|
80
|
+
export var STREAMING_PARSING_MEMBERSHIP_UPDATE = 223;
|
|
81
81
|
export var STREAMING_PARSING_SPLIT_UPDATE = 224;
|
|
82
82
|
export var WARN_INVALID_FLAGSET = 225;
|
|
83
83
|
export var WARN_LOWERCASE_FLAGSET = 226;
|
|
@@ -30,7 +30,7 @@ export var codesWarn = codesError.concat([
|
|
|
30
30
|
[c.WARN_SPLITS_FILTER_INVALID, c.LOG_PREFIX_SETTINGS + ': feature flag filter at position %s is invalid. It must be an object with a valid filter type ("bySet", "byName" or "byPrefix") and a list of "values".'],
|
|
31
31
|
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
|
|
32
32
|
[c.WARN_SDK_KEY, c.LOG_PREFIX_SETTINGS + ': You already have %s. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application'],
|
|
33
|
-
[c.
|
|
33
|
+
[c.STREAMING_PARSING_MEMBERSHIP_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching Memberships due to an error processing %s notification: %s'],
|
|
34
34
|
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing SPLIT_UPDATE notification: %s'],
|
|
35
35
|
[c.WARN_INVALID_FLAGSET, '%s: you passed %s, flag set must adhere to the regular expressions %s. This means a flag set must start with a letter or number, be in lowercase, alphanumeric and have a max length of 50 characters. %s was discarded.'],
|
|
36
36
|
[c.WARN_LOWERCASE_FLAGSET, '%s: flag set %s should be all lowercase - converting string to lowercase.'],
|