@splitsoftware/splitio-commons 1.2.1-rc.0 → 1.2.1-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/evaluator/Engine.js +6 -6
- package/cjs/evaluator/combiners/and.js +1 -1
- package/cjs/evaluator/combiners/ifelseif.js +2 -2
- package/cjs/evaluator/condition/engineUtils.js +2 -2
- package/cjs/evaluator/condition/index.js +4 -4
- package/cjs/evaluator/index.js +5 -5
- package/cjs/evaluator/matchers/cont_all.js +1 -1
- package/cjs/evaluator/matchers/cont_any.js +1 -1
- package/cjs/evaluator/matchers/cont_str.js +1 -1
- package/cjs/evaluator/matchers/dependency.js +1 -1
- package/cjs/evaluator/matchers/eq_set.js +1 -1
- package/cjs/evaluator/matchers/ew.js +3 -3
- package/cjs/evaluator/matchers/part_of.js +1 -1
- package/cjs/evaluator/matchers/segment.js +1 -1
- package/cjs/evaluator/matchers/sw.js +1 -1
- package/cjs/evaluator/matchers/whitelist.js +1 -1
- package/cjs/evaluator/matchersTransform/index.js +12 -12
- package/cjs/evaluator/parser/index.js +6 -6
- package/cjs/evaluator/treatments/index.js +1 -1
- package/cjs/evaluator/value/index.js +1 -1
- package/cjs/evaluator/value/sanitize.js +4 -4
- package/cjs/integrations/browser.js +3 -3
- package/cjs/integrations/ga/GaToSplit.js +14 -14
- package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +5 -3
- package/cjs/integrations/ga/SplitToGa.js +1 -1
- package/cjs/integrations/ga/SplitToGoogleAnalytics.js +4 -2
- package/cjs/listeners/browser.js +15 -11
- package/cjs/listeners/node.js +1 -1
- package/cjs/logger/constants.js +9 -3
- package/cjs/logger/index.js +2 -2
- package/cjs/logger/messages/debug.js +4 -4
- package/cjs/logger/messages/error.js +5 -4
- package/cjs/logger/messages/info.js +8 -5
- package/cjs/logger/messages/warn.js +1 -1
- package/cjs/logger/sdkLogger.js +1 -1
- package/cjs/readiness/readinessManager.js +2 -2
- package/cjs/readiness/sdkReadinessManager.js +4 -4
- package/cjs/sdkClient/client.js +12 -11
- package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
- package/cjs/sdkClient/clientCS.js +3 -3
- package/cjs/sdkClient/clientInputValidation.js +20 -22
- package/cjs/sdkClient/sdkClient.js +3 -6
- package/cjs/sdkClient/sdkClientMethod.js +1 -1
- package/cjs/sdkClient/sdkClientMethodCS.js +6 -10
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +7 -15
- package/cjs/sdkFactory/index.js +14 -12
- package/cjs/sdkFactory/userConsentProps.js +40 -0
- package/cjs/sdkManager/index.js +11 -11
- package/cjs/services/splitApi.js +3 -2
- package/cjs/services/splitHttpClient.js +2 -2
- package/cjs/storages/KeyBuilder.js +2 -6
- package/cjs/storages/KeyBuilderCS.js +13 -3
- package/cjs/storages/KeyBuilderSS.js +1 -1
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +24 -4
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
- package/cjs/storages/inLocalStorage/index.js +4 -4
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
- package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
- package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/cjs/storages/inMemory/LatenciesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -2
- package/cjs/storages/inMemory/SplitsCacheInMemory.js +5 -5
- package/cjs/storages/inRedis/LatenciesCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/RedisAdapter.js +24 -11
- package/cjs/storages/inRedis/SegmentsCacheInRedis.js +1 -1
- package/cjs/storages/inRedis/SplitsCacheInRedis.js +3 -3
- package/cjs/storages/inRedis/index.js +1 -1
- package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
- package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
- package/cjs/storages/pluggable/inMemoryWrapper.js +4 -4
- package/cjs/storages/pluggable/index.js +6 -6
- package/cjs/sync/offline/LocalhostFromFile.js +1 -1
- package/cjs/sync/offline/LocalhostFromObject.js +1 -1
- package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
- package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +13 -13
- package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +3 -3
- package/cjs/sync/offline/syncManagerOffline.js +1 -1
- package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
- package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
- package/cjs/sync/polling/pollingManagerCS.js +8 -7
- package/cjs/sync/polling/pollingManagerSS.js +5 -4
- package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +1 -1
- package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
- package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -2
- package/cjs/sync/streaming/AuthClient/index.js +3 -3
- package/cjs/sync/streaming/SSEClient/index.js +2 -1
- package/cjs/sync/streaming/SSEHandler/NotificationParser.js +1 -1
- package/cjs/sync/streaming/SSEHandler/index.js +3 -3
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/cjs/sync/streaming/mySegmentsV2utils.js +1 -1
- package/cjs/sync/streaming/pushManager.js +27 -19
- package/cjs/sync/submitters/eventsSyncTask.js +17 -5
- package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionsSyncTask.js +15 -3
- package/cjs/sync/submitters/metricsSyncTask.js +3 -3
- package/cjs/sync/submitters/submitterManager.js +6 -5
- package/cjs/sync/submitters/submitterSyncTask.js +1 -1
- package/cjs/sync/syncManagerOnline.js +14 -15
- package/cjs/trackers/eventTracker.js +11 -4
- package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
- package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
- package/cjs/trackers/impressionObserver/utils.js +8 -1
- package/cjs/trackers/impressionsTracker.js +9 -8
- package/cjs/utils/MinEvents.js +2 -1
- package/cjs/utils/consent.js +10 -0
- package/cjs/utils/constants/index.js +5 -1
- package/cjs/utils/inputValidation/apiKey.js +1 -1
- package/cjs/utils/inputValidation/attribute.js +4 -4
- package/cjs/utils/inputValidation/attributes.js +2 -2
- package/cjs/utils/inputValidation/event.js +1 -1
- package/cjs/utils/inputValidation/eventProperties.js +7 -5
- package/cjs/utils/inputValidation/eventValue.js +1 -1
- package/cjs/utils/inputValidation/key.js +6 -5
- package/cjs/utils/inputValidation/preloadedData.js +8 -8
- package/cjs/utils/inputValidation/split.js +1 -1
- package/cjs/utils/inputValidation/splits.js +2 -2
- package/cjs/utils/inputValidation/trafficType.js +1 -1
- package/cjs/utils/inputValidation/trafficTypeExistance.js +1 -1
- package/cjs/utils/jwt/index.js +1 -1
- package/cjs/utils/key/index.js +3 -3
- package/cjs/utils/lang/index.js +13 -16
- package/cjs/utils/lang/maps.js +16 -2
- package/cjs/utils/murmur3/common.js +1 -1
- package/cjs/utils/murmur3/murmur3.js +10 -10
- package/cjs/utils/murmur3/murmur3_128.js +1 -1
- package/cjs/utils/murmur3/murmur3_128_x86.js +37 -37
- package/cjs/utils/murmur3/murmur3_64.js +1 -1
- package/cjs/utils/settingsValidation/consent.js +16 -0
- package/cjs/utils/settingsValidation/impressionsMode.js +6 -6
- package/cjs/utils/settingsValidation/index.js +32 -14
- package/cjs/utils/settingsValidation/integrations/configurable.js +1 -1
- package/cjs/utils/settingsValidation/integrations/pluggable.js +1 -1
- package/cjs/utils/settingsValidation/localhost/builtin.js +2 -2
- package/cjs/utils/settingsValidation/logger/builtinLogger.js +3 -3
- package/cjs/utils/settingsValidation/logger/commons.js +1 -1
- package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
- package/cjs/utils/settingsValidation/runtime.js +11 -0
- package/cjs/utils/settingsValidation/splitFilters.js +1 -1
- package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
- package/cjs/utils/timeTracker/index.js +3 -3
- package/esm/evaluator/matchers/ew.js +4 -4
- package/esm/integrations/ga/GoogleAnalyticsToSplit.js +4 -2
- package/esm/integrations/ga/SplitToGoogleAnalytics.js +4 -2
- package/esm/listeners/browser.js +14 -10
- package/esm/logger/constants.js +6 -2
- package/esm/logger/messages/debug.js +3 -3
- package/esm/logger/messages/error.js +4 -3
- package/esm/logger/messages/info.js +7 -4
- package/esm/sdkClient/client.js +3 -2
- package/esm/sdkClient/clientCS.js +1 -1
- package/esm/sdkClient/clientInputValidation.js +6 -8
- package/esm/sdkClient/sdkClient.js +1 -4
- package/esm/sdkClient/sdkClientMethodCS.js +1 -5
- package/esm/sdkClient/sdkClientMethodCSWithTT.js +1 -9
- package/esm/sdkFactory/index.js +8 -6
- package/esm/sdkFactory/userConsentProps.js +36 -0
- package/esm/services/splitApi.js +2 -1
- package/esm/storages/KeyBuilder.js +2 -6
- package/esm/storages/KeyBuilderCS.js +11 -1
- package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +23 -3
- package/esm/storages/inLocalStorage/index.js +1 -1
- package/esm/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
- package/esm/storages/inMemory/InMemoryStorage.js +1 -1
- package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +15 -2
- package/esm/storages/pluggable/index.js +2 -2
- package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
- package/esm/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +2 -2
- package/esm/sync/polling/pollingManagerCS.js +2 -1
- package/esm/sync/polling/pollingManagerSS.js +2 -1
- package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
- package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
- package/esm/sync/streaming/SSEClient/index.js +2 -1
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/esm/sync/streaming/pushManager.js +13 -5
- package/esm/sync/submitters/eventsSyncTask.js +18 -6
- package/esm/sync/submitters/impressionsSyncTask.js +13 -1
- package/esm/sync/submitters/submitterManager.js +2 -1
- package/esm/sync/syncManagerOnline.js +14 -15
- package/esm/trackers/eventTracker.js +8 -1
- package/esm/trackers/impressionObserver/utils.js +7 -1
- package/esm/trackers/impressionsTracker.js +6 -5
- package/esm/utils/consent.js +6 -0
- package/esm/utils/constants/index.js +4 -0
- package/esm/utils/inputValidation/attributes.js +1 -1
- package/esm/utils/inputValidation/eventProperties.js +4 -2
- package/esm/utils/inputValidation/key.js +2 -1
- package/esm/utils/lang/index.js +12 -15
- package/esm/utils/lang/maps.js +14 -1
- package/esm/utils/settingsValidation/consent.js +12 -0
- package/esm/utils/settingsValidation/impressionsMode.js +7 -7
- package/esm/utils/settingsValidation/index.js +28 -10
- package/esm/utils/settingsValidation/runtime.js +7 -0
- package/package.json +6 -6
- package/src/evaluator/matchers/ew.ts +4 -4
- package/src/evaluator/parser/index.ts +1 -1
- package/src/evaluator/types.ts +2 -2
- package/src/evaluator/value/index.ts +2 -2
- package/src/evaluator/value/sanitize.ts +2 -2
- package/src/integrations/ga/GoogleAnalyticsToSplit.ts +7 -4
- package/src/integrations/ga/SplitToGoogleAnalytics.ts +7 -4
- package/src/integrations/pluggable.ts +2 -2
- package/src/integrations/types.ts +5 -0
- package/src/listeners/browser.ts +13 -9
- package/src/logger/constants.ts +6 -2
- package/src/logger/messages/debug.ts +3 -3
- package/src/logger/messages/error.ts +4 -3
- package/src/logger/messages/info.ts +7 -4
- package/src/logger/types.ts +4 -0
- package/src/sdkClient/client.ts +3 -2
- package/src/sdkClient/clientCS.ts +1 -1
- package/src/sdkClient/clientInputValidation.ts +8 -7
- package/src/sdkClient/sdkClient.ts +2 -5
- package/src/sdkClient/sdkClientMethodCS.ts +1 -6
- package/src/sdkClient/sdkClientMethodCSWithTT.ts +2 -11
- package/src/sdkFactory/index.ts +9 -7
- package/src/sdkFactory/types.ts +2 -1
- package/src/sdkFactory/userConsentProps.ts +42 -0
- package/src/storages/KeyBuilder.ts +2 -6
- package/src/storages/KeyBuilderCS.ts +13 -1
- package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +23 -3
- package/src/storages/inLocalStorage/index.ts +1 -1
- package/src/storages/inMemory/ImpressionsCacheInMemory.ts +22 -1
- package/src/storages/inMemory/InMemoryStorage.ts +1 -1
- package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
- package/src/storages/inRedis/RedisAdapter.ts +8 -2
- package/src/storages/pluggable/index.ts +2 -2
- package/src/storages/types.ts +6 -2
- package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
- package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -1
- package/src/sync/polling/fetchers/types.ts +1 -0
- package/src/sync/polling/pollingManagerCS.ts +3 -6
- package/src/sync/polling/pollingManagerSS.ts +3 -8
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +2 -1
- package/src/sync/polling/types.ts +0 -12
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -1
- package/src/sync/streaming/SSEClient/index.ts +2 -1
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
- package/src/sync/streaming/pushManager.ts +19 -16
- package/src/sync/streaming/types.ts +5 -25
- package/src/sync/submitters/eventsSyncTask.ts +19 -6
- package/src/sync/submitters/impressionsSyncTask.ts +16 -1
- package/src/sync/submitters/submitterManager.ts +4 -8
- package/src/sync/syncManagerOnline.ts +20 -24
- package/src/sync/types.ts +4 -1
- package/src/trackers/eventTracker.ts +11 -3
- package/src/trackers/impressionObserver/utils.ts +8 -1
- package/src/trackers/impressionsTracker.ts +7 -8
- package/src/types.ts +22 -1
- package/src/utils/consent.ts +8 -0
- package/src/utils/constants/index.ts +5 -0
- package/src/utils/inputValidation/attributes.ts +1 -2
- package/src/utils/inputValidation/eventProperties.ts +4 -2
- package/src/utils/lang/index.ts +15 -18
- package/src/utils/lang/maps.ts +15 -1
- package/src/utils/settingsValidation/consent.ts +16 -0
- package/src/utils/settingsValidation/impressionsMode.ts +8 -8
- package/src/utils/settingsValidation/index.ts +29 -10
- package/src/utils/settingsValidation/runtime.ts +9 -0
- package/src/utils/settingsValidation/types.ts +12 -6
- package/types/evaluator/types.d.ts +2 -2
- package/types/evaluator/value/index.d.ts +1 -1
- package/types/evaluator/value/sanitize.d.ts +1 -1
- package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +2 -2
- package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +2 -3
- package/types/integrations/types.d.ts +4 -0
- package/types/logger/constants.d.ts +6 -2
- package/types/logger/types.d.ts +4 -0
- package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
- package/types/sdkClient/clientInputValidation.d.ts +2 -3
- package/types/sdkFactory/types.d.ts +1 -1
- package/types/sdkFactory/userConsentProps.d.ts +6 -0
- package/types/storages/KeyBuilderCS.d.ts +2 -0
- package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +9 -0
- package/types/storages/inMemory/index.d.ts +10 -0
- package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
- package/types/storages/parseSegments.d.ts +6 -0
- package/types/storages/types.d.ts +3 -1
- package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +1 -1
- package/types/sync/polling/fetchers/types.d.ts +1 -1
- package/types/sync/polling/pollingManagerCS.d.ts +2 -5
- package/types/sync/polling/pollingManagerSS.d.ts +2 -5
- package/types/sync/polling/types.d.ts +0 -11
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
- package/types/sync/streaming/pushManager.d.ts +3 -7
- package/types/sync/streaming/pushManagerCS.d.ts +1 -12
- package/types/sync/streaming/pushManagerSS.d.ts +1 -11
- package/types/sync/streaming/types.d.ts +3 -23
- package/types/sync/submitters/submitterManager.d.ts +2 -4
- package/types/sync/syncManagerOnline.d.ts +3 -3
- package/types/sync/types.d.ts +3 -0
- package/types/trackers/eventTracker.d.ts +2 -2
- package/types/trackers/impressionObserver/utils.d.ts +4 -0
- package/types/trackers/impressionsTracker.d.ts +2 -3
- package/types/types.d.ts +22 -1
- package/types/utils/consent.d.ts +2 -0
- package/types/utils/constants/index.d.ts +3 -0
- package/types/utils/lang/index.d.ts +6 -5
- package/types/utils/lang/maps.d.ts +7 -0
- package/types/utils/settingsValidation/consent.d.ts +6 -0
- package/types/utils/settingsValidation/impressionsMode.d.ts +1 -1
- package/types/utils/settingsValidation/runtime/browser.d.ts +2 -0
- package/types/utils/settingsValidation/runtime/node.d.ts +2 -0
- package/types/utils/settingsValidation/runtime.d.ts +2 -0
- package/types/utils/settingsValidation/types.d.ts +12 -6
- package/types/utils/settingsValidation/userConsent.d.ts +5 -0
package/cjs/evaluator/Engine.js
CHANGED
|
@@ -6,12 +6,12 @@ var lang_1 = require("../utils/lang");
|
|
|
6
6
|
var parser_1 = require("./parser");
|
|
7
7
|
var key_1 = require("../utils/key");
|
|
8
8
|
var thenable_1 = require("../utils/promise/thenable");
|
|
9
|
-
var LabelsConstants = tslib_1.__importStar(require("../utils/labels"));
|
|
9
|
+
var LabelsConstants = (0, tslib_1.__importStar)(require("../utils/labels"));
|
|
10
10
|
var constants_1 = require("../utils/constants");
|
|
11
11
|
function evaluationResult(result, defaultTreatment) {
|
|
12
12
|
return {
|
|
13
|
-
treatment: lang_1.get(result, 'treatment', defaultTreatment),
|
|
14
|
-
label: lang_1.get(result, 'label', LabelsConstants.NO_CONDITION_MATCH)
|
|
13
|
+
treatment: (0, lang_1.get)(result, 'treatment', defaultTreatment),
|
|
14
|
+
label: (0, lang_1.get)(result, 'label', LabelsConstants.NO_CONDITION_MATCH)
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
var Engine = /** @class */ (function () {
|
|
@@ -25,7 +25,7 @@ var Engine = /** @class */ (function () {
|
|
|
25
25
|
}
|
|
26
26
|
Engine.parse = function (log, splitFlatStructure, storage) {
|
|
27
27
|
var conditions = splitFlatStructure.conditions;
|
|
28
|
-
var evaluator = parser_1.parser(log, conditions, storage);
|
|
28
|
+
var evaluator = (0, parser_1.parser)(log, conditions, storage);
|
|
29
29
|
return new Engine(splitFlatStructure, evaluator);
|
|
30
30
|
};
|
|
31
31
|
Engine.prototype.getKey = function () {
|
|
@@ -37,7 +37,7 @@ var Engine = /** @class */ (function () {
|
|
|
37
37
|
var treatment;
|
|
38
38
|
var label;
|
|
39
39
|
try {
|
|
40
|
-
parsedKey = key_1.keyParser(key);
|
|
40
|
+
parsedKey = (0, key_1.keyParser)(key);
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
43
43
|
return {
|
|
@@ -57,7 +57,7 @@ var Engine = /** @class */ (function () {
|
|
|
57
57
|
var evaluation = this.evaluator(parsedKey, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator);
|
|
58
58
|
// Evaluation could be async, so we should handle that case checking for a
|
|
59
59
|
// thenable object
|
|
60
|
-
if (thenable_1.thenable(evaluation)) {
|
|
60
|
+
if ((0, thenable_1.thenable)(evaluation)) {
|
|
61
61
|
return evaluation.then(function (result) { return evaluationResult(result, defaultTreatment); });
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
@@ -18,7 +18,7 @@ function andCombinerContext(log, matchers) {
|
|
|
18
18
|
}
|
|
19
19
|
var matcherResults = matchers.map(function (matcher) { return matcher.apply(void 0, params); });
|
|
20
20
|
// If any matching result is a thenable we should use Promise.all
|
|
21
|
-
if (lang_1.findIndex(matcherResults, thenable_1.thenable) !== -1) {
|
|
21
|
+
if ((0, lang_1.findIndex)(matcherResults, thenable_1.thenable) !== -1) {
|
|
22
22
|
return Promise.all(matcherResults).then(andResults);
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
@@ -4,7 +4,7 @@ exports.ifElseIfCombinerContext = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var lang_1 = require("../../utils/lang");
|
|
6
6
|
var thenable_1 = require("../../utils/promise/thenable");
|
|
7
|
-
var LabelsConstants = tslib_1.__importStar(require("../../utils/labels"));
|
|
7
|
+
var LabelsConstants = (0, tslib_1.__importStar)(require("../../utils/labels"));
|
|
8
8
|
var constants_1 = require("../../utils/constants");
|
|
9
9
|
var constants_2 = require("../../logger/constants");
|
|
10
10
|
function ifElseIfCombinerContext(log, predicates) {
|
|
@@ -33,7 +33,7 @@ function ifElseIfCombinerContext(log, predicates) {
|
|
|
33
33
|
// define how to return the treatment (wrap result into a Promise or not).
|
|
34
34
|
var predicateResults = predicates.map(function (evaluator) { return evaluator(key, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator); });
|
|
35
35
|
// if we find a thenable
|
|
36
|
-
if (lang_1.findIndex(predicateResults, thenable_1.thenable) !== -1) {
|
|
36
|
+
if ((0, lang_1.findIndex)(predicateResults, thenable_1.thenable) !== -1) {
|
|
37
37
|
return Promise.all(predicateResults).then(function (results) { return computeTreatment(results); });
|
|
38
38
|
}
|
|
39
39
|
return computeTreatment(predicateResults);
|
|
@@ -7,7 +7,7 @@ var murmur3_1 = require("../../utils/murmur3/murmur3");
|
|
|
7
7
|
* Get the treatment name given a key, a seed, and the percentage of each treatment.
|
|
8
8
|
*/
|
|
9
9
|
function getTreatment(log, key, seed, treatments) {
|
|
10
|
-
var _bucket = murmur3_1.bucket(key, seed);
|
|
10
|
+
var _bucket = (0, murmur3_1.bucket)(key, seed);
|
|
11
11
|
var treatment = treatments.getTreatmentFor(_bucket);
|
|
12
12
|
log.debug(constants_1.ENGINE_BUCKET, [_bucket, key, seed, treatment]);
|
|
13
13
|
return treatment;
|
|
@@ -19,7 +19,7 @@ exports.getTreatment = getTreatment;
|
|
|
19
19
|
function shouldApplyRollout(trafficAllocation, key, 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 = murmur3_1.bucket(key, trafficAllocationSeed);
|
|
22
|
+
var _bucket = (0, murmur3_1.bucket)(key, trafficAllocationSeed);
|
|
23
23
|
if (_bucket > trafficAllocation) {
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
@@ -4,11 +4,11 @@ exports.conditionContext = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var engineUtils_1 = require("./engineUtils");
|
|
6
6
|
var thenable_1 = require("../../utils/promise/thenable");
|
|
7
|
-
var LabelsConstants = tslib_1.__importStar(require("../../utils/labels"));
|
|
7
|
+
var LabelsConstants = (0, tslib_1.__importStar)(require("../../utils/labels"));
|
|
8
8
|
// Build Evaluation object if and only if matchingResult is true
|
|
9
9
|
function match(log, matchingResult, bucketingKey, seed, treatments, label) {
|
|
10
10
|
if (matchingResult) {
|
|
11
|
-
var treatment = engineUtils_1.getTreatment(log, bucketingKey, seed, treatments);
|
|
11
|
+
var treatment = (0, engineUtils_1.getTreatment)(log, bucketingKey, seed, treatments);
|
|
12
12
|
return {
|
|
13
13
|
treatment: treatment,
|
|
14
14
|
label: label
|
|
@@ -21,7 +21,7 @@ function match(log, matchingResult, bucketingKey, seed, treatments, label) {
|
|
|
21
21
|
function conditionContext(log, matcherEvaluator, treatments, label, conditionType) {
|
|
22
22
|
return function conditionEvaluator(key, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator) {
|
|
23
23
|
// Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
|
|
24
|
-
if (conditionType === 'ROLLOUT' && !engineUtils_1.shouldApplyRollout(trafficAllocation, key.bucketingKey, trafficAllocationSeed)) {
|
|
24
|
+
if (conditionType === 'ROLLOUT' && !(0, engineUtils_1.shouldApplyRollout)(trafficAllocation, key.bucketingKey, trafficAllocationSeed)) {
|
|
25
25
|
return {
|
|
26
26
|
treatment: undefined,
|
|
27
27
|
label: LabelsConstants.NOT_IN_SPLIT
|
|
@@ -32,7 +32,7 @@ function conditionContext(log, matcherEvaluator, treatments, label, conditionTyp
|
|
|
32
32
|
// Also, we pass splitEvaluator function in case we have a matcher that needs to evaluate another split,
|
|
33
33
|
// as well as the entire key object for the same reason.
|
|
34
34
|
var matches = matcherEvaluator(key, attributes, splitEvaluator);
|
|
35
|
-
if (thenable_1.thenable(matches)) {
|
|
35
|
+
if ((0, thenable_1.thenable)(matches)) {
|
|
36
36
|
return matches.then(function (result) { return match(log, result, key.bucketingKey, seed, treatments, label); });
|
|
37
37
|
}
|
|
38
38
|
return match(log, matches, key.bucketingKey, seed, treatments, label);
|
package/cjs/evaluator/index.js
CHANGED
|
@@ -4,7 +4,7 @@ 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
|
-
var LabelsConstants = tslib_1.__importStar(require("../utils/labels"));
|
|
7
|
+
var LabelsConstants = (0, tslib_1.__importStar)(require("../utils/labels"));
|
|
8
8
|
var constants_1 = require("../utils/constants");
|
|
9
9
|
var treatmentException = {
|
|
10
10
|
treatment: constants_1.CONTROL,
|
|
@@ -27,7 +27,7 @@ function evaluateFeature(log, key, splitName, attributes, storage) {
|
|
|
27
27
|
// Exception on sync `getSplit` storage. Not possible ATM with InMemory and InLocal storages.
|
|
28
28
|
return treatmentException;
|
|
29
29
|
}
|
|
30
|
-
if (thenable_1.thenable(stringifiedSplit)) {
|
|
30
|
+
if ((0, thenable_1.thenable)(stringifiedSplit)) {
|
|
31
31
|
return stringifiedSplit.then(function (result) { return getEvaluation(log, result, key, attributes, storage); }).catch(
|
|
32
32
|
// Exception on async `getSplit` storage. For example, when the storage is redis or
|
|
33
33
|
// pluggable and there is a connection issue and we can't retrieve the split to be evaluated
|
|
@@ -45,7 +45,7 @@ function evaluateFeatures(log, key, splitNames, attributes, storage) {
|
|
|
45
45
|
// Exception on sync `getSplits` storage. Not possible ATM with InMemory and InLocal storages.
|
|
46
46
|
return treatmentsException(splitNames);
|
|
47
47
|
}
|
|
48
|
-
return (thenable_1.thenable(stringifiedSplits)) ?
|
|
48
|
+
return ((0, thenable_1.thenable)(stringifiedSplits)) ?
|
|
49
49
|
stringifiedSplits.then(function (splits) { return getEvaluations(log, splitNames, splits, key, attributes, storage); })
|
|
50
50
|
.catch(function () {
|
|
51
51
|
// Exception on async `getSplits` storage. For example, when the storage is redis or
|
|
@@ -66,7 +66,7 @@ function getEvaluation(log, stringifiedSplit, key, attributes, storage) {
|
|
|
66
66
|
var split_1 = Engine_1.Engine.parse(log, splitJSON_1, storage);
|
|
67
67
|
evaluation = split_1.getTreatment(key, attributes, evaluateFeature);
|
|
68
68
|
// If the storage is async and the evaluated split uses segment, evaluation is thenable
|
|
69
|
-
if (thenable_1.thenable(evaluation)) {
|
|
69
|
+
if ((0, thenable_1.thenable)(evaluation)) {
|
|
70
70
|
return evaluation.then(function (result) {
|
|
71
71
|
result.changeNumber = split_1.getChangeNumber();
|
|
72
72
|
result.config = splitJSON_1.configurations && splitJSON_1.configurations[result.treatment] || null;
|
|
@@ -85,7 +85,7 @@ function getEvaluations(log, splitNames, splits, key, attributes, storage) {
|
|
|
85
85
|
var thenables = [];
|
|
86
86
|
splitNames.forEach(function (splitName) {
|
|
87
87
|
var evaluation = getEvaluation(log, splits[splitName], key, attributes, storage);
|
|
88
|
-
if (thenable_1.thenable(evaluation)) {
|
|
88
|
+
if ((0, thenable_1.thenable)(evaluation)) {
|
|
89
89
|
thenables.push(evaluation.then(function (res) {
|
|
90
90
|
result[splitName] = res;
|
|
91
91
|
}));
|
|
@@ -11,7 +11,7 @@ function containsAllSetMatcherContext(log, ruleAttr) {
|
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
13
|
var _loop_1 = function (i) {
|
|
14
|
-
if (lang_1.findIndex(runtimeAttr, function (e) { return e === ruleAttr[i]; }) < 0)
|
|
14
|
+
if ((0, lang_1.findIndex)(runtimeAttr, function (e) { return e === ruleAttr[i]; }) < 0)
|
|
15
15
|
containsAll = false;
|
|
16
16
|
};
|
|
17
17
|
for (var i = 0; i < ruleAttr.length && containsAll; i++) {
|
|
@@ -7,7 +7,7 @@ function containsAnySetMatcherContext(log, ruleAttr) {
|
|
|
7
7
|
return function containsAnyMatcher(runtimeAttr) {
|
|
8
8
|
var containsAny = false;
|
|
9
9
|
var _loop_1 = function (i) {
|
|
10
|
-
if (lang_1.findIndex(runtimeAttr, function (e) { return e === ruleAttr[i]; }) >= 0)
|
|
10
|
+
if ((0, lang_1.findIndex)(runtimeAttr, function (e) { return e === ruleAttr[i]; }) >= 0)
|
|
11
11
|
containsAny = true;
|
|
12
12
|
};
|
|
13
13
|
for (var i = 0; i < ruleAttr.length && !containsAny; i++) {
|
|
@@ -5,7 +5,7 @@ var lang_1 = require("../../utils/lang");
|
|
|
5
5
|
var constants_1 = require("../../logger/constants");
|
|
6
6
|
function containsStringMatcherContext(log, ruleAttr) {
|
|
7
7
|
return function containsStringMatcher(runtimeAttr) {
|
|
8
|
-
var contains = ruleAttr.some(function (e) { return lang_1.isString(runtimeAttr) && runtimeAttr.indexOf(e) > -1; });
|
|
8
|
+
var contains = ruleAttr.some(function (e) { return (0, lang_1.isString)(runtimeAttr) && runtimeAttr.indexOf(e) > -1; });
|
|
9
9
|
log.debug(constants_1.ENGINE_MATCHER_CONTAINS_STRING, [runtimeAttr, ruleAttr, contains]);
|
|
10
10
|
return contains;
|
|
11
11
|
};
|
|
@@ -17,7 +17,7 @@ function dependencyMatcherContext(log, _a, storage) {
|
|
|
17
17
|
var key = _a.key, attributes = _a.attributes;
|
|
18
18
|
log.debug(constants_1.ENGINE_MATCHER_DEPENDENCY_PRE, [split, JSON.stringify(key), attributes ? '\n attributes: ' + JSON.stringify(attributes) : '']);
|
|
19
19
|
var evaluation = splitEvaluator(log, key, split, attributes, storage);
|
|
20
|
-
if (thenable_1.thenable(evaluation)) {
|
|
20
|
+
if ((0, thenable_1.thenable)(evaluation)) {
|
|
21
21
|
return evaluation.then(function (ev) { return checkTreatment(ev, treatments, split); });
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
@@ -9,7 +9,7 @@ function equalToSetMatcherContext(log, ruleAttr) {
|
|
|
9
9
|
var isEqual = runtimeAttr.length === ruleAttr.length;
|
|
10
10
|
var _loop_1 = function (i) {
|
|
11
11
|
// if length is the same we check that all elements are present in the other collection.
|
|
12
|
-
if (lang_1.findIndex(ruleAttr, function (e) { return e === runtimeAttr[i]; }) < 0)
|
|
12
|
+
if ((0, lang_1.findIndex)(ruleAttr, function (e) { return e === runtimeAttr[i]; }) < 0)
|
|
13
13
|
isEqual = false;
|
|
14
14
|
};
|
|
15
15
|
for (var i = 0; i < runtimeAttr.length && isEqual; i++) {
|
|
@@ -5,9 +5,9 @@ var constants_1 = require("../../logger/constants");
|
|
|
5
5
|
var lang_1 = require("../../utils/lang");
|
|
6
6
|
function endsWithMatcherContext(log, ruleAttr) {
|
|
7
7
|
return function endsWithMatcher(runtimeAttr) {
|
|
8
|
-
var
|
|
9
|
-
log.debug(constants_1.ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr,
|
|
10
|
-
return
|
|
8
|
+
var strEndsWith = ruleAttr.some(function (e) { return (0, lang_1.endsWith)(runtimeAttr, e); });
|
|
9
|
+
log.debug(constants_1.ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr, strEndsWith]);
|
|
10
|
+
return strEndsWith;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
exports.endsWithMatcherContext = endsWithMatcherContext;
|
|
@@ -9,7 +9,7 @@ function partOfSetMatcherContext(log, ruleAttr) {
|
|
|
9
9
|
var isPartOf = runtimeAttr.length <= ruleAttr.length;
|
|
10
10
|
var _loop_1 = function (i) {
|
|
11
11
|
// If the length says is possible, we iterate until we prove otherwise or we check all elements.
|
|
12
|
-
if (lang_1.findIndex(ruleAttr, function (e) { return e === runtimeAttr[i]; }) < 0)
|
|
12
|
+
if ((0, lang_1.findIndex)(ruleAttr, function (e) { return e === runtimeAttr[i]; }) < 0)
|
|
13
13
|
isPartOf = false;
|
|
14
14
|
};
|
|
15
15
|
for (var i = 0; i < runtimeAttr.length && isPartOf; i++) {
|
|
@@ -6,7 +6,7 @@ var constants_1 = require("../../logger/constants");
|
|
|
6
6
|
function segmentMatcherContext(log, segmentName, storage) {
|
|
7
7
|
return function segmentMatcher(key) {
|
|
8
8
|
var isInSegment = storage.segments.isInSegment(segmentName, key);
|
|
9
|
-
if (thenable_1.thenable(isInSegment)) {
|
|
9
|
+
if ((0, thenable_1.thenable)(isInSegment)) {
|
|
10
10
|
isInSegment.then(function (result) {
|
|
11
11
|
log.debug(constants_1.ENGINE_MATCHER_SEGMENT, [segmentName, key, isInSegment]);
|
|
12
12
|
return result;
|
|
@@ -5,7 +5,7 @@ var constants_1 = require("../../logger/constants");
|
|
|
5
5
|
var lang_1 = require("../../utils/lang");
|
|
6
6
|
function startsWithMatcherContext(log, ruleAttr) {
|
|
7
7
|
return function startsWithMatcher(runtimeAttr) {
|
|
8
|
-
var matches = ruleAttr.some(function (e) { return lang_1.startsWith(runtimeAttr, e); });
|
|
8
|
+
var matches = ruleAttr.some(function (e) { return (0, lang_1.startsWith)(runtimeAttr, e); });
|
|
9
9
|
log.debug(constants_1.ENGINE_MATCHER_STARTS_WITH, [runtimeAttr, ruleAttr, matches]);
|
|
10
10
|
return matches;
|
|
11
11
|
};
|
|
@@ -6,7 +6,7 @@ var constants_1 = require("../../logger/constants");
|
|
|
6
6
|
function whitelistMatcherContext(log, ruleAttr) {
|
|
7
7
|
return function whitelistMatcher(runtimeAttr) {
|
|
8
8
|
var isInWhitelist = ruleAttr.has(runtimeAttr);
|
|
9
|
-
log.debug(constants_1.ENGINE_MATCHER_WHITELIST, [runtimeAttr, sets_1.setToArray(ruleAttr).join(','), isInWhitelist]);
|
|
9
|
+
log.debug(constants_1.ENGINE_MATCHER_WHITELIST, [runtimeAttr, (0, sets_1.setToArray)(ruleAttr).join(','), isInWhitelist]);
|
|
10
10
|
return isInWhitelist;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -15,30 +15,30 @@ function matchersTransform(matchers) {
|
|
|
15
15
|
var parsedMatchers = matchers.map(function (matcher) {
|
|
16
16
|
var matcherType = matcher.matcherType /* string */, negate = matcher.negate /* boolean */, keySelector = matcher.keySelector /* keySelectorObject */, segmentObject = matcher.userDefinedSegmentMatcherData /* segmentObject */, whitelistObject = matcher.whitelistMatcherData /* whiteListObject, provided by 'WHITELIST', set and string matchers */, unaryNumericObject = matcher.unaryNumericMatcherData /* unaryNumericObject */, betweenObject = matcher.betweenMatcherData /* betweenObject */, dependencyObject = matcher.dependencyMatcherData /* dependencyObject */, booleanMatcherData = matcher.booleanMatcherData, stringMatcherData = matcher.stringMatcherData;
|
|
17
17
|
var attribute = keySelector && keySelector.attribute;
|
|
18
|
-
var type = matcherTypes_1.matcherTypesMapper(matcherType);
|
|
18
|
+
var type = (0, matcherTypes_1.matcherTypesMapper)(matcherType);
|
|
19
19
|
// As default input data type we use string (even for ALL_KEYS)
|
|
20
20
|
var dataType = matcherTypes_1.matcherDataTypes.STRING;
|
|
21
21
|
var value = undefined;
|
|
22
22
|
if (type === matcherTypes_1.matcherTypes.IN_SEGMENT) {
|
|
23
|
-
value = segment_1.segmentTransform(segmentObject);
|
|
23
|
+
value = (0, segment_1.segmentTransform)(segmentObject);
|
|
24
24
|
}
|
|
25
25
|
else if (type === matcherTypes_1.matcherTypes.WHITELIST) {
|
|
26
|
-
value = whitelist_1.whitelistTransform(whitelistObject);
|
|
26
|
+
value = (0, whitelist_1.whitelistTransform)(whitelistObject);
|
|
27
27
|
}
|
|
28
28
|
else if (type === matcherTypes_1.matcherTypes.EQUAL_TO) {
|
|
29
|
-
value = unaryNumeric_1.numericTransform(unaryNumericObject);
|
|
29
|
+
value = (0, unaryNumeric_1.numericTransform)(unaryNumericObject);
|
|
30
30
|
dataType = matcherTypes_1.matcherDataTypes.NUMBER;
|
|
31
31
|
if (unaryNumericObject.dataType === 'DATETIME') {
|
|
32
|
-
value = convertions_1.zeroSinceHH(value);
|
|
32
|
+
value = (0, convertions_1.zeroSinceHH)(value);
|
|
33
33
|
dataType = matcherTypes_1.matcherDataTypes.DATETIME;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
else if (type === matcherTypes_1.matcherTypes.GREATER_THAN_OR_EQUAL_TO ||
|
|
37
37
|
type === matcherTypes_1.matcherTypes.LESS_THAN_OR_EQUAL_TO) {
|
|
38
|
-
value = unaryNumeric_1.numericTransform(unaryNumericObject);
|
|
38
|
+
value = (0, unaryNumeric_1.numericTransform)(unaryNumericObject);
|
|
39
39
|
dataType = matcherTypes_1.matcherDataTypes.NUMBER;
|
|
40
40
|
if (unaryNumericObject.dataType === 'DATETIME') {
|
|
41
|
-
value = convertions_1.zeroSinceSS(value);
|
|
41
|
+
value = (0, convertions_1.zeroSinceSS)(value);
|
|
42
42
|
dataType = matcherTypes_1.matcherDataTypes.DATETIME;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -46,8 +46,8 @@ function matchersTransform(matchers) {
|
|
|
46
46
|
value = betweenObject;
|
|
47
47
|
dataType = matcherTypes_1.matcherDataTypes.NUMBER;
|
|
48
48
|
if (value.dataType === 'DATETIME') {
|
|
49
|
-
value.start = convertions_1.zeroSinceSS(value.start);
|
|
50
|
-
value.end = convertions_1.zeroSinceSS(value.end);
|
|
49
|
+
value.start = (0, convertions_1.zeroSinceSS)(value.start);
|
|
50
|
+
value.end = (0, convertions_1.zeroSinceSS)(value.end);
|
|
51
51
|
dataType = matcherTypes_1.matcherDataTypes.DATETIME;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -55,13 +55,13 @@ function matchersTransform(matchers) {
|
|
|
55
55
|
type === matcherTypes_1.matcherTypes.CONTAINS_ANY_OF_SET ||
|
|
56
56
|
type === matcherTypes_1.matcherTypes.CONTAINS_ALL_OF_SET ||
|
|
57
57
|
type === matcherTypes_1.matcherTypes.PART_OF_SET) {
|
|
58
|
-
value = set_1.setTransform(whitelistObject);
|
|
58
|
+
value = (0, set_1.setTransform)(whitelistObject);
|
|
59
59
|
dataType = matcherTypes_1.matcherDataTypes.SET;
|
|
60
60
|
}
|
|
61
61
|
else if (type === matcherTypes_1.matcherTypes.STARTS_WITH ||
|
|
62
62
|
type === matcherTypes_1.matcherTypes.ENDS_WITH ||
|
|
63
63
|
type === matcherTypes_1.matcherTypes.CONTAINS_STRING) {
|
|
64
|
-
value = set_1.setTransform(whitelistObject);
|
|
64
|
+
value = (0, set_1.setTransform)(whitelistObject);
|
|
65
65
|
}
|
|
66
66
|
else if (type === matcherTypes_1.matcherTypes.IN_SPLIT_TREATMENT) {
|
|
67
67
|
value = dependencyObject;
|
|
@@ -82,7 +82,7 @@ function matchersTransform(matchers) {
|
|
|
82
82
|
dataType: dataType // runtime input data type
|
|
83
83
|
};
|
|
84
84
|
});
|
|
85
|
-
if (lang_1.findIndex(parsedMatchers, function (m) { return m.type === matcherTypes_1.matcherTypes.UNDEFINED; }) === -1) {
|
|
85
|
+
if ((0, lang_1.findIndex)(parsedMatchers, function (m) { return m.type === matcherTypes_1.matcherTypes.UNDEFINED; }) === -1) {
|
|
86
86
|
return parsedMatchers;
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
@@ -14,15 +14,15 @@ function parser(log, conditions, storage) {
|
|
|
14
14
|
for (var i = 0; i < conditions.length; i++) {
|
|
15
15
|
var _a = conditions[i], matcherGroup = _a.matcherGroup, partitions = _a.partitions, label = _a.label, conditionType = _a.conditionType;
|
|
16
16
|
// transform data structure
|
|
17
|
-
var matchers = matchersTransform_1.matchersTransform(matcherGroup.matchers);
|
|
17
|
+
var matchers = (0, matchersTransform_1.matchersTransform)(matcherGroup.matchers);
|
|
18
18
|
// create a set of pure functions from the matcher's dto
|
|
19
19
|
var expressions = matchers.map(function (matcherDto) {
|
|
20
|
-
var matcher = matchers_1.matcherFactory(log, matcherDto, storage);
|
|
20
|
+
var matcher = (0, matchers_1.matcherFactory)(log, matcherDto, storage);
|
|
21
21
|
// Evaluator function.
|
|
22
22
|
return function (key, attributes, splitEvaluator) {
|
|
23
|
-
var value = value_1.sanitizeValue(log, key, matcherDto, attributes);
|
|
23
|
+
var value = (0, value_1.sanitizeValue)(log, key, matcherDto, attributes);
|
|
24
24
|
var result = value !== undefined && matcher ? matcher(value, splitEvaluator) : false;
|
|
25
|
-
if (thenable_1.thenable(result)) {
|
|
25
|
+
if ((0, thenable_1.thenable)(result)) {
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
return result.then(function (res) { return Boolean(res ^ matcherDto.negate); });
|
|
28
28
|
}
|
|
@@ -38,9 +38,9 @@ function parser(log, conditions, storage) {
|
|
|
38
38
|
// and break the loop
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
|
-
predicates.push(condition_1.conditionContext(log, and_1.andCombinerContext(log, expressions), treatments_1.Treatments.parse(partitions), label, conditionType));
|
|
41
|
+
predicates.push((0, condition_1.conditionContext)(log, (0, and_1.andCombinerContext)(log, expressions), treatments_1.Treatments.parse(partitions), label, conditionType));
|
|
42
42
|
}
|
|
43
43
|
// Instanciate evaluator given the set of conditions using if else if logic
|
|
44
|
-
return ifelseif_1.ifElseIfCombinerContext(log, predicates);
|
|
44
|
+
return (0, ifelseif_1.ifElseIfCombinerContext)(log, predicates);
|
|
45
45
|
}
|
|
46
46
|
exports.parser = parser;
|
|
@@ -33,7 +33,7 @@ var Treatments = /** @class */ (function () {
|
|
|
33
33
|
// for (let [k, r] of this._ranges.entries()) {
|
|
34
34
|
// if (x <= r) return this._treatments[k];
|
|
35
35
|
// }
|
|
36
|
-
var index = lang_1.findIndex(this._ranges, function (range) { return x <= range; });
|
|
36
|
+
var index = (0, lang_1.findIndex)(this._ranges, function (range) { return x <= range; });
|
|
37
37
|
var treatment = this._treatments[index];
|
|
38
38
|
return treatment;
|
|
39
39
|
};
|
|
@@ -25,7 +25,7 @@ function parseValue(log, key, attributeName, attributes) {
|
|
|
25
25
|
function sanitizeValue(log, key, matcherDto, attributes) {
|
|
26
26
|
var attributeName = matcherDto.attribute;
|
|
27
27
|
var valueToMatch = parseValue(log, key, attributeName, attributes);
|
|
28
|
-
var sanitizedValue = sanitize_1.sanitize(log, matcherDto.type, valueToMatch, matcherDto.dataType, attributes);
|
|
28
|
+
var sanitizedValue = (0, sanitize_1.sanitize)(log, matcherDto.type, valueToMatch, matcherDto.dataType, attributes);
|
|
29
29
|
if (sanitizedValue !== undefined) {
|
|
30
30
|
return sanitizedValue;
|
|
31
31
|
}
|
|
@@ -6,20 +6,20 @@ var convertions_1 = require("../convertions");
|
|
|
6
6
|
var matcherTypes_1 = require("../matchers/matcherTypes");
|
|
7
7
|
var constants_1 = require("../../logger/constants");
|
|
8
8
|
function sanitizeNumber(val) {
|
|
9
|
-
var num = lang_1.toNumber(val);
|
|
9
|
+
var num = (0, lang_1.toNumber)(val);
|
|
10
10
|
return isNaN(num) ? undefined : num;
|
|
11
11
|
}
|
|
12
12
|
function sanitizeString(val) {
|
|
13
13
|
var valueToSanitize = val;
|
|
14
|
-
if (lang_1.isObject(val)) {
|
|
14
|
+
if ((0, lang_1.isObject)(val)) {
|
|
15
15
|
// If the value is an object and is not a key, discard it.
|
|
16
16
|
valueToSanitize = val.matchingKey ? val.matchingKey : undefined;
|
|
17
17
|
}
|
|
18
|
-
var str = lang_1.toString(valueToSanitize);
|
|
18
|
+
var str = (0, lang_1.toString)(valueToSanitize);
|
|
19
19
|
return str ? str : undefined;
|
|
20
20
|
}
|
|
21
21
|
function sanitizeArray(val) {
|
|
22
|
-
var arr = Array.isArray(val) ? lang_1.uniq(val.map(function (e) { return e + ''; })) : [];
|
|
22
|
+
var arr = Array.isArray(val) ? (0, lang_1.uniq)(val.map(function (e) { return e + ''; })) : [];
|
|
23
23
|
return arr.length ? arr : undefined;
|
|
24
24
|
}
|
|
25
25
|
function sanitizeBoolean(val) {
|
|
@@ -19,13 +19,13 @@ function integrationsManagerFactory(integrations, params) {
|
|
|
19
19
|
var integrationFactories = integrations
|
|
20
20
|
.map(function (integrationOptions) {
|
|
21
21
|
switch (integrationOptions.type) {
|
|
22
|
-
case browser_1.GOOGLE_ANALYTICS_TO_SPLIT: return GoogleAnalyticsToSplit_1.GoogleAnalyticsToSplit(integrationOptions);
|
|
23
|
-
case browser_1.SPLIT_TO_GOOGLE_ANALYTICS: return SplitToGoogleAnalytics_1.SplitToGoogleAnalytics(integrationOptions);
|
|
22
|
+
case browser_1.GOOGLE_ANALYTICS_TO_SPLIT: return (0, GoogleAnalyticsToSplit_1.GoogleAnalyticsToSplit)(integrationOptions);
|
|
23
|
+
case browser_1.SPLIT_TO_GOOGLE_ANALYTICS: return (0, SplitToGoogleAnalytics_1.SplitToGoogleAnalytics)(integrationOptions);
|
|
24
24
|
}
|
|
25
25
|
})
|
|
26
26
|
.filter(function (integrationFactory) {
|
|
27
27
|
return integrationFactory && typeof integrationFactory === 'function';
|
|
28
28
|
});
|
|
29
|
-
return pluggable_1.pluggableIntegrationsManagerFactory(integrationFactories, params);
|
|
29
|
+
return (0, pluggable_1.pluggableIntegrationsManagerFactory)(integrationFactories, params);
|
|
30
30
|
}
|
|
31
31
|
exports.integrationsManagerFactory = integrationsManagerFactory;
|
|
@@ -87,16 +87,16 @@ function validateIdentities(identities) {
|
|
|
87
87
|
if (!Array.isArray(identities))
|
|
88
88
|
return [];
|
|
89
89
|
// Remove duplicated identities
|
|
90
|
-
var uniqueIdentities = lang_1.uniqAsStrings(identities);
|
|
90
|
+
var uniqueIdentities = (0, lang_1.uniqAsStrings)(identities);
|
|
91
91
|
// Filter based on rum-agent identities validator
|
|
92
92
|
return uniqueIdentities.filter(function (identity) {
|
|
93
93
|
if (!identity)
|
|
94
94
|
return false;
|
|
95
95
|
var maybeKey = identity.key;
|
|
96
96
|
var maybeTT = identity.trafficType;
|
|
97
|
-
if (!lang_1.isString(maybeKey) && !lang_1.isFiniteNumber(maybeKey))
|
|
97
|
+
if (!(0, lang_1.isString)(maybeKey) && !(0, lang_1.isFiniteNumber)(maybeKey))
|
|
98
98
|
return false;
|
|
99
|
-
if (!lang_1.isString(maybeTT))
|
|
99
|
+
if (!(0, lang_1.isString)(maybeTT))
|
|
100
100
|
return false;
|
|
101
101
|
return true;
|
|
102
102
|
});
|
|
@@ -110,18 +110,18 @@ exports.validateIdentities = validateIdentities;
|
|
|
110
110
|
* @returns {boolean} Whether the data instance is a valid EventData or not.
|
|
111
111
|
*/
|
|
112
112
|
function validateEventData(log, eventData) {
|
|
113
|
-
if (!inputValidation_1.validateEvent(log, eventData.eventTypeId, logNameMapper))
|
|
113
|
+
if (!(0, inputValidation_1.validateEvent)(log, eventData.eventTypeId, logNameMapper))
|
|
114
114
|
return false;
|
|
115
|
-
if (inputValidation_1.validateEventValue(log, eventData.value, logNameMapper) === false)
|
|
115
|
+
if ((0, inputValidation_1.validateEventValue)(log, eventData.value, logNameMapper) === false)
|
|
116
116
|
return false;
|
|
117
|
-
var properties = inputValidation_1.validateEventProperties(log, eventData.properties, logNameMapper).properties;
|
|
117
|
+
var properties = (0, inputValidation_1.validateEventProperties)(log, eventData.properties, logNameMapper).properties;
|
|
118
118
|
if (properties === false)
|
|
119
119
|
return false;
|
|
120
|
-
if (eventData.timestamp && !lang_1.isFiniteNumber(eventData.timestamp))
|
|
120
|
+
if (eventData.timestamp && !(0, lang_1.isFiniteNumber)(eventData.timestamp))
|
|
121
121
|
return false;
|
|
122
|
-
if (eventData.key && inputValidation_1.validateKey(log, eventData.key, logNameMapper) === false)
|
|
122
|
+
if (eventData.key && (0, inputValidation_1.validateKey)(log, eventData.key, logNameMapper) === false)
|
|
123
123
|
return false;
|
|
124
|
-
if (eventData.trafficTypeName && inputValidation_1.validateTrafficType(log, eventData.trafficTypeName, logNameMapper) === false)
|
|
124
|
+
if (eventData.trafficTypeName && (0, inputValidation_1.validateTrafficType)(log, eventData.trafficTypeName, logNameMapper) === false)
|
|
125
125
|
return false;
|
|
126
126
|
return true;
|
|
127
127
|
}
|
|
@@ -137,7 +137,7 @@ var INVALID_SUBSTRING_REGEX = /[^-_.:a-zA-Z0-9]+/g;
|
|
|
137
137
|
*/
|
|
138
138
|
function fixEventTypeId(log, eventTypeId) {
|
|
139
139
|
// return the input eventTypeId if it cannot be fixed
|
|
140
|
-
if (!lang_1.isString(eventTypeId) || eventTypeId.length === 0) {
|
|
140
|
+
if (!(0, lang_1.isString)(eventTypeId) || eventTypeId.length === 0) {
|
|
141
141
|
return eventTypeId;
|
|
142
142
|
}
|
|
143
143
|
// replace invalid substrings and truncate
|
|
@@ -172,7 +172,7 @@ function GaToSplit(sdkOptions, params) {
|
|
|
172
172
|
// Constructor for the SplitTracker plugin.
|
|
173
173
|
function SplitTracker(tracker, pluginOptions) {
|
|
174
174
|
// precedence of options: SDK options (config.integrations) overwrite pluginOptions (`ga('require', 'splitTracker', pluginOptions)`)
|
|
175
|
-
var opts = objectAssign_1.objectAssign({}, defaultOptions, sdkOptions, pluginOptions);
|
|
175
|
+
var opts = (0, objectAssign_1.objectAssign)({}, defaultOptions, sdkOptions, pluginOptions);
|
|
176
176
|
this.tracker = tracker;
|
|
177
177
|
// Validate identities
|
|
178
178
|
var validIdentities = validateIdentities(opts.identities);
|
|
@@ -186,7 +186,7 @@ function GaToSplit(sdkOptions, params) {
|
|
|
186
186
|
}
|
|
187
187
|
opts.identities = validIdentities;
|
|
188
188
|
// Validate prefix
|
|
189
|
-
if (!lang_1.isString(opts.prefix)) {
|
|
189
|
+
if (!(0, lang_1.isString)(opts.prefix)) {
|
|
190
190
|
log.warn(logPrefix + 'The provided `prefix` was ignored since it is invalid. Please check that you are passing a string object as `prefix`.');
|
|
191
191
|
opts.prefix = undefined;
|
|
192
192
|
}
|
|
@@ -209,7 +209,7 @@ function GaToSplit(sdkOptions, params) {
|
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
211
211
|
// map hit into an EventData instance
|
|
212
|
-
var eventData = exports.defaultMapper(model);
|
|
212
|
+
var eventData = (0, exports.defaultMapper)(model);
|
|
213
213
|
if (opts.mapper) {
|
|
214
214
|
try {
|
|
215
215
|
eventData = opts.mapper(model, eventData);
|
|
@@ -233,7 +233,7 @@ function GaToSplit(sdkOptions, params) {
|
|
|
233
233
|
}
|
|
234
234
|
else { // Store the event for each Key-TT pair (identities), if key and TT is not present in eventData
|
|
235
235
|
opts.identities.forEach(function (identity) {
|
|
236
|
-
var event = objectAssign_1.objectAssign({
|
|
236
|
+
var event = (0, objectAssign_1.objectAssign)({
|
|
237
237
|
key: identity.key,
|
|
238
238
|
trafficTypeName: identity.trafficType,
|
|
239
239
|
}, eventData);
|
|
@@ -4,8 +4,10 @@ exports.GoogleAnalyticsToSplit = void 0;
|
|
|
4
4
|
var GaToSplit_1 = require("./GaToSplit");
|
|
5
5
|
function GoogleAnalyticsToSplit(options) {
|
|
6
6
|
// GaToSplit integration factory
|
|
7
|
-
|
|
8
|
-
return GaToSplit_1.GaToSplit(options, params);
|
|
9
|
-
}
|
|
7
|
+
function GoogleAnalyticsToSplitFactory(params) {
|
|
8
|
+
return (0, GaToSplit_1.GaToSplit)(options, params);
|
|
9
|
+
}
|
|
10
|
+
GoogleAnalyticsToSplitFactory.type = 'GOOGLE_ANALYTICS_TO_SPLIT';
|
|
11
|
+
return GoogleAnalyticsToSplitFactory;
|
|
10
12
|
}
|
|
11
13
|
exports.GoogleAnalyticsToSplit = GoogleAnalyticsToSplit;
|
|
@@ -24,7 +24,7 @@ var SplitToGa = /** @class */ (function () {
|
|
|
24
24
|
// We don't warn if a tracker does not exist, since the user might create it after the SDK is initialized.
|
|
25
25
|
// Note: GA allows to create and get trackers using a string or number as tracker name, and does nothing if other types are used.
|
|
26
26
|
if (Array.isArray(options.trackerNames))
|
|
27
|
-
this.trackerNames = lang_1.uniq(options.trackerNames);
|
|
27
|
+
this.trackerNames = (0, lang_1.uniq)(options.trackerNames);
|
|
28
28
|
// No need to validate `impressions` and `events` flags. Any other value than `false` is ignored (considered true by default).
|
|
29
29
|
this.impressions = options.impressions;
|
|
30
30
|
this.events = options.events;
|
|
@@ -5,8 +5,10 @@ var SplitToGa_1 = require("./SplitToGa");
|
|
|
5
5
|
function SplitToGoogleAnalytics(options) {
|
|
6
6
|
if (options === void 0) { options = {}; }
|
|
7
7
|
// SplitToGa integration factory
|
|
8
|
-
|
|
8
|
+
function SplitToGoogleAnalyticsFactory(params) {
|
|
9
9
|
return new SplitToGa_1.SplitToGa(params.settings.log, options);
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
|
+
SplitToGoogleAnalyticsFactory.type = 'SPLIT_TO_GOOGLE_ANALYTICS';
|
|
12
|
+
return SplitToGoogleAnalyticsFactory;
|
|
11
13
|
}
|
|
12
14
|
exports.SplitToGoogleAnalytics = SplitToGoogleAnalytics;
|