@splitsoftware/splitio-commons 2.12.0 → 2.12.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 +8 -1
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +3 -3
- package/cjs/evaluator/fallbackTreatmentsCalculator/index.js +21 -32
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/integrations/pluggable.js +1 -1
- package/cjs/listeners/node.js +2 -2
- package/cjs/logger/constants.js +3 -4
- package/cjs/logger/index.js +1 -1
- package/cjs/logger/messages/debug.js +1 -1
- package/cjs/logger/messages/error.js +1 -1
- package/cjs/logger/messages/info.js +2 -3
- package/cjs/logger/messages/warn.js +4 -4
- package/cjs/sdkClient/client.js +2 -3
- package/cjs/sdkClient/clientAttributesDecoration.js +3 -3
- package/cjs/sdkClient/clientInputValidation.js +36 -68
- package/cjs/sdkClient/identity.js +1 -1
- package/cjs/sdkClient/sdkClient.js +19 -7
- package/cjs/sdkFactory/index.js +8 -41
- package/cjs/services/splitApi.js +13 -13
- package/cjs/services/splitHttpClient.js +1 -1
- package/cjs/storages/KeyBuilder.js +12 -12
- package/cjs/storages/KeyBuilderCS.js +13 -13
- package/cjs/storages/KeyBuilderSS.js +15 -15
- package/cjs/storages/getRolloutPlan.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +1 -1
- package/cjs/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/ImpressionCountsCacheInRedis.js +5 -5
- package/cjs/storages/inRedis/ImpressionsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +8 -8
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +6 -6
- package/cjs/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/cjs/storages/inRedis/UniqueKeysCacheInRedis.js +3 -3
- package/cjs/storages/pluggable/EventsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/ImpressionCountsCachePluggable.js +6 -6
- package/cjs/storages/pluggable/SplitsCachePluggable.js +4 -4
- package/cjs/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/cjs/storages/pluggable/UniqueKeysCachePluggable.js +2 -2
- package/cjs/storages/pluggable/index.js +3 -3
- package/cjs/storages/pluggable/wrapperAdapter.js +1 -1
- package/cjs/storages/setRolloutPlan.js +3 -3
- package/cjs/storages/utils.js +6 -6
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerSS.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +12 -10
- package/cjs/sync/streaming/SSEClient/index.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +2 -2
- package/cjs/sync/streaming/parseUtils.js +1 -1
- package/cjs/sync/submitters/submitter.js +1 -1
- package/cjs/trackers/eventTracker.js +10 -12
- package/cjs/trackers/impressionObserver/buildKey.js +1 -1
- package/cjs/trackers/impressionsTracker.js +37 -20
- package/cjs/trackers/uniqueKeysTracker.js +1 -1
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +2 -2
- package/cjs/utils/inputValidation/eventProperties.js +1 -1
- package/cjs/utils/inputValidation/isOperational.js +1 -1
- package/cjs/utils/lang/index.js +1 -1
- package/cjs/utils/lang/sets.js +4 -4
- package/cjs/utils/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/splitFilters.js +2 -2
- package/cjs/utils/settingsValidation/url.js +5 -5
- package/esm/evaluator/condition/engineUtils.js +2 -2
- package/esm/evaluator/fallbackTreatmentsCalculator/fallbackSanitizer/index.js +3 -3
- package/esm/evaluator/fallbackTreatmentsCalculator/index.js +21 -33
- package/esm/evaluator/matchers/whitelist.js +1 -1
- package/esm/integrations/pluggable.js +1 -1
- package/esm/listeners/node.js +2 -2
- package/esm/logger/constants.js +0 -1
- package/esm/logger/index.js +1 -1
- package/esm/logger/messages/info.js +1 -2
- package/esm/logger/messages/warn.js +3 -3
- package/esm/sdkClient/client.js +3 -4
- package/esm/sdkClient/clientAttributesDecoration.js +3 -3
- package/esm/sdkClient/clientInputValidation.js +36 -68
- package/esm/sdkClient/identity.js +1 -1
- package/esm/sdkClient/sdkClient.js +20 -8
- package/esm/sdkFactory/index.js +8 -41
- package/esm/services/splitApi.js +13 -13
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/KeyBuilder.js +12 -12
- package/esm/storages/KeyBuilderCS.js +12 -12
- package/esm/storages/KeyBuilderSS.js +14 -14
- package/esm/storages/getRolloutPlan.js +1 -1
- package/esm/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/esm/storages/inRedis/EventsCacheInRedis.js +1 -1
- package/esm/storages/inRedis/ImpressionCountsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/RedisAdapter.js +7 -7
- package/esm/storages/inRedis/SplitsCacheInRedis.js +4 -4
- package/esm/storages/inRedis/TelemetryCacheInRedis.js +7 -7
- package/esm/storages/inRedis/UniqueKeysCacheInRedis.js +1 -1
- package/esm/storages/pluggable/EventsCachePluggable.js +1 -1
- package/esm/storages/pluggable/ImpressionCountsCachePluggable.js +5 -5
- package/esm/storages/pluggable/SplitsCachePluggable.js +2 -2
- package/esm/storages/pluggable/TelemetryCachePluggable.js +7 -7
- package/esm/storages/pluggable/UniqueKeysCachePluggable.js +1 -1
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/storages/pluggable/wrapperAdapter.js +1 -1
- package/esm/storages/setRolloutPlan.js +3 -3
- package/esm/storages/utils.js +6 -6
- package/esm/sync/offline/splitsParser/parseCondition.js +1 -1
- package/esm/sync/polling/pollingManagerSS.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +6 -6
- package/esm/sync/polling/updaters/splitChangesUpdater.js +12 -10
- package/esm/sync/streaming/SSEClient/index.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +2 -2
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +2 -2
- package/esm/sync/streaming/parseUtils.js +1 -1
- package/esm/sync/submitters/submitter.js +1 -1
- package/esm/trackers/eventTracker.js +10 -12
- package/esm/trackers/impressionObserver/buildKey.js +1 -1
- package/esm/trackers/impressionsTracker.js +38 -21
- package/esm/trackers/uniqueKeysTracker.js +1 -1
- package/esm/utils/inputValidation/apiKey.js +1 -1
- package/esm/utils/inputValidation/attribute.js +2 -2
- package/esm/utils/inputValidation/isOperational.js +1 -1
- package/esm/utils/lang/sets.js +4 -4
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/splitFilters.js +2 -2
- package/esm/utils/settingsValidation/url.js +5 -5
- package/package.json +6 -6
- package/src/dtos/types.ts +15 -15
- package/src/evaluator/condition/engineUtils.ts +2 -2
- package/src/evaluator/fallbackTreatmentsCalculator/index.ts +23 -41
- package/src/evaluator/matchers/whitelist.ts +2 -2
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +1 -1
- package/src/integrations/pluggable.ts +1 -1
- package/src/logger/constants.ts +0 -1
- package/src/logger/messages/info.ts +1 -2
- package/src/logger/messages/warn.ts +3 -3
- package/src/sdkClient/client.ts +3 -5
- package/src/sdkClient/clientInputValidation.ts +38 -61
- package/src/sdkClient/sdkClient.ts +20 -5
- package/src/sdkFactory/index.ts +10 -47
- package/src/sdkFactory/types.ts +6 -3
- package/src/storages/inLocalStorage/SplitsCacheInLocal.ts +1 -1
- package/src/storages/inMemory/SplitsCacheInMemory.ts +1 -1
- package/src/storages/inRedis/SplitsCacheInRedis.ts +1 -1
- package/src/storages/pluggable/SplitsCachePluggable.ts +1 -1
- package/src/storages/setRolloutPlan.ts +2 -2
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
- package/src/sync/polling/updaters/splitChangesUpdater.ts +11 -9
- package/src/trackers/eventTracker.ts +7 -10
- package/src/trackers/impressionsTracker.ts +42 -26
- package/src/trackers/types.ts +3 -1
- package/src/utils/lang/sets.ts +4 -2
- package/types/splitio.d.ts +22 -18
package/CHANGES.txt
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
2.12.2 (September 23, 2026)
|
|
2
|
+
- Updated some transitive dependencies for vulnerability fixes.
|
|
3
|
+
|
|
4
|
+
2.12.1 (June 25, 2026)
|
|
5
|
+
- Updated internal modules to handle `null` values from `/splitChanges` response.
|
|
6
|
+
- Updated some dependencies for vulnerability fixes.
|
|
7
|
+
|
|
1
8
|
2.12.0 (February 24, 2026)
|
|
2
|
-
- Added support for ioredis v5.
|
|
9
|
+
- Added support for ioredis v5 (Related to issue https://github.com/splitio/javascript-commons/issues/471).
|
|
3
10
|
|
|
4
11
|
2.11.0 (January 28, 2026)
|
|
5
12
|
- Added functionality to provide metadata alongside SDK update and READY events. Read more in our docs.
|
|
@@ -16,10 +16,10 @@ exports.getTreatment = getTreatment;
|
|
|
16
16
|
/**
|
|
17
17
|
* Evaluates the traffic allocation to see if we should apply rollout conditions or not.
|
|
18
18
|
*/
|
|
19
|
-
function shouldApplyRollout(trafficAllocation,
|
|
19
|
+
function shouldApplyRollout(trafficAllocation, bucketingKey, trafficAllocationSeed) {
|
|
20
20
|
// For rollout, if traffic allocation for splits is 100%, we don't need to filter it because everything should evaluate the rollout.
|
|
21
21
|
if (trafficAllocation < 100) {
|
|
22
|
-
var _bucket = (0, murmur3_1.bucket)(
|
|
22
|
+
var _bucket = (0, murmur3_1.bucket)(bucketingKey, trafficAllocationSeed);
|
|
23
23
|
if (_bucket > trafficAllocation) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
@@ -24,7 +24,7 @@ function sanitizeGlobal(logger, treatment) {
|
|
|
24
24
|
if (treatment === undefined)
|
|
25
25
|
return undefined;
|
|
26
26
|
if (!isValidTreatment(treatment)) {
|
|
27
|
-
logger.error("Fallback treatments - Discarded fallback: "
|
|
27
|
+
logger.error("Fallback treatments - Discarded fallback: ".concat(FallbackDiscardReason.Treatment));
|
|
28
28
|
return undefined;
|
|
29
29
|
}
|
|
30
30
|
return treatment;
|
|
@@ -36,11 +36,11 @@ function sanitizeByFlag(logger, byFlagFallbacks) {
|
|
|
36
36
|
Object.keys(byFlagFallbacks).forEach(function (flag) {
|
|
37
37
|
var t = byFlagFallbacks[flag];
|
|
38
38
|
if (!isValidFlagName(flag)) {
|
|
39
|
-
logger.error("Fallback treatments - Discarded flag '"
|
|
39
|
+
logger.error("Fallback treatments - Discarded flag '".concat(flag, "': ").concat(FallbackDiscardReason.FlagName));
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
if (!isValidTreatment(t)) {
|
|
43
|
-
logger.error("Fallback treatments - Discarded treatment for flag '"
|
|
43
|
+
logger.error("Fallback treatments - Discarded treatment for flag '".concat(flag, "': ").concat(FallbackDiscardReason.Treatment));
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
sanitizedByFlag[flag] = t;
|
|
@@ -4,40 +4,29 @@ exports.FallbackTreatmentsCalculator = exports.FALLBACK_PREFIX = void 0;
|
|
|
4
4
|
var constants_1 = require("../../utils/constants");
|
|
5
5
|
var lang_1 = require("../../utils/lang");
|
|
6
6
|
exports.FALLBACK_PREFIX = 'fallback - ';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.fallbacks = fallbacks;
|
|
11
|
-
}
|
|
12
|
-
FallbackTreatmentsCalculator.prototype.resolve = function (flagName, label) {
|
|
7
|
+
function FallbackTreatmentsCalculator(fallbacks) {
|
|
8
|
+
if (fallbacks === void 0) { fallbacks = {}; }
|
|
9
|
+
return function (flagName, label) {
|
|
13
10
|
var _a;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
treatment: fallback,
|
|
11
|
+
if (label === void 0) { label = ''; }
|
|
12
|
+
var fallback = ((_a = fallbacks.byFlag) === null || _a === void 0 ? void 0 : _a[flagName]) || fallbacks.global;
|
|
13
|
+
return fallback ?
|
|
14
|
+
(0, lang_1.isString)(fallback) ?
|
|
15
|
+
{
|
|
16
|
+
treatment: fallback,
|
|
17
|
+
config: null,
|
|
18
|
+
label: "".concat(exports.FALLBACK_PREFIX).concat(label),
|
|
19
|
+
} :
|
|
20
|
+
{
|
|
21
|
+
treatment: fallback.treatment,
|
|
22
|
+
config: fallback.config,
|
|
23
|
+
label: "".concat(exports.FALLBACK_PREFIX).concat(label),
|
|
24
|
+
} :
|
|
25
|
+
{
|
|
26
|
+
treatment: constants_1.CONTROL,
|
|
31
27
|
config: null,
|
|
32
|
-
label:
|
|
28
|
+
label: label,
|
|
33
29
|
};
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
treatment: fallback.treatment,
|
|
37
|
-
config: fallback.config,
|
|
38
|
-
label: "" + exports.FALLBACK_PREFIX + label,
|
|
39
|
-
};
|
|
40
30
|
};
|
|
41
|
-
|
|
42
|
-
}());
|
|
31
|
+
}
|
|
43
32
|
exports.FallbackTreatmentsCalculator = FallbackTreatmentsCalculator;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.whitelistMatcherContext = void 0;
|
|
4
4
|
function whitelistMatcherContext(ruleAttr) {
|
|
5
|
-
var whitelistSet = new Set(ruleAttr);
|
|
5
|
+
var whitelistSet = new Set(ruleAttr || []);
|
|
6
6
|
return function whitelistMatcher(runtimeAttr) {
|
|
7
7
|
var isInWhitelist = whitelistSet.has(runtimeAttr);
|
|
8
8
|
return isInWhitelist;
|
|
@@ -16,7 +16,7 @@ function pluggableIntegrationsManagerFactory(integrations, params) {
|
|
|
16
16
|
// No need to check if `settings.integrations` is an array of functions. It was already validated
|
|
17
17
|
integrations.forEach(function (integrationFactory) {
|
|
18
18
|
var integration = integrationFactory(params);
|
|
19
|
-
if (integration
|
|
19
|
+
if (integration)
|
|
20
20
|
listeners.push(integration);
|
|
21
21
|
});
|
|
22
22
|
// If `listeners` is empty, not return a integration manager
|
package/cjs/listeners/node.js
CHANGED
|
@@ -47,13 +47,13 @@ var NodeSignalListener = /** @class */ (function () {
|
|
|
47
47
|
// eslint-disable-next-line no-undef
|
|
48
48
|
process.kill(process.pid, SIGTERM);
|
|
49
49
|
};
|
|
50
|
-
this.settings.log.debug(constants_1.LOG_PREFIX_CLEANUP
|
|
50
|
+
this.settings.log.debug("".concat(constants_1.LOG_PREFIX_CLEANUP, "Split SDK graceful shutdown after SIGTERM."));
|
|
51
51
|
var handlerResult = null;
|
|
52
52
|
try {
|
|
53
53
|
handlerResult = this.handler();
|
|
54
54
|
}
|
|
55
55
|
catch (err) {
|
|
56
|
-
this.settings.log.error(constants_1.LOG_PREFIX_CLEANUP
|
|
56
|
+
this.settings.log.error("".concat(constants_1.LOG_PREFIX_CLEANUP, "Error with Split SDK graceful shutdown: ").concat(err));
|
|
57
57
|
}
|
|
58
58
|
if ((0, thenable_1.thenable)(handlerResult)) {
|
|
59
59
|
// Always exit, even with errors. The promise is returned for UT purposes.
|
package/cjs/logger/constants.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUBMITTERS_PUSH_PAGE_HIDDEN = 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.
|
|
4
|
-
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_MEMBERSHIPS_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_FROM_CACHE = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES =
|
|
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_HTTP =
|
|
3
|
+
exports.ENGINE_VALUE_INVALID = exports.SUBMITTERS_PUSH_PAGE_HIDDEN = 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.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.ENGINE_DEFAULT = 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_RBS_UPDATE = exports.SYNC_SPLITS_UPDATE = 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.STREAMING_PARSING_MEMBERSHIPS_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_FROM_CACHE = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = 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_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_HTTP = 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.
|
|
@@ -36,7 +36,6 @@ exports.ENGINE_MATCHER_RESULT = 40;
|
|
|
36
36
|
exports.ENGINE_DEFAULT = 41;
|
|
37
37
|
exports.CLIENT_READY_FROM_CACHE = 100;
|
|
38
38
|
exports.CLIENT_READY = 101;
|
|
39
|
-
exports.IMPRESSION = 102;
|
|
40
39
|
exports.IMPRESSION_QUEUEING = 103;
|
|
41
40
|
exports.NEW_SHARED_CLIENT = 104;
|
|
42
41
|
exports.NEW_FACTORY = 105;
|
package/cjs/logger/index.js
CHANGED
|
@@ -91,7 +91,7 @@ var Logger = /** @class */ (function () {
|
|
|
91
91
|
Logger.prototype._log = function (method, msg, args) {
|
|
92
92
|
if (typeof msg === 'number') {
|
|
93
93
|
var format = this.codes.get(msg);
|
|
94
|
-
msg = format ? _sprintf(format, args) : "Message code "
|
|
94
|
+
msg = format ? _sprintf(format, args) : "Message code ".concat(msg).concat(args ? ', with args: ' + args.toString() : '');
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
97
|
if (args)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.codesDebug = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var c =
|
|
5
|
+
var c = tslib_1.__importStar(require("../constants"));
|
|
6
6
|
var info_1 = require("./info");
|
|
7
7
|
exports.codesDebug = info_1.codesInfo.concat([
|
|
8
8
|
// evaluator
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.codesError = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var c =
|
|
5
|
+
var c = tslib_1.__importStar(require("../constants"));
|
|
6
6
|
exports.codesError = [
|
|
7
7
|
// evaluator
|
|
8
8
|
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported targeting rule type found'],
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.codesInfo = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var c =
|
|
5
|
+
var c = tslib_1.__importStar(require("../constants"));
|
|
6
6
|
var warn_1 = require("./warn");
|
|
7
7
|
var READY_MSG = 'Split SDK client is ready';
|
|
8
8
|
exports.codesInfo = warn_1.codesWarn.concat([
|
|
@@ -10,8 +10,7 @@ exports.codesInfo = warn_1.codesWarn.concat([
|
|
|
10
10
|
[c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
|
|
11
11
|
[c.CLIENT_READY, READY_MSG],
|
|
12
12
|
// SDK
|
|
13
|
-
[c.
|
|
14
|
-
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing corresponding impression.'],
|
|
13
|
+
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Queueing impression. Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
|
|
15
14
|
[c.NEW_SHARED_CLIENT, 'New shared client instance created.'],
|
|
16
15
|
[c.NEW_FACTORY, 'New Split SDK instance created. %s'],
|
|
17
16
|
[c.EVENTS_TRACKER_SUCCESS, c.LOG_PREFIX_EVENTS_TRACKER + 'Successfully queued %s'],
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.codesWarn = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
var c =
|
|
5
|
+
var c = tslib_1.__importStar(require("../constants"));
|
|
6
6
|
var error_1 = require("./error");
|
|
7
7
|
exports.codesWarn = error_1.codesError.concat([
|
|
8
8
|
// evaluator
|
|
@@ -24,9 +24,9 @@ exports.codesWarn = error_1.codesError.concat([
|
|
|
24
24
|
[c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
|
|
25
25
|
[c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
|
|
26
26
|
[c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
|
|
27
|
-
[c.WARN_NOT_EXISTENT_SPLIT, '%s: feature flag "%s" does not exist in this environment. Please double check what feature flags exist in
|
|
27
|
+
[c.WARN_NOT_EXISTENT_SPLIT, '%s: feature flag "%s" does not exist in this environment. Please double check what feature flags exist in Harness FME UI.'],
|
|
28
28
|
[c.WARN_LOWERCASE_TRAFFIC_TYPE, '%s: traffic_type_name should be all lowercase - converting string to lowercase.'],
|
|
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
|
|
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 Harness FME UI.'],
|
|
30
30
|
[c.WARN_FLAGSET_NOT_CONFIGURED, '%s: you passed %s which is not part of the configured FlagSetsFilter, ignoring Flag Set.'],
|
|
31
31
|
// initialization / settings validation
|
|
32
32
|
[c.WARN_INTEGRATION_INVALID, c.LOG_PREFIX_SETTINGS + ': %s integration item(s) at settings is invalid. %s'],
|
|
@@ -38,5 +38,5 @@ exports.codesWarn = error_1.codesError.concat([
|
|
|
38
38
|
[c.STREAMING_PARSING_SPLIT_UPDATE, c.LOG_PREFIX_SYNC_STREAMING + 'Fetching SplitChanges due to an error processing %s 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.'],
|
|
41
|
-
[c.WARN_FLAGSET_WITHOUT_FLAGS, '%s: you passed %s flag set that does not contain cached feature flag names. Please double check what flag sets are in use in
|
|
41
|
+
[c.WARN_FLAGSET_WITHOUT_FLAGS, '%s: you passed %s flag set that does not contain cached feature flag names. Please double check what flag sets are in use in Harness FME UI.'],
|
|
42
42
|
]);
|
package/cjs/sdkClient/client.js
CHANGED
|
@@ -118,14 +118,13 @@ function clientFactory(params) {
|
|
|
118
118
|
var changeNumber = evaluation.changeNumber, impressionsDisabled = evaluation.impressionsDisabled;
|
|
119
119
|
var treatment = evaluation.treatment, label = evaluation.label, _a = evaluation.config, config = _a === void 0 ? null : _a;
|
|
120
120
|
if (treatment === constants_1.CONTROL) {
|
|
121
|
-
var fallbackTreatment = fallbackTreatmentsCalculator
|
|
121
|
+
var fallbackTreatment = fallbackTreatmentsCalculator(featureFlagName, label);
|
|
122
122
|
treatment = fallbackTreatment.treatment;
|
|
123
123
|
label = fallbackTreatment.label;
|
|
124
124
|
config = fallbackTreatment.config;
|
|
125
125
|
}
|
|
126
|
-
log.info(constants_2.IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
|
|
127
126
|
if ((0, splitExistence_1.validateSplitExistence)(log, readinessManager, featureFlagName, label, invokingMethodName)) {
|
|
128
|
-
log.info(constants_2.IMPRESSION_QUEUEING);
|
|
127
|
+
log.info(constants_2.IMPRESSION_QUEUEING, [featureFlagName, matchingKey, treatment, label]);
|
|
129
128
|
queue.push({
|
|
130
129
|
imp: {
|
|
131
130
|
feature: featureFlagName,
|
|
@@ -69,7 +69,7 @@ function clientAttributesDecoration(log, client) {
|
|
|
69
69
|
attribute[attributeName] = attributeValue;
|
|
70
70
|
if (!(0, attributes_1.validateAttributesDeep)(log, attribute, 'setAttribute'))
|
|
71
71
|
return false;
|
|
72
|
-
log.debug("stored "
|
|
72
|
+
log.debug("stored ".concat(attributeValue, " for attribute ").concat(attributeName));
|
|
73
73
|
return attributeStorage.setAttribute(attributeName, attributeValue);
|
|
74
74
|
},
|
|
75
75
|
/**
|
|
@@ -79,7 +79,7 @@ function clientAttributesDecoration(log, client) {
|
|
|
79
79
|
* @returns Attribute with the given name
|
|
80
80
|
*/
|
|
81
81
|
getAttribute: function (attributeName) {
|
|
82
|
-
log.debug("retrieved attribute "
|
|
82
|
+
log.debug("retrieved attribute ".concat(attributeName));
|
|
83
83
|
return attributeStorage.getAttribute(attributeName + '');
|
|
84
84
|
},
|
|
85
85
|
/**
|
|
@@ -108,7 +108,7 @@ function clientAttributesDecoration(log, client) {
|
|
|
108
108
|
* @returns true if attribute was removed and false otherways
|
|
109
109
|
*/
|
|
110
110
|
removeAttribute: function (attributeName) {
|
|
111
|
-
log.debug("removed attribute "
|
|
111
|
+
log.debug("removed attribute ".concat(attributeName));
|
|
112
112
|
return attributeStorage.removeAttribute(attributeName + '');
|
|
113
113
|
},
|
|
114
114
|
/**
|
|
@@ -37,97 +37,68 @@ function clientInputValidationDecorator(settings, client, readinessManager, fall
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
function evaluateFallBackTreatment(featureFlagName, withConfig) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return
|
|
40
|
+
if (Array.isArray(featureFlagName)) {
|
|
41
|
+
var res_1 = {};
|
|
42
|
+
featureFlagName.forEach(function (split) { return res_1[split] = evaluateFallBackTreatment(split, withConfig); });
|
|
43
|
+
return res_1;
|
|
44
|
+
}
|
|
45
|
+
var _a = fallbackTreatmentsCalculator(featureFlagName), treatment = _a.treatment, config = _a.config;
|
|
46
|
+
return withConfig ?
|
|
47
|
+
{
|
|
43
48
|
treatment: treatment,
|
|
44
49
|
config: config
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
return treatment;
|
|
50
|
+
} : treatment;
|
|
48
51
|
}
|
|
49
52
|
function wrapResult(value) {
|
|
50
53
|
return isAsync ? Promise.resolve(value) : value;
|
|
51
54
|
}
|
|
52
55
|
function getTreatment(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
|
|
53
56
|
var params = validateEvaluationParams(constants_1.GET_TREATMENT, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
else {
|
|
58
|
-
var result = evaluateFallBackTreatment(params.nameOrNames, false);
|
|
59
|
-
return wrapResult(result);
|
|
60
|
-
}
|
|
57
|
+
return params.valid ?
|
|
58
|
+
client.getTreatment(params.key, params.nameOrNames, params.attributes, params.options) :
|
|
59
|
+
wrapResult(evaluateFallBackTreatment(params.nameOrNames, false));
|
|
61
60
|
}
|
|
62
61
|
function getTreatmentWithConfig(maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions) {
|
|
63
62
|
var params = validateEvaluationParams(constants_1.GET_TREATMENT_WITH_CONFIG, maybeKey, maybeFeatureFlagName, maybeAttributes, maybeOptions);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
else {
|
|
68
|
-
var result = evaluateFallBackTreatment(params.nameOrNames, true);
|
|
69
|
-
return wrapResult(result);
|
|
70
|
-
}
|
|
63
|
+
return params.valid ?
|
|
64
|
+
client.getTreatmentWithConfig(params.key, params.nameOrNames, params.attributes, params.options) :
|
|
65
|
+
wrapResult(evaluateFallBackTreatment(params.nameOrNames, true));
|
|
71
66
|
}
|
|
72
67
|
function getTreatments(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
|
|
73
68
|
var params = validateEvaluationParams(constants_1.GET_TREATMENTS, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
else {
|
|
78
|
-
var res_1 = {};
|
|
79
|
-
if (params.nameOrNames)
|
|
80
|
-
params.nameOrNames.forEach(function (split) { return res_1[split] = evaluateFallBackTreatment(split, false); });
|
|
81
|
-
return wrapResult(res_1);
|
|
82
|
-
}
|
|
69
|
+
return params.valid ?
|
|
70
|
+
client.getTreatments(params.key, params.nameOrNames, params.attributes, params.options) :
|
|
71
|
+
wrapResult(evaluateFallBackTreatment(params.nameOrNames || [], false));
|
|
83
72
|
}
|
|
84
73
|
function getTreatmentsWithConfig(maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions) {
|
|
85
74
|
var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG, maybeKey, maybeFeatureFlagNames, maybeAttributes, maybeOptions);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
else {
|
|
90
|
-
var res_2 = {};
|
|
91
|
-
if (params.nameOrNames)
|
|
92
|
-
params.nameOrNames.forEach(function (split) { return res_2[split] = evaluateFallBackTreatment(split, true); });
|
|
93
|
-
return wrapResult(res_2);
|
|
94
|
-
}
|
|
75
|
+
return params.valid ?
|
|
76
|
+
client.getTreatmentsWithConfig(params.key, params.nameOrNames, params.attributes, params.options) :
|
|
77
|
+
wrapResult(evaluateFallBackTreatment(params.nameOrNames || [], true));
|
|
95
78
|
}
|
|
96
79
|
function getTreatmentsByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
|
|
97
80
|
var params = validateEvaluationParams(constants_1.GET_TREATMENTS_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
else {
|
|
102
|
-
return wrapResult({});
|
|
103
|
-
}
|
|
81
|
+
return params.valid ?
|
|
82
|
+
client.getTreatmentsByFlagSets(params.key, params.nameOrNames, params.attributes, params.options) :
|
|
83
|
+
wrapResult({});
|
|
104
84
|
}
|
|
105
85
|
function getTreatmentsWithConfigByFlagSets(maybeKey, maybeFlagSets, maybeAttributes, maybeOptions) {
|
|
106
86
|
var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, maybeKey, maybeFlagSets, maybeAttributes, maybeOptions);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
else {
|
|
111
|
-
return wrapResult({});
|
|
112
|
-
}
|
|
87
|
+
return params.valid ?
|
|
88
|
+
client.getTreatmentsWithConfigByFlagSets(params.key, params.nameOrNames, params.attributes, params.options) :
|
|
89
|
+
wrapResult({});
|
|
113
90
|
}
|
|
114
91
|
function getTreatmentsByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
|
|
115
92
|
var params = validateEvaluationParams(constants_1.GET_TREATMENTS_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
else {
|
|
120
|
-
return wrapResult({});
|
|
121
|
-
}
|
|
93
|
+
return params.valid ?
|
|
94
|
+
client.getTreatmentsByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options) :
|
|
95
|
+
wrapResult({});
|
|
122
96
|
}
|
|
123
97
|
function getTreatmentsWithConfigByFlagSet(maybeKey, maybeFlagSet, maybeAttributes, maybeOptions) {
|
|
124
98
|
var params = validateEvaluationParams(constants_1.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, maybeKey, [maybeFlagSet], maybeAttributes, maybeOptions);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
else {
|
|
129
|
-
return wrapResult({});
|
|
130
|
-
}
|
|
99
|
+
return params.valid ?
|
|
100
|
+
client.getTreatmentsWithConfigByFlagSet(params.key, params.nameOrNames[0], params.attributes, params.options) :
|
|
101
|
+
wrapResult({});
|
|
131
102
|
}
|
|
132
103
|
function track(maybeKey, maybeTT, maybeEvent, maybeEventValue, maybeProperties) {
|
|
133
104
|
var key = (0, inputValidation_1.validateKey)(log, maybeKey, constants_1.TRACK_FN_LABEL);
|
|
@@ -136,12 +107,9 @@ function clientInputValidationDecorator(settings, client, readinessManager, fall
|
|
|
136
107
|
var eventValue = (0, inputValidation_1.validateEventValue)(log, maybeEventValue, constants_1.TRACK_FN_LABEL);
|
|
137
108
|
var _a = (0, inputValidation_1.validateEventProperties)(log, maybeProperties, constants_1.TRACK_FN_LABEL), properties = _a.properties, size = _a.size;
|
|
138
109
|
var isNotDestroyed = (0, inputValidation_1.validateIfNotDestroyed)(log, readinessManager, constants_1.TRACK_FN_LABEL);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
else {
|
|
143
|
-
return isAsync ? Promise.resolve(false) : false;
|
|
144
|
-
}
|
|
110
|
+
return isNotDestroyed && key && tt && event && eventValue !== false && properties !== false ? // @ts-expect-error
|
|
111
|
+
client.track(key, tt, event, eventValue, properties, size) :
|
|
112
|
+
wrapResult(false);
|
|
145
113
|
}
|
|
146
114
|
return {
|
|
147
115
|
getTreatment: getTreatment,
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildInstanceId = void 0;
|
|
4
4
|
function buildInstanceId(key, trafficType) {
|
|
5
|
-
return (key.matchingKey ? key.matchingKey : key
|
|
5
|
+
return "".concat(key.matchingKey ? key.matchingKey : key, "-").concat(key.bucketingKey ? key.bucketingKey : key, "-").concat(trafficType ? trafficType : '');
|
|
6
6
|
}
|
|
7
7
|
exports.buildInstanceId = buildInstanceId;
|
|
@@ -7,10 +7,11 @@ var client_1 = require("./client");
|
|
|
7
7
|
var clientInputValidation_1 = require("./clientInputValidation");
|
|
8
8
|
var COOLDOWN_TIME_IN_MILLIS = 1000;
|
|
9
9
|
/**
|
|
10
|
-
* Creates an Sdk client, i.e., a base client with status and destroy interface
|
|
10
|
+
* Creates an Sdk client, i.e., a base client with status, init, flush and destroy interface
|
|
11
11
|
*/
|
|
12
12
|
function sdkClientFactory(params, isSharedClient) {
|
|
13
|
-
var sdkReadinessManager = params.sdkReadinessManager, syncManager = params.syncManager, storage = params.storage, signalListener = params.signalListener, settings = params.settings, telemetryTracker = params.telemetryTracker,
|
|
13
|
+
var sdkReadinessManager = params.sdkReadinessManager, syncManager = params.syncManager, storage = params.storage, signalListener = params.signalListener, settings = params.settings, telemetryTracker = params.telemetryTracker, impressionsTracker = params.impressionsTracker;
|
|
14
|
+
var hasInit = false;
|
|
14
15
|
var lastActionTime = 0;
|
|
15
16
|
function __cooldown(func, time) {
|
|
16
17
|
var now = Date.now();
|
|
@@ -19,7 +20,7 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
19
20
|
//check if the time elapsed is less than desired cooldown
|
|
20
21
|
if (timeElapsed < time) {
|
|
21
22
|
//if yes, return message with remaining time in seconds
|
|
22
|
-
settings.log.warn("Flush cooldown, remaining time "
|
|
23
|
+
settings.log.warn("Flush cooldown, remaining time ".concat((time - timeElapsed) / 1000, " seconds"));
|
|
23
24
|
return Promise.resolve();
|
|
24
25
|
}
|
|
25
26
|
else {
|
|
@@ -35,14 +36,25 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
35
36
|
// Proto-linkage of the readiness Event Emitter
|
|
36
37
|
Object.create(sdkReadinessManager.sdkStatus),
|
|
37
38
|
// Client API (getTreatment* & track methods)
|
|
38
|
-
(0, clientInputValidation_1.clientInputValidationDecorator)(settings, (0, client_1.clientFactory)(params), sdkReadinessManager.readinessManager, params.fallbackTreatmentsCalculator),
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
(0, clientInputValidation_1.clientInputValidationDecorator)(settings, (0, client_1.clientFactory)(params), sdkReadinessManager.readinessManager, params.fallbackTreatmentsCalculator), {
|
|
40
|
+
init: function () {
|
|
41
|
+
if (hasInit)
|
|
42
|
+
return;
|
|
43
|
+
hasInit = true;
|
|
44
|
+
if (!isSharedClient) {
|
|
45
|
+
(0, apiKey_1.validateAndTrackApiKey)(settings.log, settings.core.authorizationKey);
|
|
46
|
+
sdkReadinessManager.readinessManager.init();
|
|
47
|
+
impressionsTracker.start();
|
|
48
|
+
syncManager && syncManager.start();
|
|
49
|
+
signalListener && signalListener.start();
|
|
50
|
+
}
|
|
51
|
+
},
|
|
41
52
|
flush: function () {
|
|
42
53
|
// @TODO define cooldown time
|
|
43
54
|
return __cooldown(__flush, COOLDOWN_TIME_IN_MILLIS);
|
|
44
55
|
},
|
|
45
56
|
destroy: function () {
|
|
57
|
+
hasInit = false;
|
|
46
58
|
// Mark the SDK as destroyed immediately
|
|
47
59
|
sdkReadinessManager.readinessManager.destroy();
|
|
48
60
|
// For main client, cleanup the SDK Key, listeners and scheduled jobs, and record stat before flushing data
|
|
@@ -50,7 +62,7 @@ function sdkClientFactory(params, isSharedClient) {
|
|
|
50
62
|
(0, apiKey_1.releaseApiKey)(settings.core.authorizationKey);
|
|
51
63
|
telemetryTracker.sessionLength();
|
|
52
64
|
signalListener && signalListener.stop();
|
|
53
|
-
|
|
65
|
+
impressionsTracker.stop();
|
|
54
66
|
}
|
|
55
67
|
// Stop background jobs
|
|
56
68
|
syncManager && syncManager.stop();
|