@splitsoftware/splitio-commons 1.9.2-rc.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.txt +4 -0
- package/cjs/evaluator/index.js +1 -18
- package/cjs/logger/constants.js +2 -7
- package/cjs/logger/messages/error.js +0 -2
- package/cjs/logger/messages/info.js +1 -1
- package/cjs/logger/messages/warn.js +1 -4
- package/cjs/sdkClient/client.js +0 -33
- package/cjs/sdkClient/clientAttributesDecoration.js +0 -20
- package/cjs/sdkClient/clientCS.js +4 -5
- package/cjs/sdkClient/clientInputValidation.js +3 -52
- package/cjs/sdkClient/sdkClientMethodCS.js +2 -2
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +1 -1
- package/cjs/sdkManager/index.js +1 -2
- package/cjs/services/splitApi.js +1 -7
- package/cjs/storages/KeyBuilder.js +0 -3
- package/cjs/storages/KeyBuilderSS.js +0 -4
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +27 -63
- package/cjs/storages/inLocalStorage/index.js +2 -2
- package/cjs/storages/inMemory/InMemoryStorage.js +2 -2
- package/cjs/storages/inMemory/InMemoryStorageCS.js +3 -3
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +2 -47
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +0 -11
- package/cjs/storages/pluggable/SplitsCachePluggable.js +0 -11
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +4 -24
- package/cjs/sync/submitters/telemetrySubmitter.js +1 -15
- package/cjs/utils/constants/index.js +2 -6
- package/cjs/utils/lang/sets.js +1 -9
- package/cjs/utils/settingsValidation/index.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +2 -72
- package/esm/evaluator/index.js +0 -16
- package/esm/logger/constants.js +0 -5
- package/esm/logger/messages/error.js +0 -2
- package/esm/logger/messages/info.js +1 -1
- package/esm/logger/messages/warn.js +1 -4
- package/esm/sdkClient/client.js +2 -35
- package/esm/sdkClient/clientAttributesDecoration.js +0 -20
- package/esm/sdkClient/clientCS.js +4 -5
- package/esm/sdkClient/clientInputValidation.js +3 -52
- package/esm/sdkClient/sdkClientMethodCS.js +2 -2
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +1 -1
- package/esm/sdkManager/index.js +1 -2
- package/esm/services/splitApi.js +1 -7
- package/esm/storages/KeyBuilder.js +0 -3
- package/esm/storages/KeyBuilderSS.js +0 -4
- package/esm/storages/inLocalStorage/SplitsCacheInLocal.js +27 -63
- package/esm/storages/inLocalStorage/index.js +2 -2
- package/esm/storages/inMemory/InMemoryStorage.js +2 -2
- package/esm/storages/inMemory/InMemoryStorageCS.js +3 -3
- package/esm/storages/inMemory/SplitsCacheInMemory.js +2 -47
- package/esm/storages/inRedis/SplitsCacheInRedis.js +0 -11
- package/esm/storages/pluggable/SplitsCachePluggable.js +0 -11
- package/esm/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/splitChangesUpdater.js +4 -24
- package/esm/sync/submitters/telemetrySubmitter.js +1 -15
- package/esm/utils/constants/index.js +0 -4
- package/esm/utils/lang/sets.js +0 -7
- package/esm/utils/settingsValidation/index.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +2 -71
- package/package.json +1 -1
- package/src/dtos/types.ts +2 -3
- package/src/evaluator/index.ts +0 -24
- package/src/logger/constants.ts +0 -5
- package/src/logger/messages/error.ts +0 -2
- package/src/logger/messages/info.ts +1 -1
- package/src/logger/messages/warn.ts +1 -4
- package/src/sdkClient/client.ts +2 -42
- package/src/sdkClient/clientAttributesDecoration.ts +0 -24
- package/src/sdkClient/clientCS.ts +4 -5
- package/src/sdkClient/clientInputValidation.ts +4 -56
- package/src/sdkClient/sdkClientMethodCS.ts +2 -2
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +1 -1
- package/src/sdkManager/index.ts +1 -2
- package/src/services/splitApi.ts +1 -6
- package/src/storages/AbstractSegmentsCacheSync.ts +1 -0
- package/src/storages/AbstractSplitsCacheAsync.ts +0 -2
- package/src/storages/AbstractSplitsCacheSync.ts +0 -3
- package/src/storages/KeyBuilder.ts +0 -4
- package/src/storages/KeyBuilderSS.ts +0 -4
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +28 -74
- package/src/storages/inLocalStorage/index.ts +2 -2
- package/src/storages/inMemory/InMemoryStorage.ts +2 -2
- package/src/storages/inMemory/InMemoryStorageCS.ts +3 -3
- package/src/storages/inMemory/SplitsCacheInMemory.ts +1 -50
- package/src/storages/inRedis/SplitsCacheInRedis.ts +0 -12
- package/src/storages/pluggable/SplitsCachePluggable.ts +0 -12
- package/src/storages/types.ts +3 -7
- package/src/sync/polling/syncTasks/splitsSyncTask.ts +0 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +4 -27
- package/src/sync/submitters/telemetrySubmitter.ts +2 -19
- package/src/sync/submitters/types.ts +1 -7
- package/src/types.ts +1 -118
- package/src/utils/constants/index.ts +0 -4
- package/src/utils/lang/sets.ts +0 -8
- package/src/utils/settingsValidation/index.ts +1 -1
- package/src/utils/settingsValidation/splitFilters.ts +2 -77
- package/types/dtos/types.d.ts +0 -1
- package/types/evaluator/index.d.ts +0 -1
- package/types/logger/constants.d.ts +0 -5
- package/types/sdkClient/clientAttributesDecoration.d.ts +0 -4
- package/types/sdkClient/identity.d.ts +6 -0
- package/types/sdkClient/sdkClientMethodCS.d.ts +2 -2
- package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +1 -1
- package/types/storages/AbstractSegmentsCacheSync.d.ts +1 -0
- package/types/storages/AbstractSplitsCacheAsync.d.ts +0 -2
- package/types/storages/AbstractSplitsCacheSync.d.ts +0 -2
- package/types/storages/KeyBuilder.d.ts +0 -1
- package/types/storages/inLocalStorage/SplitsCacheInLocal.d.ts +1 -6
- package/types/storages/inMemory/SplitsCacheInMemory.d.ts +1 -9
- package/types/storages/inRedis/SplitsCacheInRedis.d.ts +0 -8
- package/types/storages/pluggable/SplitsCachePluggable.d.ts +0 -8
- package/types/storages/types.d.ts +0 -4
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +3 -3
- package/types/sync/submitters/types.d.ts +1 -7
- package/types/types.d.ts +1 -118
- package/types/utils/constants/index.d.ts +0 -4
- package/types/utils/inputValidation/sdkKey.d.ts +7 -0
- package/types/utils/lang/sets.d.ts +0 -1
- package/types/utils/settingsValidation/splitFilters.d.ts +0 -1
- package/types/myLogger.d.ts +0 -5
- package/types/sdkClient/types.d.ts +0 -18
- package/types/storages/inMemory/CountsCacheInMemory.d.ts +0 -20
- package/types/storages/inMemory/LatenciesCacheInMemory.d.ts +0 -20
- package/types/storages/inRedis/CountsCacheInRedis.d.ts +0 -9
- package/types/storages/inRedis/LatenciesCacheInRedis.d.ts +0 -9
- package/types/storages/metadataBuilder.d.ts +0 -3
- package/types/sync/offline/LocalhostFromFile.d.ts +0 -2
- package/types/sync/offline/splitsParser/splitsParserFromFile.d.ts +0 -2
- package/types/sync/offline/updaters/splitChangesUpdater.d.ts +0 -0
- package/types/sync/submitters/eventsSyncTask.d.ts +0 -8
- package/types/sync/submitters/impressionCountsSubmitterInRedis.d.ts +0 -5
- package/types/sync/submitters/impressionCountsSyncTask.d.ts +0 -13
- package/types/sync/submitters/impressionsSyncTask.d.ts +0 -14
- package/types/sync/submitters/metricsSyncTask.d.ts +0 -12
- package/types/sync/submitters/submitterSyncTask.d.ts +0 -10
- package/types/sync/submitters/uniqueKeysSubmitterInRedis.d.ts +0 -5
- package/types/sync/syncTaskComposite.d.ts +0 -5
- package/types/trackers/filter/bloomFilter.d.ts +0 -10
- package/types/trackers/filter/dictionaryFilter.d.ts +0 -8
- package/types/trackers/filter/types.d.ts +0 -5
- package/types/utils/timeTracker/index.d.ts +0 -70
- /package/types/storages/inMemory/{uniqueKeysCacheInMemory.d.ts → UniqueKeysCacheInMemory.d.ts} +0 -0
- /package/types/storages/inMemory/{uniqueKeysCacheInMemoryCS.d.ts → UniqueKeysCacheInMemoryCS.d.ts} +0 -0
- /package/types/storages/inRedis/{uniqueKeysCacheInRedis.d.ts → UniqueKeysCacheInRedis.d.ts} +0 -0
package/CHANGES.txt
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
1.9.2 (October 19, 2023)
|
|
2
|
+
- Updated client module to support the Split Suite.
|
|
3
|
+
- Updated some transitive dependencies for vulnerability fixes.
|
|
4
|
+
|
|
1
5
|
1.9.1 (September 21, 2023)
|
|
2
6
|
- Updated browser listener to avoid registering a handler for 'unload' DOM events, that can prevent browsers from being able to put pages in the back/forward cache for faster back and forward loads (Related to issue https://github.com/splitio/javascript-client/issues/759).
|
|
3
7
|
|
package/cjs/evaluator/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.evaluateFeatures = exports.evaluateFeature = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var Engine_1 = require("./Engine");
|
|
6
6
|
var thenable_1 = require("../utils/promise/thenable");
|
|
7
7
|
var LabelsConstants = (0, tslib_1.__importStar)(require("../utils/labels"));
|
|
8
8
|
var constants_1 = require("../utils/constants");
|
|
9
|
-
var sets_1 = require("../utils/lang/sets");
|
|
10
9
|
var treatmentException = {
|
|
11
10
|
treatment: constants_1.CONTROL,
|
|
12
11
|
label: LabelsConstants.EXCEPTION,
|
|
@@ -56,22 +55,6 @@ function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
|
56
55
|
getEvaluations(log, splitNames, parsedSplits, key, attributes, storage);
|
|
57
56
|
}
|
|
58
57
|
exports.evaluateFeatures = evaluateFeatures;
|
|
59
|
-
function evaluateFeaturesByFlagSets(log, key, flagSets, attributes, storage) {
|
|
60
|
-
var storedFlagNames;
|
|
61
|
-
// get features by flag sets
|
|
62
|
-
try {
|
|
63
|
-
storedFlagNames = storage.splits.getNamesByFlagSets(flagSets);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
// return empty evaluations
|
|
67
|
-
return {};
|
|
68
|
-
}
|
|
69
|
-
// evaluate related features
|
|
70
|
-
return (0, thenable_1.thenable)(storedFlagNames) ?
|
|
71
|
-
storedFlagNames.then(function (splitNames) { return evaluateFeatures(log, key, (0, sets_1.setToArray)(splitNames), attributes, storage); }) :
|
|
72
|
-
evaluateFeatures(log, key, (0, sets_1.setToArray)(storedFlagNames), attributes, storage);
|
|
73
|
-
}
|
|
74
|
-
exports.evaluateFeaturesByFlagSets = evaluateFeaturesByFlagSets;
|
|
75
58
|
function getEvaluation(log, splitJSON, key, attributes, storage) {
|
|
76
59
|
var evaluation = {
|
|
77
60
|
treatment: constants_1.CONTROL,
|
package/cjs/logger/constants.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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.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_WHITELIST = exports.ENGINE_MATCHER_STARTS_WITH = exports.ENGINE_MATCHER_STRING_INVALID = exports.ENGINE_MATCHER_STRING = exports.ENGINE_MATCHER_SEGMENT = exports.ENGINE_MATCHER_PART_OF = exports.ENGINE_MATCHER_LESS = exports.ENGINE_MATCHER_GREATER = exports.ENGINE_MATCHER_ENDS_WITH = exports.ENGINE_MATCHER_EQUAL_TO_SET = exports.ENGINE_MATCHER_EQUAL = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_MATCHER_CONTAINS_STRING = exports.ENGINE_MATCHER_CONTAINS_ANY = exports.ENGINE_MATCHER_CONTAINS_ALL = exports.ENGINE_MATCHER_BOOLEAN = exports.ENGINE_MATCHER_BETWEEN = exports.ENGINE_MATCHER_ALL = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
|
|
4
|
-
exports.
|
|
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_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.
|
|
4
|
+
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.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 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 = 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 = void 0;
|
|
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_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = 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 = void 0;
|
|
6
6
|
/**
|
|
7
7
|
* Message codes used to trim string log messages from commons and client-side API modules,
|
|
8
8
|
* in order to reduce the minimal SDK size for Browser and eventually other client-side environments.
|
|
@@ -100,9 +100,6 @@ exports.WARN_SPLITS_FILTER_EMPTY = 221;
|
|
|
100
100
|
exports.WARN_SDK_KEY = 222;
|
|
101
101
|
exports.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = 223;
|
|
102
102
|
exports.STREAMING_PARSING_SPLIT_UPDATE = 224;
|
|
103
|
-
exports.WARN_SPLITS_FILTER_INVALID_SET = 225;
|
|
104
|
-
exports.WARN_SPLITS_FILTER_LOWERCASE_SET = 226;
|
|
105
|
-
exports.WARN_FLAGSET_NOT_CONFIGURED = 227;
|
|
106
103
|
exports.ERROR_ENGINE_COMBINER_IFELSEIF = 300;
|
|
107
104
|
exports.ERROR_LOGLEVEL_INVALID = 301;
|
|
108
105
|
exports.ERROR_CLIENT_LISTENER = 302;
|
|
@@ -130,8 +127,6 @@ exports.ERROR_LOCALHOST_MODULE_REQUIRED = 323;
|
|
|
130
127
|
exports.ERROR_STORAGE_INVALID = 324;
|
|
131
128
|
exports.ERROR_NOT_BOOLEAN = 325;
|
|
132
129
|
exports.ERROR_MIN_CONFIG_PARAM = 326;
|
|
133
|
-
exports.ERROR_TOO_MANY_SETS = 327;
|
|
134
|
-
exports.ERROR_SETS_FILTER_EXCLUSIVE = 328;
|
|
135
130
|
// Log prefixes (a.k.a. tags or categories)
|
|
136
131
|
exports.LOG_PREFIX_SETTINGS = 'settings';
|
|
137
132
|
exports.LOG_PREFIX_INSTANTIATION = 'Factory instantiation';
|
|
@@ -37,6 +37,4 @@ exports.codesError = [
|
|
|
37
37
|
[c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
|
|
38
38
|
[c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': the provided storage is invalid.%s Falling back into default MEMORY storage'],
|
|
39
39
|
[c.ERROR_MIN_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': the provided "%s" config param is lower than allowed. Setting to the minimum value %s seconds'],
|
|
40
|
-
[c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the amount of flag sets provided are big causing uri length error.'],
|
|
41
|
-
[c.ERROR_SETS_FILTER_EXCLUSIVE, c.LOG_PREFIX_SETTINGS + ': the Set filter is exclusive and cannot be used simultaneously with names or prefix filters. Ignoring names and prefixes.'],
|
|
42
40
|
];
|
|
@@ -4,7 +4,7 @@ exports.codesInfo = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var c = (0, tslib_1.__importStar)(require("../constants"));
|
|
6
6
|
var warn_1 = require("./warn");
|
|
7
|
-
var READY_MSG = 'Split SDK is ready';
|
|
7
|
+
var READY_MSG = 'Split SDK client is ready';
|
|
8
8
|
exports.codesInfo = warn_1.codesWarn.concat([
|
|
9
9
|
// client status
|
|
10
10
|
[c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
|
|
@@ -27,15 +27,12 @@ exports.codesWarn = error_1.codesError.concat([
|
|
|
27
27
|
[c.WARN_NOT_EXISTENT_SPLIT, '%s: feature flag "%s" does not exist in this environment. Please double check what feature flags exist in the Split user interface.'],
|
|
28
28
|
[c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
|
|
29
29
|
[c.WARN_NOT_EXISTENT_TT, '%s: traffic type "%s" does not have any corresponding feature flag in this environment, make sure you\'re tracking your events to a valid traffic type defined in the Split user interface.'],
|
|
30
|
-
[c.WARN_FLAGSET_NOT_CONFIGURED, '%s: : you passed %s wich is not part of the configured FlagSetsFilter, ignoring Flag Set.'],
|
|
31
30
|
// initialization / settings validation
|
|
32
31
|
[c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS + ': %s integration item(s) at settings is invalid. %s'],
|
|
33
32
|
[c.WARN_SPLITS_FILTER_IGNORED, c.LOG_PREFIX_SETTINGS + ': feature flag filters have been configured but will have no effect if mode is not "%s", since synchronization is being deferred to an external tool.'],
|
|
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 ("
|
|
33
|
+
[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 ("byName" or "byPrefix") and a list of "values".'],
|
|
35
34
|
[c.WARN_SPLITS_FILTER_EMPTY, c.LOG_PREFIX_SETTINGS + ': feature flag filter configuration must be a non-empty array of filter objects.'],
|
|
36
35
|
[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
36
|
[c.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching MySegments due to an error processing %s notification: %s'],
|
|
38
37
|
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing SPLIT_UPDATE notification: %s'],
|
|
39
|
-
[c.WARN_SPLITS_FILTER_INVALID_SET, c.LOG_PREFIX_SETTINGS + ': 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
|
-
[c.WARN_SPLITS_FILTER_LOWERCASE_SET, c.LOG_PREFIX_SETTINGS + ': flag set %s should be all lowercase - converting string to lowercase.'],
|
|
41
38
|
]);
|
package/cjs/sdkClient/client.js
CHANGED
|
@@ -67,35 +67,6 @@ function clientFactory(params) {
|
|
|
67
67
|
function getTreatmentsWithConfig(key, featureFlagNames, attributes) {
|
|
68
68
|
return getTreatments(key, featureFlagNames, attributes, true);
|
|
69
69
|
}
|
|
70
|
-
function getTreatmentsByFlagSets(key, flagSetNames, attributes, withConfig, method) {
|
|
71
|
-
if (withConfig === void 0) { withConfig = false; }
|
|
72
|
-
if (method === void 0) { method = constants_1.TREATMENTS_BY_FLAGSETS; }
|
|
73
|
-
var stopTelemetryTracker = telemetryTracker.trackEval(method);
|
|
74
|
-
var wrapUp = function (evaluationResults) {
|
|
75
|
-
var queue = [];
|
|
76
|
-
var treatments = {};
|
|
77
|
-
var evaluations = evaluationResults;
|
|
78
|
-
Object.keys(evaluations).forEach(function (featureFlagName) {
|
|
79
|
-
treatments[featureFlagName] = processEvaluation(evaluations[featureFlagName], featureFlagName, key, attributes, withConfig, "getTreatmentsByFlagSets" + (withConfig ? 'WithConfig' : ''), queue);
|
|
80
|
-
});
|
|
81
|
-
impressionsTracker.track(queue, attributes);
|
|
82
|
-
stopTelemetryTracker(queue[0] && queue[0].label);
|
|
83
|
-
return treatments;
|
|
84
|
-
};
|
|
85
|
-
var evaluations = readinessManager.isReady() || readinessManager.isReadyFromCache() ?
|
|
86
|
-
(0, evaluator_1.evaluateFeaturesByFlagSets)(log, key, flagSetNames, attributes, storage) :
|
|
87
|
-
(0, utils_1.isStorageSync)(settings) ? {} : Promise.resolve({}); // Promisify if async
|
|
88
|
-
return (0, thenable_1.thenable)(evaluations) ? evaluations.then(function (res) { return wrapUp(res); }) : wrapUp(evaluations);
|
|
89
|
-
}
|
|
90
|
-
function getTreatmentsWithConfigByFlagSets(key, flagSetNames, attributes) {
|
|
91
|
-
return getTreatmentsByFlagSets(key, flagSetNames, attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSETS);
|
|
92
|
-
}
|
|
93
|
-
function getTreatmentsByFlagSet(key, flagSetName, attributes) {
|
|
94
|
-
return getTreatmentsByFlagSets(key, [flagSetName], attributes, false, constants_1.TREATMENTS_BY_FLAGSET);
|
|
95
|
-
}
|
|
96
|
-
function getTreatmentsWithConfigByFlagSet(key, flagSetName, attributes) {
|
|
97
|
-
return getTreatmentsByFlagSets(key, [flagSetName], attributes, true, constants_1.TREATMENTS_WITH_CONFIG_BY_FLAGSET);
|
|
98
|
-
}
|
|
99
70
|
// Internal function
|
|
100
71
|
function processEvaluation(evaluation, featureFlagName, key, attributes, withConfig, invokingMethodName, queue) {
|
|
101
72
|
var matchingKey = (0, key_1.getMatching)(key);
|
|
@@ -154,10 +125,6 @@ function clientFactory(params) {
|
|
|
154
125
|
getTreatmentWithConfig: getTreatmentWithConfig,
|
|
155
126
|
getTreatments: getTreatments,
|
|
156
127
|
getTreatmentsWithConfig: getTreatmentsWithConfig,
|
|
157
|
-
getTreatmentsByFlagSets: getTreatmentsByFlagSets,
|
|
158
|
-
getTreatmentsWithConfigByFlagSets: getTreatmentsWithConfigByFlagSets,
|
|
159
|
-
getTreatmentsByFlagSet: getTreatmentsByFlagSet,
|
|
160
|
-
getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
|
|
161
128
|
track: track,
|
|
162
129
|
isClientSide: false
|
|
163
130
|
};
|
|
@@ -14,10 +14,6 @@ function clientAttributesDecoration(log, client) {
|
|
|
14
14
|
var clientGetTreatmentWithConfig = client.getTreatmentWithConfig;
|
|
15
15
|
var clientGetTreatments = client.getTreatments;
|
|
16
16
|
var clientGetTreatmentsWithConfig = client.getTreatmentsWithConfig;
|
|
17
|
-
var clientGetTreatmentsByFlagSets = client.getTreatmentsByFlagSets;
|
|
18
|
-
var clientGetTreatmentsWithConfigByFlagSets = client.getTreatmentsWithConfigByFlagSets;
|
|
19
|
-
var clientGetTreatmentsByFlagSet = client.getTreatmentsByFlagSet;
|
|
20
|
-
var clientGetTreatmentsWithConfigByFlagSet = client.getTreatmentsWithConfigByFlagSet;
|
|
21
17
|
var clientTrack = client.track;
|
|
22
18
|
function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes) {
|
|
23
19
|
return clientGetTreatment(maybeKey, maybeFeatureFlagName, combineAttributes(maybeAttributes));
|
|
@@ -31,18 +27,6 @@ function clientAttributesDecoration(log, client) {
|
|
|
31
27
|
function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes) {
|
|
32
28
|
return clientGetTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, combineAttributes(maybeAttributes));
|
|
33
29
|
}
|
|
34
|
-
function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
35
|
-
return clientGetTreatmentsByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes));
|
|
36
|
-
}
|
|
37
|
-
function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
38
|
-
return clientGetTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, combineAttributes(maybeAttributes));
|
|
39
|
-
}
|
|
40
|
-
function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
41
|
-
return clientGetTreatmentsByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes));
|
|
42
|
-
}
|
|
43
|
-
function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
44
|
-
return clientGetTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, combineAttributes(maybeAttributes));
|
|
45
|
-
}
|
|
46
30
|
function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
|
|
47
31
|
return clientTrack(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties);
|
|
48
32
|
}
|
|
@@ -58,10 +42,6 @@ function clientAttributesDecoration(log, client) {
|
|
|
58
42
|
getTreatmentWithConfig: getTreatmentWithConfig,
|
|
59
43
|
getTreatments: getTreatments,
|
|
60
44
|
getTreatmentsWithConfig: getTreatmentsWithConfig,
|
|
61
|
-
getTreatmentsByFlagSets: getTreatmentsByFlagSets,
|
|
62
|
-
getTreatmentsWithConfigByFlagSets: getTreatmentsWithConfigByFlagSets,
|
|
63
|
-
getTreatmentsByFlagSet: getTreatmentsByFlagSet,
|
|
64
|
-
getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
|
|
65
45
|
track: track,
|
|
66
46
|
/**
|
|
67
47
|
* Add an attribute to client's in memory attributes storage
|
|
@@ -18,13 +18,12 @@ function clientCSDecorator(log, client, key, trafficType) {
|
|
|
18
18
|
getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key),
|
|
19
19
|
getTreatments: clientCS.getTreatments.bind(clientCS, key),
|
|
20
20
|
getTreatmentsWithConfig: clientCS.getTreatmentsWithConfig.bind(clientCS, key),
|
|
21
|
-
getTreatmentsByFlagSets: clientCS.getTreatmentsByFlagSets.bind(clientCS, key),
|
|
22
|
-
getTreatmentsWithConfigByFlagSets: clientCS.getTreatmentsWithConfigByFlagSets.bind(clientCS, key),
|
|
23
|
-
getTreatmentsByFlagSet: clientCS.getTreatmentsByFlagSet.bind(clientCS, key),
|
|
24
|
-
getTreatmentsWithConfigByFlagSet: clientCS.getTreatmentsWithConfigByFlagSet.bind(clientCS, key),
|
|
25
21
|
// Key is bound to the `track` method. Same thing happens with trafficType but only if provided
|
|
26
22
|
track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
|
|
27
|
-
|
|
23
|
+
// Not part of the public API. These properties are used to support other modules (e.g., Split Suite)
|
|
24
|
+
isClientSide: true,
|
|
25
|
+
key: key,
|
|
26
|
+
trafficType: trafficType
|
|
28
27
|
});
|
|
29
28
|
}
|
|
30
29
|
exports.clientCSDecorator = clientCSDecorator;
|
|
@@ -6,7 +6,6 @@ var inputValidation_1 = require("../utils/inputValidation");
|
|
|
6
6
|
var lang_1 = require("../utils/lang");
|
|
7
7
|
var constants_1 = require("../utils/constants");
|
|
8
8
|
var utils_1 = require("../trackers/impressionObserver/utils");
|
|
9
|
-
var splitFilters_1 = require("../utils/settingsValidation/splitFilters");
|
|
10
9
|
/**
|
|
11
10
|
* Decorator that validates the input before actually executing the client methods.
|
|
12
11
|
* We should "guard" the client here, while not polluting the "real" implementation of those methods.
|
|
@@ -17,26 +16,18 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
|
|
|
17
16
|
/**
|
|
18
17
|
* Avoid repeating this validations code
|
|
19
18
|
*/
|
|
20
|
-
function validateEvaluationParams(maybeKey, maybeFeatureFlagNameOrNames, maybeAttributes, methodName
|
|
19
|
+
function validateEvaluationParams(maybeKey, maybeFeatureFlagNameOrNames, maybeAttributes, methodName) {
|
|
21
20
|
var multi = (0, lang_1.startsWith)(methodName, 'getTreatments');
|
|
22
21
|
var key = (0, inputValidation_1.validateKey)(log, maybeKey, methodName);
|
|
23
|
-
var splitOrSplits =
|
|
24
|
-
var flagSetOrFlagSets = [];
|
|
25
|
-
if (maybeFeatureFlagNameOrNames) {
|
|
26
|
-
splitOrSplits = multi ? (0, inputValidation_1.validateSplits)(log, maybeFeatureFlagNameOrNames, methodName) : (0, inputValidation_1.validateSplit)(log, maybeFeatureFlagNameOrNames, methodName);
|
|
27
|
-
}
|
|
22
|
+
var splitOrSplits = multi ? (0, inputValidation_1.validateSplits)(log, maybeFeatureFlagNameOrNames, methodName) : (0, inputValidation_1.validateSplit)(log, maybeFeatureFlagNameOrNames, methodName);
|
|
28
23
|
var attributes = (0, inputValidation_1.validateAttributes)(log, maybeAttributes, methodName);
|
|
29
24
|
var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, methodName);
|
|
30
|
-
if (maybeFlagSetNameOrNames) {
|
|
31
|
-
flagSetOrFlagSets = (0, splitFilters_1.flagSetsAreValid)(log, methodName, maybeFlagSetNameOrNames, settings.sync.__splitFiltersValidation.groupedFilters.bySet);
|
|
32
|
-
}
|
|
33
25
|
(0, inputValidation_1.validateIfOperational)(log, readinessManager, methodName);
|
|
34
|
-
var valid = isNotDestroyed && key &&
|
|
26
|
+
var valid = isNotDestroyed && key && splitOrSplits && attributes !== false;
|
|
35
27
|
return {
|
|
36
28
|
valid: valid,
|
|
37
29
|
key: key,
|
|
38
30
|
splitOrSplits: splitOrSplits,
|
|
39
|
-
flagSetOrFlagSets: flagSetOrFlagSets,
|
|
40
31
|
attributes: attributes
|
|
41
32
|
};
|
|
42
33
|
}
|
|
@@ -85,42 +76,6 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
|
|
|
85
76
|
return wrapResult(res_2);
|
|
86
77
|
}
|
|
87
78
|
}
|
|
88
|
-
function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
89
|
-
var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsByFlagSets', maybeFlagSets);
|
|
90
|
-
if (params.valid) {
|
|
91
|
-
return client.getTreatmentsByFlagSets(params.key, params.flagSetOrFlagSets, params.attributes);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
return wrapResult({});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes) {
|
|
98
|
-
var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsWithConfigByFlagSets', maybeFlagSets);
|
|
99
|
-
if (params.valid) {
|
|
100
|
-
return client.getTreatmentsWithConfigByFlagSets(params.key, params.flagSetOrFlagSets, params.attributes);
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
return wrapResult({});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
107
|
-
var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsByFlagSet', [maybeFlagSet]);
|
|
108
|
-
if (params.valid) {
|
|
109
|
-
return client.getTreatmentsByFlagSet(params.key, params.flagSetOrFlagSets[0], params.attributes);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
return wrapResult({});
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes) {
|
|
116
|
-
var params = validateEvaluationParams(maybeKey, undefined, maybeAttributes, 'getTreatmentsWithConfigByFlagSet', [maybeFlagSet]);
|
|
117
|
-
if (params.valid) {
|
|
118
|
-
return client.getTreatmentsWithConfigByFlagSet(params.key, params.flagSetOrFlagSets[0], params.attributes);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
return wrapResult({});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
79
|
function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
|
|
125
80
|
var key = (0, inputValidation_1.validateKey)(log, maybeKey, 'track');
|
|
126
81
|
var tt = (0, inputValidation_1.validateTrafficType)(log, maybeTT, 'track');
|
|
@@ -140,10 +95,6 @@ function clientInputValidationDecorator(settings, client, readinessManager) {
|
|
|
140
95
|
getTreatmentWithConfig: getTreatmentWithConfig,
|
|
141
96
|
getTreatments: getTreatments,
|
|
142
97
|
getTreatmentsWithConfig: getTreatmentsWithConfig,
|
|
143
|
-
getTreatmentsByFlagSets: getTreatmentsByFlagSets,
|
|
144
|
-
getTreatmentsWithConfigByFlagSets: getTreatmentsWithConfigByFlagSets,
|
|
145
|
-
getTreatmentsByFlagSet: getTreatmentsByFlagSet,
|
|
146
|
-
getTreatmentsWithConfigByFlagSet: getTreatmentsWithConfigByFlagSet,
|
|
147
98
|
track: track
|
|
148
99
|
};
|
|
149
100
|
}
|
|
@@ -14,8 +14,8 @@ function buildInstanceId(key) {
|
|
|
14
14
|
}
|
|
15
15
|
var method = 'Client instantiation';
|
|
16
16
|
/**
|
|
17
|
-
* Factory of client method for the client-side API variant where TT is ignored
|
|
18
|
-
* clients don't have a
|
|
17
|
+
* Factory of client method for the client-side API variant where TT is ignored.
|
|
18
|
+
* Therefore, clients don't have a bound TT for the track method.
|
|
19
19
|
*/
|
|
20
20
|
function sdkClientMethodCSFactory(params) {
|
|
21
21
|
var storage = params.storage, syncManager = params.syncManager, sdkReadinessManager = params.sdkReadinessManager, _a = params.settings, key = _a.core.key, readyTimeout = _a.startup.readyTimeout, log = _a.log;
|
|
@@ -16,7 +16,7 @@ function buildInstanceId(key, trafficType) {
|
|
|
16
16
|
var method = 'Client instantiation';
|
|
17
17
|
/**
|
|
18
18
|
* Factory of client method for the client-side (browser) variant of the Isomorphic JS SDK,
|
|
19
|
-
* where clients can have a
|
|
19
|
+
* where clients can have a bound TT for the track method, which is provided via the settings
|
|
20
20
|
* (default client) or the client method (shared clients).
|
|
21
21
|
*/
|
|
22
22
|
function sdkClientMethodCSFactory(params) {
|
package/cjs/sdkManager/index.js
CHANGED
|
@@ -27,8 +27,7 @@ function objectToView(splitObject) {
|
|
|
27
27
|
killed: splitObject.killed,
|
|
28
28
|
changeNumber: splitObject.changeNumber || 0,
|
|
29
29
|
treatments: collectTreatments(splitObject),
|
|
30
|
-
configs: splitObject.configurations || {}
|
|
31
|
-
sets: splitObject.sets || []
|
|
30
|
+
configs: splitObject.configurations || {}
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
33
|
function objectsToViews(splitObjects) {
|
package/cjs/services/splitApi.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.splitApiFactory = void 0;
|
|
|
4
4
|
var splitHttpClient_1 = require("./splitHttpClient");
|
|
5
5
|
var objectAssign_1 = require("../utils/lang/objectAssign");
|
|
6
6
|
var constants_1 = require("../utils/constants");
|
|
7
|
-
var constants_2 = require("../logger/constants");
|
|
8
7
|
var noCacheHeaderOptions = { headers: { 'Cache-Control': 'no-cache' } };
|
|
9
8
|
function userKeyToQueryParam(userKey) {
|
|
10
9
|
return 'users=' + encodeURIComponent(userKey); // no need to check availability of `encodeURIComponent`, since it is a global highly supported.
|
|
@@ -41,12 +40,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
|
|
|
41
40
|
},
|
|
42
41
|
fetchSplitChanges: function (since, noCache, till) {
|
|
43
42
|
var url = urls.sdk + "/splitChanges?since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
|
|
44
|
-
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS))
|
|
45
|
-
.catch(function (err) {
|
|
46
|
-
if (err.statusCode === 414)
|
|
47
|
-
settings.log.error(constants_2.ERROR_TOO_MANY_SETS);
|
|
48
|
-
throw err;
|
|
49
|
-
});
|
|
43
|
+
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS));
|
|
50
44
|
},
|
|
51
45
|
fetchSegmentChanges: function (since, segmentName, noCache, till) {
|
|
52
46
|
var url = urls.sdk + "/segmentChanges/" + segmentName + "?since=" + since + (till ? '&till=' + till : '');
|
|
@@ -16,9 +16,6 @@ var KeyBuilder = /** @class */ (function () {
|
|
|
16
16
|
KeyBuilder.prototype.buildTrafficTypeKey = function (trafficType) {
|
|
17
17
|
return this.prefix + ".trafficType." + trafficType;
|
|
18
18
|
};
|
|
19
|
-
KeyBuilder.prototype.buildFlagSetKey = function (flagSet) {
|
|
20
|
-
return this.prefix + ".flagset." + flagSet;
|
|
21
|
-
};
|
|
22
19
|
KeyBuilder.prototype.buildSplitKey = function (splitName) {
|
|
23
20
|
return this.prefix + ".split." + splitName;
|
|
24
21
|
};
|
|
@@ -8,10 +8,6 @@ exports.METHOD_NAMES = {
|
|
|
8
8
|
ts: 'treatments',
|
|
9
9
|
tc: 'treatmentWithConfig',
|
|
10
10
|
tcs: 'treatmentsWithConfig',
|
|
11
|
-
tf: 'treatmentsByFlagSet',
|
|
12
|
-
tfs: 'treatmentsByFlagSets',
|
|
13
|
-
tcf: 'treatmentsWithConfigByFlagSet',
|
|
14
|
-
tcfs: 'treatmentsWithConfigByFlagSets',
|
|
15
11
|
tr: 'track'
|
|
16
12
|
};
|
|
17
13
|
var KeyBuilderSS = /** @class */ (function (_super) {
|
|
@@ -5,7 +5,6 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var AbstractSplitsCacheSync_1 = require("../AbstractSplitsCacheSync");
|
|
6
6
|
var lang_1 = require("../../utils/lang");
|
|
7
7
|
var constants_1 = require("./constants");
|
|
8
|
-
var sets_1 = require("../../utils/lang/sets");
|
|
9
8
|
/**
|
|
10
9
|
* ISplitsCacheSync implementation that stores split definitions in browser LocalStorage.
|
|
11
10
|
*/
|
|
@@ -17,12 +16,12 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
17
16
|
* @param {ISplitFiltersValidation} splitFiltersValidation
|
|
18
17
|
*/
|
|
19
18
|
function SplitsCacheInLocal(log, keys, expirationTimestamp, splitFiltersValidation) {
|
|
20
|
-
if (splitFiltersValidation === void 0) { splitFiltersValidation = { queryString: null, groupedFilters: {
|
|
19
|
+
if (splitFiltersValidation === void 0) { splitFiltersValidation = { queryString: null, groupedFilters: { byName: [], byPrefix: [] }, validFilters: [] }; }
|
|
21
20
|
var _this = _super.call(this) || this;
|
|
22
21
|
_this.log = log;
|
|
22
|
+
_this.cacheReadyButNeedsToFlush = false;
|
|
23
23
|
_this.keys = keys;
|
|
24
24
|
_this.splitFiltersValidation = splitFiltersValidation;
|
|
25
|
-
_this.flagSetsFilter = _this.splitFiltersValidation.groupedFilters.bySet;
|
|
26
25
|
_this._checkExpiration(expirationTimestamp);
|
|
27
26
|
_this._checkFilterQuery();
|
|
28
27
|
return _this;
|
|
@@ -95,9 +94,6 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
95
94
|
localStorage.setItem(splitKey, JSON.stringify(split));
|
|
96
95
|
this._incrementCounts(split);
|
|
97
96
|
this._decrementCounts(previousSplit);
|
|
98
|
-
if (previousSplit)
|
|
99
|
-
this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
|
|
100
|
-
this.addToFlagSets(split);
|
|
101
97
|
return true;
|
|
102
98
|
}
|
|
103
99
|
catch (e) {
|
|
@@ -110,8 +106,6 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
110
106
|
var split = this.getSplit(name);
|
|
111
107
|
localStorage.removeItem(this.keys.buildSplitKey(name));
|
|
112
108
|
this._decrementCounts(split);
|
|
113
|
-
if (split)
|
|
114
|
-
this.removeFromFlagSets(split.name, split.sets);
|
|
115
109
|
return true;
|
|
116
110
|
}
|
|
117
111
|
catch (e) {
|
|
@@ -124,6 +118,11 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
124
118
|
return item && JSON.parse(item);
|
|
125
119
|
};
|
|
126
120
|
SplitsCacheInLocal.prototype.setChangeNumber = function (changeNumber) {
|
|
121
|
+
// when cache is ready but using a new split query, we must clear all split data
|
|
122
|
+
if (this.cacheReadyButNeedsToFlush) {
|
|
123
|
+
this.clear();
|
|
124
|
+
this.cacheReadyButNeedsToFlush = false;
|
|
125
|
+
}
|
|
127
126
|
// when using a new split query, we must update it at the store
|
|
128
127
|
if (this.updateNewFilter) {
|
|
129
128
|
this.log.info(constants_1.LOG_PREFIX + 'Split filter query was modified. Updating cache.');
|
|
@@ -196,7 +195,7 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
196
195
|
* @override
|
|
197
196
|
*/
|
|
198
197
|
SplitsCacheInLocal.prototype.checkCache = function () {
|
|
199
|
-
return this.getChangeNumber() > -1;
|
|
198
|
+
return this.getChangeNumber() > -1 || this.cacheReadyButNeedsToFlush;
|
|
200
199
|
};
|
|
201
200
|
/**
|
|
202
201
|
* Clean Splits cache if its `lastUpdated` timestamp is older than the given `expirationTimestamp`,
|
|
@@ -212,16 +211,31 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
212
211
|
}
|
|
213
212
|
};
|
|
214
213
|
SplitsCacheInLocal.prototype._checkFilterQuery = function () {
|
|
215
|
-
var
|
|
214
|
+
var _this = this;
|
|
215
|
+
var _a = this.splitFiltersValidation, queryString = _a.queryString, groupedFilters = _a.groupedFilters;
|
|
216
216
|
var queryKey = this.keys.buildSplitsFilterQueryKey();
|
|
217
217
|
var currentQueryString = localStorage.getItem(queryKey);
|
|
218
218
|
if (currentQueryString !== queryString) {
|
|
219
219
|
try {
|
|
220
220
|
// mark cache to update the new query filter on first successful splits fetch
|
|
221
221
|
this.updateNewFilter = true;
|
|
222
|
-
// if
|
|
223
|
-
if (this.checkCache())
|
|
224
|
-
|
|
222
|
+
// if cache is ready:
|
|
223
|
+
if (this.checkCache()) {
|
|
224
|
+
// * set change number to -1, to fetch splits with -1 `since` value.
|
|
225
|
+
localStorage.setItem(this.keys.buildSplitsTillKey(), '-1');
|
|
226
|
+
// * remove from cache splits that doesn't match with the new filters
|
|
227
|
+
this.getSplitNames().forEach(function (splitName) {
|
|
228
|
+
if (queryString && (
|
|
229
|
+
// @TODO consider redefining `groupedFilters` to expose a method like `groupedFilters::filter(splitName): boolean`
|
|
230
|
+
groupedFilters.byName.indexOf(splitName) > -1 ||
|
|
231
|
+
groupedFilters.byPrefix.some(function (prefix) { return splitName.startsWith(prefix + '__'); }))) {
|
|
232
|
+
// * set `cacheReadyButNeedsToFlush` so that `checkCache` returns true (the storage is ready to be used) and the data is cleared before updating on first successful splits fetch
|
|
233
|
+
_this.cacheReadyButNeedsToFlush = true;
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
_this.removeSplit(splitName);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
225
239
|
}
|
|
226
240
|
catch (e) {
|
|
227
241
|
this.log.error(constants_1.LOG_PREFIX + e);
|
|
@@ -229,56 +243,6 @@ var SplitsCacheInLocal = /** @class */ (function (_super) {
|
|
|
229
243
|
}
|
|
230
244
|
// if the filter didn't change, nothing is done
|
|
231
245
|
};
|
|
232
|
-
SplitsCacheInLocal.prototype.getNamesByFlagSets = function (flagSets) {
|
|
233
|
-
var _this = this;
|
|
234
|
-
var toReturn = new sets_1._Set([]);
|
|
235
|
-
flagSets.forEach(function (flagSet) {
|
|
236
|
-
var flagSetKey = _this.keys.buildFlagSetKey(flagSet);
|
|
237
|
-
var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
|
|
238
|
-
if (flagSetFromLocalStorage) {
|
|
239
|
-
var flagSetCache = new sets_1._Set(JSON.parse(flagSetFromLocalStorage));
|
|
240
|
-
toReturn = (0, sets_1.returnSetsUnion)(toReturn, flagSetCache);
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
return toReturn;
|
|
244
|
-
};
|
|
245
|
-
SplitsCacheInLocal.prototype.addToFlagSets = function (featureFlag) {
|
|
246
|
-
var _this = this;
|
|
247
|
-
if (!featureFlag.sets)
|
|
248
|
-
return;
|
|
249
|
-
featureFlag.sets.forEach(function (featureFlagSet) {
|
|
250
|
-
if (_this.flagSetsFilter.length > 0 && !_this.flagSetsFilter.some(function (filterFlagSet) { return filterFlagSet === featureFlagSet; }))
|
|
251
|
-
return;
|
|
252
|
-
var flagSetKey = _this.keys.buildFlagSetKey(featureFlagSet);
|
|
253
|
-
var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
|
|
254
|
-
if (!flagSetFromLocalStorage)
|
|
255
|
-
flagSetFromLocalStorage = '[]';
|
|
256
|
-
var flagSetCache = new sets_1._Set(JSON.parse(flagSetFromLocalStorage));
|
|
257
|
-
flagSetCache.add(featureFlag.name);
|
|
258
|
-
localStorage.setItem(flagSetKey, JSON.stringify((0, sets_1.setToArray)(flagSetCache)));
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
|
-
SplitsCacheInLocal.prototype.removeFromFlagSets = function (featureFlagName, flagSets) {
|
|
262
|
-
var _this = this;
|
|
263
|
-
if (!flagSets)
|
|
264
|
-
return;
|
|
265
|
-
flagSets.forEach(function (flagSet) {
|
|
266
|
-
_this.removeNames(flagSet, featureFlagName);
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
SplitsCacheInLocal.prototype.removeNames = function (flagSetName, featureFlagName) {
|
|
270
|
-
var flagSetKey = this.keys.buildFlagSetKey(flagSetName);
|
|
271
|
-
var flagSetFromLocalStorage = localStorage.getItem(flagSetKey);
|
|
272
|
-
if (!flagSetFromLocalStorage)
|
|
273
|
-
return;
|
|
274
|
-
var flagSetCache = new sets_1._Set(JSON.parse(flagSetFromLocalStorage));
|
|
275
|
-
flagSetCache.delete(featureFlagName);
|
|
276
|
-
if (flagSetCache.size === 0) {
|
|
277
|
-
localStorage.removeItem(flagSetKey);
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
localStorage.setItem(flagSetKey, JSON.stringify((0, sets_1.setToArray)(flagSetCache)));
|
|
281
|
-
};
|
|
282
246
|
return SplitsCacheInLocal;
|
|
283
247
|
}(AbstractSplitsCacheSync_1.AbstractSplitsCacheSync));
|
|
284
248
|
exports.SplitsCacheInLocal = SplitsCacheInLocal;
|
|
@@ -46,7 +46,7 @@ function InLocalStorage(options) {
|
|
|
46
46
|
uniqueKeys: impressionsMode === constants_2.NONE ? new UniqueKeysCacheInMemoryCS_1.UniqueKeysCacheInMemoryCS() : undefined,
|
|
47
47
|
destroy: function () {
|
|
48
48
|
var _a;
|
|
49
|
-
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(
|
|
49
|
+
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory();
|
|
50
50
|
this.segments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
51
51
|
this.impressions.clear();
|
|
52
52
|
this.impressionCounts && this.impressionCounts.clear();
|
|
@@ -64,7 +64,7 @@ function InLocalStorage(options) {
|
|
|
64
64
|
events: this.events,
|
|
65
65
|
telemetry: this.telemetry,
|
|
66
66
|
destroy: function () {
|
|
67
|
-
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(
|
|
67
|
+
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory();
|
|
68
68
|
this.segments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
69
69
|
}
|
|
70
70
|
};
|
|
@@ -15,8 +15,8 @@ var UniqueKeysCacheInMemory_1 = require("./UniqueKeysCacheInMemory");
|
|
|
15
15
|
* @param params parameters required by EventsCacheSync
|
|
16
16
|
*/
|
|
17
17
|
function InMemoryStorageFactory(params) {
|
|
18
|
-
var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize,
|
|
19
|
-
var splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(
|
|
18
|
+
var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize, impressionsMode = _a.sync.impressionsMode;
|
|
19
|
+
var splits = new SplitsCacheInMemory_1.SplitsCacheInMemory();
|
|
20
20
|
var segments = new SegmentsCacheInMemory_1.SegmentsCacheInMemory();
|
|
21
21
|
var storage = {
|
|
22
22
|
splits: splits,
|
|
@@ -15,8 +15,8 @@ var UniqueKeysCacheInMemoryCS_1 = require("./UniqueKeysCacheInMemoryCS");
|
|
|
15
15
|
* @param params parameters required by EventsCacheSync
|
|
16
16
|
*/
|
|
17
17
|
function InMemoryStorageCSFactory(params) {
|
|
18
|
-
var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize,
|
|
19
|
-
var splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(
|
|
18
|
+
var _a = params.settings, _b = _a.scheduler, impressionsQueueSize = _b.impressionsQueueSize, eventsQueueSize = _b.eventsQueueSize, impressionsMode = _a.sync.impressionsMode;
|
|
19
|
+
var splits = new SplitsCacheInMemory_1.SplitsCacheInMemory();
|
|
20
20
|
var segments = new MySegmentsCacheInMemory_1.MySegmentsCacheInMemory();
|
|
21
21
|
var storage = {
|
|
22
22
|
splits: splits,
|
|
@@ -46,7 +46,7 @@ function InMemoryStorageCSFactory(params) {
|
|
|
46
46
|
telemetry: this.telemetry,
|
|
47
47
|
// Set a new splits cache to clean it for the client without affecting other clients
|
|
48
48
|
destroy: function () {
|
|
49
|
-
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory(
|
|
49
|
+
this.splits = new SplitsCacheInMemory_1.SplitsCacheInMemory();
|
|
50
50
|
this.segments.clear();
|
|
51
51
|
}
|
|
52
52
|
};
|