@splitsoftware/splitio-commons 1.1.1-rc.0 → 1.2.1-rc.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 +1 -1
- 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 +1 -1
- package/cjs/integrations/ga/SplitToGa.js +1 -1
- package/cjs/listeners/browser.js +1 -1
- package/cjs/listeners/node.js +1 -1
- package/cjs/logger/constants.js +3 -1
- package/cjs/logger/index.js +2 -2
- package/cjs/logger/messages/debug.js +1 -1
- package/cjs/logger/messages/error.js +1 -1
- package/cjs/logger/messages/info.js +4 -4
- 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 +11 -10
- package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
- package/cjs/sdkClient/clientCS.js +4 -3
- package/cjs/sdkClient/clientInputValidation.js +14 -14
- package/cjs/sdkClient/sdkClient.js +3 -3
- package/cjs/sdkClient/sdkClientMethod.js +1 -1
- package/cjs/sdkClient/sdkClientMethodCS.js +6 -6
- package/cjs/sdkClient/sdkClientMethodCSWithTT.js +8 -8
- package/cjs/sdkFactory/index.js +8 -8
- package/cjs/sdkManager/index.js +11 -11
- package/cjs/services/splitApi.js +3 -2
- package/cjs/services/splitHttpClient.js +3 -3
- package/cjs/storages/KeyBuilder.js +2 -2
- package/cjs/storages/KeyBuilderCS.js +2 -2
- package/cjs/storages/KeyBuilderSS.js +1 -1
- package/cjs/storages/findLatencyIndex.js +1 -1
- package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +1 -1
- package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
- package/cjs/storages/inLocalStorage/index.js +3 -3
- package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
- package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.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 +16 -10
- 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 +4 -4
- 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 +4 -5
- 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 +39 -35
- package/cjs/sync/submitters/eventsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionsSyncTask.js +3 -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 +12 -12
- package/cjs/trackers/eventTracker.js +3 -3
- package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
- package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
- package/cjs/trackers/impressionsTracker.js +3 -3
- package/cjs/utils/MinEvents.js +2 -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 +2 -14
- package/cjs/utils/murmur3/common.js +1 -1
- package/cjs/utils/murmur3/legacy.js +44 -0
- 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/promise/timeout.js +1 -1
- package/cjs/utils/settingsValidation/index.js +5 -10
- 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/browser.js +10 -0
- package/cjs/utils/settingsValidation/runtime/node.js +22 -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/logger/messages/info.js +3 -3
- package/esm/sdkClient/client.js +2 -1
- package/esm/sdkClient/clientCS.js +2 -1
- package/esm/services/splitApi.js +2 -1
- package/esm/services/splitHttpClient.js +1 -1
- package/esm/storages/inRedis/RedisAdapter.js +7 -1
- 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/AuthClient/index.js +1 -2
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/esm/sync/streaming/pushManager.js +27 -23
- package/esm/sync/submitters/submitterManager.js +2 -1
- package/esm/sync/syncManagerOnline.js +12 -12
- package/esm/utils/inputValidation/eventProperties.js +4 -2
- package/esm/utils/inputValidation/key.js +2 -1
- package/esm/utils/lang/index.js +2 -13
- package/esm/utils/murmur3/legacy.js +39 -0
- package/esm/utils/promise/timeout.js +1 -1
- package/esm/utils/settingsValidation/index.js +1 -6
- package/esm/utils/settingsValidation/runtime/browser.js +6 -0
- package/esm/utils/settingsValidation/runtime/node.js +17 -0
- package/package.json +8 -7
- package/src/evaluator/matchers/ew.ts +4 -4
- package/src/logger/.DS_Store +0 -0
- package/src/logger/messages/info.ts +3 -3
- package/src/logger/types.ts +4 -0
- package/src/sdkClient/client.ts +2 -1
- package/src/sdkClient/clientCS.ts +3 -1
- package/src/services/splitHttpClient.ts +1 -1
- 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/AuthClient/index.ts +1 -2
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
- package/src/sync/streaming/pushManager.ts +31 -38
- package/src/sync/streaming/types.ts +5 -25
- package/src/sync/submitters/submitterManager.ts +4 -8
- package/src/sync/syncManagerOnline.ts +16 -22
- package/src/types.ts +5 -1
- package/src/utils/inputValidation/eventProperties.ts +4 -2
- package/src/utils/lang/index.ts +0 -14
- package/src/utils/murmur3/legacy.ts +48 -0
- package/src/utils/promise/timeout.ts +1 -1
- package/src/utils/settingsValidation/index.ts +1 -6
- package/src/utils/settingsValidation/runtime/browser.ts +6 -0
- package/src/utils/settingsValidation/runtime/node.ts +22 -0
- package/src/utils/settingsValidation/types.ts +6 -6
- package/types/integrations/ga/GaToSplitPlugin.d.ts +3 -0
- package/types/integrations/ga/SplitToGaPlugin.d.ts +4 -0
- package/types/logger/browser/{DebugLogger.d.ts → debugLogger.d.ts} +0 -0
- package/types/logger/browser/{ErrorLogger.d.ts → errorLogger.d.ts} +0 -0
- package/types/logger/browser/{InfoLogger.d.ts → infoLogger.d.ts} +0 -0
- package/types/logger/browser/{WarnLogger.d.ts → warnLogger.d.ts} +0 -0
- package/types/logger/codes.d.ts +2 -0
- package/types/logger/codesConstants.d.ts +117 -0
- package/types/logger/codesConstantsBrowser.d.ts +2 -0
- package/types/logger/codesConstantsNode.d.ts +14 -0
- package/types/logger/codesDebug.d.ts +1 -0
- package/types/logger/codesDebugBrowser.d.ts +1 -0
- package/types/logger/codesDebugNode.d.ts +1 -0
- package/types/logger/codesError.d.ts +1 -0
- package/types/logger/codesErrorNode.d.ts +1 -0
- package/types/logger/codesInfo.d.ts +1 -0
- package/types/logger/codesWarn.d.ts +1 -0
- package/types/logger/codesWarnNode.d.ts +1 -0
- package/types/logger/debugLogger.d.ts +2 -0
- package/types/logger/errorLogger.d.ts +2 -0
- package/types/logger/infoLogger.d.ts +2 -0
- package/types/logger/messages/debugBrowser.d.ts +1 -0
- package/types/logger/messages/debugNode.d.ts +1 -0
- package/types/logger/messages/errorNode.d.ts +1 -0
- package/types/logger/messages/warnNode.d.ts +1 -0
- package/types/logger/noopLogger.d.ts +2 -0
- package/types/logger/types.d.ts +4 -0
- package/types/logger/warnLogger.d.ts +2 -0
- package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
- package/types/sdkManager/sdkManagerMethod.d.ts +6 -0
- package/types/storages/getRegisteredSegments.d.ts +10 -0
- package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +51 -0
- package/types/storages/inMemory/index.d.ts +10 -0
- package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +0 -0
- package/types/storages/parseSegments.d.ts +6 -0
- package/types/storages/pluggable/TelemetryCachePluggable.d.ts +2 -0
- 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/syncTasks/splitsSyncTask.copy.d.ts +35 -0
- package/types/sync/polling/syncTasks/splitsSyncTask.morelikeoriginal.d.ts +35 -0
- package/types/sync/polling/types.d.ts +0 -11
- package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
- package/types/sync/streaming/AuthClient/indexV1.d.ts +12 -0
- package/types/sync/streaming/AuthClient/indexV2.d.ts +8 -0
- 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 -0
- package/types/sync/streaming/pushManagerNoUsers.d.ts +13 -0
- package/types/sync/streaming/pushManagerSS.d.ts +1 -0
- package/types/sync/streaming/types.d.ts +3 -23
- package/types/sync/submitters/submitterManager.d.ts +2 -4
- package/types/sync/submitters/telemetrySyncTask.d.ts +17 -0
- package/types/sync/syncManagerFromFile.d.ts +2 -0
- package/types/sync/syncManagerFromObject.d.ts +2 -0
- package/types/sync/syncManagerOffline.d.ts +9 -0
- package/types/sync/syncManagerOnline.d.ts +3 -3
- package/types/trackers/telemetryRecorder.d.ts +0 -0
- package/types/types.d.ts +1 -0
- package/types/utils/EventEmitter.d.ts +4 -0
- package/types/utils/lang/errors.d.ts +10 -0
- package/types/utils/lang/index.d.ts +0 -4
- package/types/utils/murmur3/commons.d.ts +12 -0
- package/types/utils/murmur3/legacy.d.ts +2 -0
- package/types/utils/settingsValidation/buildMetadata.d.ts +3 -0
- package/types/utils/settingsValidation/localhost/index.d.ts +9 -0
- package/types/utils/settingsValidation/logger.d.ts +11 -0
- package/types/utils/settingsValidation/runtime/browser.d.ts +4 -0
- package/types/utils/settingsValidation/runtime/node.d.ts +5 -0
- package/types/utils/settingsValidation/types.d.ts +6 -6
|
@@ -6,7 +6,7 @@ function timeout(ms, promise) {
|
|
|
6
6
|
return promise;
|
|
7
7
|
return new Promise(function (resolve, reject) {
|
|
8
8
|
var tid = setTimeout(function () {
|
|
9
|
-
reject(new Error("Operation timed out because it exceeded the configured time limit of " + ms + "ms."));
|
|
9
|
+
reject(new Error("Operation timed out because it exceeded the configured time limit of " + ms + " ms."));
|
|
10
10
|
}, ms);
|
|
11
11
|
promise.then(function (res) {
|
|
12
12
|
clearTimeout(tid);
|
|
@@ -67,10 +67,6 @@ var base = {
|
|
|
67
67
|
impressionsMode: constants_1.OPTIMIZED,
|
|
68
68
|
localhostMode: undefined
|
|
69
69
|
},
|
|
70
|
-
runtime: {
|
|
71
|
-
ip: false,
|
|
72
|
-
hostname: false
|
|
73
|
-
},
|
|
74
70
|
// Logger
|
|
75
71
|
log: undefined
|
|
76
72
|
};
|
|
@@ -87,7 +83,7 @@ function fromSecondsToMillis(n) {
|
|
|
87
83
|
function settingsValidation(config, validationParams) {
|
|
88
84
|
var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, localhost = validationParams.localhost;
|
|
89
85
|
// creates a settings object merging base, defaults and config objects.
|
|
90
|
-
var withDefaults = lang_1.merge({}, base, defaults, config);
|
|
86
|
+
var withDefaults = (0, lang_1.merge)({}, base, defaults, config);
|
|
91
87
|
// ensure a valid logger.
|
|
92
88
|
// First thing to validate, since other validators might use the logger.
|
|
93
89
|
var log = logger(withDefaults); // @ts-ignore, modify readonly prop
|
|
@@ -106,7 +102,7 @@ function settingsValidation(config, validationParams) {
|
|
|
106
102
|
startup.eventsFirstPushWindow = fromSecondsToMillis(startup.eventsFirstPushWindow);
|
|
107
103
|
// ensure a valid SDK mode
|
|
108
104
|
// @ts-ignore, modify readonly prop
|
|
109
|
-
withDefaults.mode = mode_1.mode(withDefaults.core.authorizationKey, withDefaults.mode);
|
|
105
|
+
withDefaults.mode = (0, mode_1.mode)(withDefaults.core.authorizationKey, withDefaults.mode);
|
|
110
106
|
// ensure a valid Storage based on mode defined.
|
|
111
107
|
// @ts-ignore, modify readonly prop
|
|
112
108
|
if (storage)
|
|
@@ -117,8 +113,7 @@ function settingsValidation(config, validationParams) {
|
|
|
117
113
|
}
|
|
118
114
|
// Current ip/hostname information
|
|
119
115
|
// @ts-ignore, modify readonly prop
|
|
120
|
-
|
|
121
|
-
withDefaults.runtime = runtime(withDefaults);
|
|
116
|
+
withDefaults.runtime = runtime(withDefaults);
|
|
122
117
|
// ensure a valid list of integrations.
|
|
123
118
|
// `integrations` returns an array of valid integration items.
|
|
124
119
|
// @ts-ignore, modify readonly prop
|
|
@@ -134,11 +129,11 @@ function settingsValidation(config, validationParams) {
|
|
|
134
129
|
scheduler.pushRetryBackoffBase = fromSecondsToMillis(scheduler.pushRetryBackoffBase);
|
|
135
130
|
}
|
|
136
131
|
// validate the `splitFilters` settings and parse splits query
|
|
137
|
-
var splitFiltersValidation = splitFilters_1.validateSplitFilters(log, withDefaults.sync.splitFilters, withDefaults.mode);
|
|
132
|
+
var splitFiltersValidation = (0, splitFilters_1.validateSplitFilters)(log, withDefaults.sync.splitFilters, withDefaults.mode);
|
|
138
133
|
withDefaults.sync.splitFilters = splitFiltersValidation.validFilters;
|
|
139
134
|
withDefaults.sync.__splitFiltersValidation = splitFiltersValidation;
|
|
140
135
|
// ensure a valid impressionsMode
|
|
141
|
-
withDefaults.sync.impressionsMode = impressionsMode_1.validImpressionsMode(log, withDefaults.sync.impressionsMode);
|
|
136
|
+
withDefaults.sync.impressionsMode = (0, impressionsMode_1.validImpressionsMode)(log, withDefaults.sync.impressionsMode);
|
|
142
137
|
return withDefaults;
|
|
143
138
|
}
|
|
144
139
|
exports.settingsValidation = settingsValidation;
|
|
@@ -13,6 +13,6 @@ var lang_1 = require("../../lang");
|
|
|
13
13
|
*/
|
|
14
14
|
function validateConfigurableIntegrations(settings, validIntegrationTypes) {
|
|
15
15
|
if (validIntegrationTypes === void 0) { validIntegrationTypes = []; }
|
|
16
|
-
return common_1.validateIntegrations(settings, function (integration) { return integration && lang_1.isString(integration.type) && validIntegrationTypes.indexOf(integration.type) > -1; }, 'Integration items must have a valid "type" value');
|
|
16
|
+
return (0, common_1.validateIntegrations)(settings, function (integration) { return integration && (0, lang_1.isString)(integration.type) && validIntegrationTypes.indexOf(integration.type) > -1; }, 'Integration items must have a valid "type" value');
|
|
17
17
|
}
|
|
18
18
|
exports.validateConfigurableIntegrations = validateConfigurableIntegrations;
|
|
@@ -10,6 +10,6 @@ var common_1 = require("./common");
|
|
|
10
10
|
* @returns {Array} array of valid integration factories. The array might be empty if `settings` object does not have valid integrations.
|
|
11
11
|
*/
|
|
12
12
|
function validatePluggableIntegrations(settings) {
|
|
13
|
-
return common_1.validateIntegrations(settings, function (integration) { return typeof integration === 'function'; }, 'Integration items must be functions that initialize the integrations');
|
|
13
|
+
return (0, common_1.validateIntegrations)(settings, function (integration) { return typeof integration === 'function'; }, 'Integration items must be functions that initialize the integrations');
|
|
14
14
|
}
|
|
15
15
|
exports.validatePluggableIntegrations = validatePluggableIntegrations;
|
|
@@ -12,7 +12,7 @@ var pluggable_1 = require("./pluggable");
|
|
|
12
12
|
*/
|
|
13
13
|
function validateLocalhostWithDefault(settings) {
|
|
14
14
|
if (!settings.sync.localhostMode)
|
|
15
|
-
return LocalhostFromObject_1.LocalhostFromObject();
|
|
16
|
-
return pluggable_1.validateLocalhost(settings) || LocalhostFromObject_1.LocalhostFromObject();
|
|
15
|
+
return (0, LocalhostFromObject_1.LocalhostFromObject)();
|
|
16
|
+
return (0, pluggable_1.validateLocalhost)(settings) || (0, LocalhostFromObject_1.LocalhostFromObject)();
|
|
17
17
|
}
|
|
18
18
|
exports.validateLocalhostWithDefault = validateLocalhostWithDefault;
|
|
@@ -19,14 +19,14 @@ var ENV_VAR_KEY = 'SPLITIO_DEBUG';
|
|
|
19
19
|
*/
|
|
20
20
|
var initialState = String(
|
|
21
21
|
// eslint-disable-next-line no-undef
|
|
22
|
-
isNode_1.isNode ? process.env[ENV_VAR_KEY] : isLocalStorageAvailable_1.isLocalStorageAvailable() ? localStorage.getItem(LS_KEY) : '');
|
|
22
|
+
isNode_1.isNode ? process.env[ENV_VAR_KEY] : (0, isLocalStorageAvailable_1.isLocalStorageAvailable)() ? localStorage.getItem(LS_KEY) : '');
|
|
23
23
|
// By default it starts disabled.
|
|
24
24
|
var initialLogLevel = logger_1.LogLevels.NONE;
|
|
25
25
|
// Kept to avoid a breaking change ('on', 'enable' and 'enabled' are equivalent)
|
|
26
26
|
if (/^(enabled?|on)/i.test(initialState)) {
|
|
27
27
|
initialLogLevel = logger_1.LogLevels.DEBUG;
|
|
28
28
|
}
|
|
29
|
-
else if (logger_1.isLogLevelString(initialState)) {
|
|
29
|
+
else if ((0, logger_1.isLogLevelString)(initialState)) {
|
|
30
30
|
initialLogLevel = initialState;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
@@ -37,7 +37,7 @@ else if (logger_1.isLogLevelString(initialState)) {
|
|
|
37
37
|
*/
|
|
38
38
|
function validateLogger(settings) {
|
|
39
39
|
var debug = settings.debug;
|
|
40
|
-
var logLevel = debug !== undefined ? commons_1.getLogLevel(debug) : initialLogLevel;
|
|
40
|
+
var logLevel = debug !== undefined ? (0, commons_1.getLogLevel)(debug) : initialLogLevel;
|
|
41
41
|
var log = new logger_1.Logger({ logLevel: logLevel || initialLogLevel }, allCodes);
|
|
42
42
|
// @ts-ignore // if logLevel is undefined at this point, it means that settings `debug` value is invalid
|
|
43
43
|
if (!logLevel)
|
|
@@ -18,7 +18,7 @@ function getLogLevel(debugValue) {
|
|
|
18
18
|
return logger_1.LogLevels.NONE;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
else if (typeof debugValue === 'string' && logger_1.isLogLevelString(debugValue)) {
|
|
21
|
+
else if (typeof debugValue === 'string' && (0, logger_1.isLogLevelString)(debugValue)) {
|
|
22
22
|
return debugValue;
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
@@ -21,7 +21,7 @@ function validateLogger(settings) {
|
|
|
21
21
|
if (debug !== undefined) {
|
|
22
22
|
if (isLogger(debug))
|
|
23
23
|
return debug;
|
|
24
|
-
logLevel = commons_1.getLogLevel(settings.debug);
|
|
24
|
+
logLevel = (0, commons_1.getLogLevel)(settings.debug);
|
|
25
25
|
}
|
|
26
26
|
var log = new logger_1.Logger({ logLevel: logLevel || initialLogLevel });
|
|
27
27
|
// @ts-ignore // `debug` value is invalid if logLevel is undefined at this point
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateRuntime = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var os_1 = (0, tslib_1.__importDefault)(require("os"));
|
|
6
|
+
var ip_1 = (0, tslib_1.__importDefault)(require("ip"));
|
|
7
|
+
var constants_1 = require("../../constants");
|
|
8
|
+
function validateRuntime(settings) {
|
|
9
|
+
var isIPAddressesEnabled = settings.core.IPAddressesEnabled === true;
|
|
10
|
+
var isConsumerMode = settings.mode === constants_1.CONSUMER_MODE;
|
|
11
|
+
// If the values are not available, default to false (for standalone) or "unknown" (for consumer mode, to be used on Redis keys)
|
|
12
|
+
var ip = ip_1.default.address() || (isConsumerMode ? constants_1.UNKNOWN : false);
|
|
13
|
+
var hostname = os_1.default.hostname() || (isConsumerMode ? constants_1.UNKNOWN : false);
|
|
14
|
+
if (!isIPAddressesEnabled) { // If IPAddresses setting is not enabled, set as false (for standalone) or "NA" (for consumer mode, to be used on Redis keys)
|
|
15
|
+
ip = hostname = isConsumerMode ? constants_1.NA : false;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
ip: ip,
|
|
19
|
+
hostname: hostname
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.validateRuntime = validateRuntime;
|
|
@@ -36,7 +36,7 @@ function validateFilterType(maybeFilterType) {
|
|
|
36
36
|
*/
|
|
37
37
|
function validateSplitFilter(log, type, values, maxLength) {
|
|
38
38
|
// validate and remove invalid and duplicated values
|
|
39
|
-
var result = splits_1.validateSplits(log, values, constants_2.LOG_PREFIX_SETTINGS, type + " filter", type + " filter value");
|
|
39
|
+
var result = (0, splits_1.validateSplits)(log, values, constants_2.LOG_PREFIX_SETTINGS, type + " filter", type + " filter value");
|
|
40
40
|
if (result) {
|
|
41
41
|
// check max length
|
|
42
42
|
if (result.length > maxLength)
|
|
@@ -5,7 +5,7 @@ var InMemoryStorageCS_1 = require("../../../storages/inMemory/InMemoryStorageCS"
|
|
|
5
5
|
var constants_1 = require("../../../logger/constants");
|
|
6
6
|
var constants_2 = require("../../../utils/constants");
|
|
7
7
|
function __InLocalStorageMockFactory(params) {
|
|
8
|
-
var result = InMemoryStorageCS_1.InMemoryStorageCSFactory(params);
|
|
8
|
+
var result = (0, InMemoryStorageCS_1.InMemoryStorageCSFactory)(params);
|
|
9
9
|
result.splits.checkCache = function () { return true; }; // to emit SDK_READY_FROM_CACHE
|
|
10
10
|
return result;
|
|
11
11
|
}
|
|
@@ -125,12 +125,12 @@ exports.TrackerAPI = {
|
|
|
125
125
|
* @return {Function | Promise} The stop function for this specific task or the promise received with the callbacks registered.
|
|
126
126
|
*/
|
|
127
127
|
start: function (log, task, collectors, promise, now) {
|
|
128
|
-
var taskUniqueId = lang_1.uniqueId();
|
|
128
|
+
var taskUniqueId = (0, lang_1.uniqueId)();
|
|
129
129
|
var taskCollector = getCollectorForTask(task, collectors);
|
|
130
130
|
var result;
|
|
131
131
|
// If we are registering a promise with this task, we should count the status and the exceptions as well
|
|
132
132
|
// as stopping the task when the promise resolves. Then return the promise
|
|
133
|
-
if (thenable_1.thenable(promise)) {
|
|
133
|
+
if ((0, thenable_1.thenable)(promise)) {
|
|
134
134
|
result = this.__attachToPromise(log, promise, task, taskCollector, taskUniqueId);
|
|
135
135
|
}
|
|
136
136
|
else {
|
|
@@ -147,7 +147,7 @@ exports.TrackerAPI = {
|
|
|
147
147
|
var cb = getCallbackForTask(task, taskCollector);
|
|
148
148
|
timers[trackingKey] = {
|
|
149
149
|
cb: cb,
|
|
150
|
-
timer: timer_1.timer(now)
|
|
150
|
+
timer: (0, timer_1.timer)(now)
|
|
151
151
|
};
|
|
152
152
|
return result;
|
|
153
153
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ENGINE_MATCHER_ENDS_WITH } from '../../logger/constants';
|
|
2
|
-
import { endsWith
|
|
2
|
+
import { endsWith } from '../../utils/lang';
|
|
3
3
|
export function endsWithMatcherContext(log, ruleAttr) {
|
|
4
4
|
return function endsWithMatcher(runtimeAttr) {
|
|
5
|
-
var
|
|
6
|
-
log.debug(ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr,
|
|
7
|
-
return
|
|
5
|
+
var strEndsWith = ruleAttr.some(function (e) { return endsWith(runtimeAttr, e); });
|
|
6
|
+
log.debug(ENGINE_MATCHER_ENDS_WITH, [runtimeAttr, ruleAttr, strEndsWith]);
|
|
7
|
+
return strEndsWith;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
@@ -20,10 +20,10 @@ export var codesInfo = codesWarn.concat([
|
|
|
20
20
|
[c.SUBMITTERS_PUSH_FULL_EVENTS_QUEUE, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Flushing full events queue and reseting timer.'],
|
|
21
21
|
[c.SUBMITTERS_PUSH, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Pushing %s %s.'],
|
|
22
22
|
[c.STREAMING_REFRESH_TOKEN, c.LOG_PREFIX_SYNC_STREAMING + 'Refreshing streaming token in %s seconds, and connecting streaming in %s seconds.'],
|
|
23
|
-
[c.STREAMING_RECONNECT, c.LOG_PREFIX_SYNC_STREAMING + 'Attempting to reconnect in %s seconds.'],
|
|
24
|
-
[c.STREAMING_CONNECTING, c.LOG_PREFIX_SYNC_STREAMING + 'Connecting
|
|
23
|
+
[c.STREAMING_RECONNECT, c.LOG_PREFIX_SYNC_STREAMING + 'Attempting to reconnect streaming in %s seconds.'],
|
|
24
|
+
[c.STREAMING_CONNECTING, c.LOG_PREFIX_SYNC_STREAMING + 'Connecting streaming.'],
|
|
25
25
|
[c.STREAMING_DISABLED, c.LOG_PREFIX_SYNC_STREAMING + 'Streaming is disabled for given Api key. Switching to polling mode.'],
|
|
26
|
-
[c.STREAMING_DISCONNECTING, c.LOG_PREFIX_SYNC_STREAMING + 'Disconnecting
|
|
26
|
+
[c.STREAMING_DISCONNECTING, c.LOG_PREFIX_SYNC_STREAMING + 'Disconnecting streaming.'],
|
|
27
27
|
[c.SYNC_START_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming not available. Starting polling.'],
|
|
28
28
|
[c.SYNC_CONTINUE_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming couldn\'t connect. Continue polling.'],
|
|
29
29
|
[c.SYNC_STOP_POLLING, c.LOG_PREFIX_SYNC_MANAGER + 'Streaming (re)connected. Syncing and stopping polling.'],
|
package/esm/sdkClient/client.js
CHANGED
|
@@ -16,6 +16,7 @@ export function clientCSDecorator(log, client, key, trafficType) {
|
|
|
16
16
|
getTreatments: clientCS.getTreatments.bind(clientCS, key),
|
|
17
17
|
getTreatmentsWithConfig: clientCS.getTreatmentsWithConfig.bind(clientCS, key),
|
|
18
18
|
// Key is bound to the `track` method. Same thing happens with trafficType but only if provided
|
|
19
|
-
track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key)
|
|
19
|
+
track: trafficType ? clientCS.track.bind(clientCS, key, trafficType) : clientCS.track.bind(clientCS, key),
|
|
20
|
+
isBrowserClient: true
|
|
20
21
|
});
|
|
21
22
|
}
|
package/esm/services/splitApi.js
CHANGED
|
@@ -72,7 +72,8 @@ export function splitApiFactory(settings, platform) {
|
|
|
72
72
|
return splitHttpClient(url, {
|
|
73
73
|
// Adding extra headers to send impressions in OPTIMIZED or DEBUG modes.
|
|
74
74
|
method: 'POST',
|
|
75
|
-
body: body,
|
|
75
|
+
body: body,
|
|
76
|
+
headers: objectAssign({ SplitSDKImpressionsMode: SplitSDKImpressionsMode }, headers)
|
|
76
77
|
});
|
|
77
78
|
},
|
|
78
79
|
/**
|
|
@@ -43,7 +43,7 @@ export function splitHttpClientFactory(settings, getFetch, getOptions) {
|
|
|
43
43
|
return response;
|
|
44
44
|
})
|
|
45
45
|
.catch(function (error) {
|
|
46
|
-
var resp = error.response;
|
|
46
|
+
var resp = error && error.response;
|
|
47
47
|
var msg = '';
|
|
48
48
|
if (resp) { // An HTTP error
|
|
49
49
|
switch (resp.status) {
|
|
@@ -151,7 +151,13 @@ var RedisAdapter = /** @class */ (function (_super) {
|
|
|
151
151
|
RedisAdapter._defineOptions = function (_a) {
|
|
152
152
|
var connectionTimeout = _a.connectionTimeout, operationTimeout = _a.operationTimeout, url = _a.url, host = _a.host, port = _a.port, db = _a.db, pass = _a.pass;
|
|
153
153
|
var parsedOptions = {
|
|
154
|
-
connectionTimeout: connectionTimeout,
|
|
154
|
+
connectionTimeout: connectionTimeout,
|
|
155
|
+
operationTimeout: operationTimeout,
|
|
156
|
+
url: url,
|
|
157
|
+
host: host,
|
|
158
|
+
port: port,
|
|
159
|
+
db: db,
|
|
160
|
+
pass: pass
|
|
155
161
|
};
|
|
156
162
|
return merge({}, DEFAULT_OPTIONS, parsedOptions);
|
|
157
163
|
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Factory of MySegments fetcher.
|
|
3
3
|
* MySegments fetcher is a wrapper around `mySegments` API service that parses the response and handle errors.
|
|
4
4
|
*/
|
|
5
|
-
export function mySegmentsFetcherFactory(fetchMySegments
|
|
6
|
-
return function mySegmentsFetcher(noCache,
|
|
5
|
+
export function mySegmentsFetcherFactory(fetchMySegments) {
|
|
6
|
+
return function mySegmentsFetcher(userMatchingKey, noCache,
|
|
7
7
|
// Optional decorator for `fetchMySegments` promise, such as timeout or time tracker
|
|
8
8
|
decorator) {
|
|
9
9
|
var mySegmentsPromise = fetchMySegments(userMatchingKey, noCache);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __spreadArray } from "tslib";
|
|
2
2
|
function greedyFetch(fetchSegmentChanges, since, segmentName, noCache) {
|
|
3
3
|
return fetchSegmentChanges(since, segmentName, noCache)
|
|
4
4
|
.then(function (resp) { return resp.json(); })
|
|
@@ -9,7 +9,7 @@ function greedyFetch(fetchSegmentChanges, since, segmentName, noCache) {
|
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
11
|
return Promise.all([json, greedyFetch(fetchSegmentChanges, till, segmentName, noCache)]).then(function (flatMe) {
|
|
12
|
-
return
|
|
12
|
+
return __spreadArray([flatMe[0]], flatMe[1], true);
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -8,7 +8,8 @@ import { POLLING_SMART_PAUSING, POLLING_START, POLLING_STOP } from '../../logger
|
|
|
8
8
|
* Expose start / stop mechanism for polling data from services.
|
|
9
9
|
* For client-side API with multiple clients.
|
|
10
10
|
*/
|
|
11
|
-
export function pollingManagerCSFactory(
|
|
11
|
+
export function pollingManagerCSFactory(params) {
|
|
12
|
+
var splitApi = params.splitApi, storage = params.storage, readiness = params.readiness, settings = params.settings;
|
|
12
13
|
var log = settings.log;
|
|
13
14
|
var splitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
|
|
14
15
|
// Map of matching keys to their corresponding MySegmentsSyncTask.
|
|
@@ -5,7 +5,8 @@ import { POLLING_START, POLLING_STOP, LOG_PREFIX_SYNC_POLLING } from '../../logg
|
|
|
5
5
|
/**
|
|
6
6
|
* Expose start / stop mechanism for pulling data from services.
|
|
7
7
|
*/
|
|
8
|
-
export function pollingManagerSSFactory(
|
|
8
|
+
export function pollingManagerSSFactory(params) {
|
|
9
|
+
var splitApi = params.splitApi, storage = params.storage, readiness = params.readiness, settings = params.settings;
|
|
9
10
|
var log = settings.log;
|
|
10
11
|
var splitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
|
|
11
12
|
var segmentsSyncTask = segmentsSyncTaskFactory(splitApi.fetchSegmentChanges, storage, readiness, settings);
|
|
@@ -5,5 +5,5 @@ import { mySegmentsUpdaterFactory } from '../updaters/mySegmentsUpdater';
|
|
|
5
5
|
* Creates a sync task that periodically executes a `mySegmentsUpdater` task
|
|
6
6
|
*/
|
|
7
7
|
export function mySegmentsSyncTaskFactory(fetchMySegments, storage, readiness, settings, matchingKey) {
|
|
8
|
-
return syncTaskFactory(settings.log, mySegmentsUpdaterFactory(settings.log, mySegmentsFetcherFactory(fetchMySegments
|
|
8
|
+
return syncTaskFactory(settings.log, mySegmentsUpdaterFactory(settings.log, mySegmentsFetcherFactory(fetchMySegments), storage.splits, storage.segments, readiness.segments, settings.startup.requestTimeoutBeforeReady, settings.startup.retriesOnFailureBeforeReady, matchingKey), settings.scheduler.segmentsRefreshRate, 'mySegmentsUpdater');
|
|
9
9
|
}
|
|
@@ -7,7 +7,7 @@ import { SYNC_MYSEGMENTS_FETCH_RETRY } from '../../../logger/constants';
|
|
|
7
7
|
* - updates `mySegmentsCache`
|
|
8
8
|
* - uses `segmentsEventEmitter` to emit events related to segments data updates
|
|
9
9
|
*/
|
|
10
|
-
export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegmentsCache, segmentsEventEmitter, requestTimeoutBeforeReady, retriesOnFailureBeforeReady) {
|
|
10
|
+
export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, mySegmentsCache, segmentsEventEmitter, requestTimeoutBeforeReady, retriesOnFailureBeforeReady, matchingKey) {
|
|
11
11
|
var readyOnAlreadyExistentState = true;
|
|
12
12
|
var startingUp = true;
|
|
13
13
|
/** timeout and telemetry decorator for `splitChangesFetcher` promise */
|
|
@@ -51,7 +51,7 @@ export function mySegmentsUpdaterFactory(log, mySegmentsFetcher, splitsCache, my
|
|
|
51
51
|
// If segmentsData is provided, there is no need to fetch mySegments
|
|
52
52
|
new Promise(function (res) { updateSegments(segmentsData); res(true); }) :
|
|
53
53
|
// If not provided, fetch mySegments
|
|
54
|
-
mySegmentsFetcher(noCache, _promiseDecorator).then(function (segments) {
|
|
54
|
+
mySegmentsFetcher(matchingKey, noCache, _promiseDecorator).then(function (segments) {
|
|
55
55
|
// Only when we have downloaded segments completely, we should not keep retrying anymore
|
|
56
56
|
startingUp = false;
|
|
57
57
|
updateSegments(segments);
|
|
@@ -13,8 +13,7 @@ export function authenticateFactory(fetchAuth) {
|
|
|
13
13
|
* @param {string[] | undefined} userKeys set of user Keys to track MY_SEGMENTS_CHANGES. It is undefined for server-side API.
|
|
14
14
|
*/
|
|
15
15
|
return function authenticate(userKeys) {
|
|
16
|
-
|
|
17
|
-
return authPromise
|
|
16
|
+
return fetchAuth(userKeys)
|
|
18
17
|
.then(function (resp) { return resp.json(); })
|
|
19
18
|
.then(function (json) {
|
|
20
19
|
if (json.token) { // empty token when `"pushEnabled": false`
|
|
@@ -7,7 +7,7 @@ var SegmentsUpdateWorker = /** @class */ (function () {
|
|
|
7
7
|
* @param {Object} segmentsCache segments data cache
|
|
8
8
|
* @param {Object} segmentsSyncTask task for syncing segments data
|
|
9
9
|
*/
|
|
10
|
-
function SegmentsUpdateWorker(
|
|
10
|
+
function SegmentsUpdateWorker(segmentsSyncTask, segmentsCache) {
|
|
11
11
|
this.segmentsCache = segmentsCache;
|
|
12
12
|
this.segmentsSyncTask = segmentsSyncTask;
|
|
13
13
|
this.maxChangeNumbers = {};
|
|
@@ -19,10 +19,11 @@ import { hash64 } from '../../utils/murmur3/murmur3_64';
|
|
|
19
19
|
* - for server-side if key is not provided in settings.
|
|
20
20
|
* - for client-side, with support for multiple clients, if key is provided in settings
|
|
21
21
|
*/
|
|
22
|
-
export function pushManagerFactory(
|
|
22
|
+
export function pushManagerFactory(params, pollingManager) {
|
|
23
|
+
var settings = params.settings, storage = params.storage, splitApi = params.splitApi, readiness = params.readiness, platform = params.platform;
|
|
23
24
|
// `userKey` is the matching key of main client in client-side SDK.
|
|
24
25
|
// It can be used to check if running on client-side or server-side SDK.
|
|
25
|
-
var userKey = settings.core.key ? getMatching(settings.core.key) : undefined;
|
|
26
|
+
var userKey = settings.core.key ? getMatching(settings.core.key) : undefined;
|
|
26
27
|
var log = settings.log;
|
|
27
28
|
var sseClient;
|
|
28
29
|
try {
|
|
@@ -33,13 +34,14 @@ export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth
|
|
|
33
34
|
log.warn(STREAMING_FALLBACK, [e]);
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
var authenticate = authenticateFactory(fetchAuth);
|
|
37
|
+
var authenticate = authenticateFactory(splitApi.fetchAuth);
|
|
37
38
|
// init feedback loop
|
|
38
39
|
var pushEmitter = new platform.EventEmitter();
|
|
39
40
|
var sseHandler = SSEHandlerFactory(log, pushEmitter);
|
|
40
41
|
sseClient.setEventHandler(sseHandler);
|
|
41
42
|
// init workers
|
|
42
|
-
|
|
43
|
+
// MySegmentsUpdateWorker (client-side) are initiated in `add` method
|
|
44
|
+
var segmentsUpdateWorker = userKey ? undefined : new SegmentsUpdateWorker(pollingManager.segmentsSyncTask, storage.segments);
|
|
43
45
|
// For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
|
|
44
46
|
var splitsUpdateWorker = new SplitsUpdateWorker(storage.splits, pollingManager.splitsSyncTask, readiness.splits, userKey ? undefined : pollingManager.segmentsSyncTask);
|
|
45
47
|
// [Only for client-side] map of hashes to user keys, to dispatch MY_SEGMENTS_UPDATE events to the corresponding MySegmentsUpdateWorker
|
|
@@ -47,11 +49,6 @@ export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth
|
|
|
47
49
|
// [Only for client-side] map of user keys to their corresponding hash64 and MySegmentsUpdateWorkers.
|
|
48
50
|
// Hash64 is used to process MY_SEGMENTS_UPDATE_V2 events and dispatch actions to the corresponding MySegmentsUpdateWorker.
|
|
49
51
|
var clients = {};
|
|
50
|
-
if (userKey) {
|
|
51
|
-
var hash = hashUserKey(userKey);
|
|
52
|
-
userKeyHashes[hash] = userKey;
|
|
53
|
-
clients[userKey] = { hash64: hash64(userKey), worker: segmentsUpdateWorker };
|
|
54
|
-
}
|
|
55
52
|
// [Only for client-side] variable to flag that a new client was added. It is needed to reconnect streaming.
|
|
56
53
|
var connectForNewClient = false;
|
|
57
54
|
// flag that indicates if `stop/disconnectPush` was called, either by the SyncManager, when the client is destroyed, or due to a PUSH_NONRETRYABLE_ERROR error.
|
|
@@ -258,33 +255,40 @@ export function pushManagerFactory(pollingManager, storage, readiness, fetchAuth
|
|
|
258
255
|
return objectAssign(
|
|
259
256
|
// Expose Event Emitter functionality and Event constants
|
|
260
257
|
Object.create(pushEmitter), {
|
|
261
|
-
//
|
|
262
|
-
stop:
|
|
258
|
+
// Stop/pause push mode
|
|
259
|
+
stop: function () {
|
|
260
|
+
disconnectPush(); // `handleNonRetryableError` cannot be used as `stop`, because it emits PUSH_SUBSYSTEM_DOWN event, which starts polling.
|
|
261
|
+
if (userKey)
|
|
262
|
+
this.remove(userKey); // Necessary to properly resume streaming in client-side (e.g., RN SDK transition to foreground).
|
|
263
|
+
},
|
|
264
|
+
// Start/resume push mode
|
|
263
265
|
start: function () {
|
|
264
266
|
// Guard condition to avoid calling `connectPush` again if the `start` method is called multiple times or if push has been disabled.
|
|
265
267
|
if (disabled || disconnected === false)
|
|
266
268
|
return;
|
|
267
269
|
disconnected = false;
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
if (userKey)
|
|
271
|
+
this.add(userKey, pollingManager.segmentsSyncTask); // client-side
|
|
272
|
+
else
|
|
273
|
+
setTimeout(connectPush); // server-side runs in next cycle as in client-side, for consistency with client-side
|
|
270
274
|
},
|
|
271
275
|
// [Only for client-side]
|
|
272
276
|
add: function (userKey, mySegmentsSyncTask) {
|
|
273
|
-
clients[userKey] = { hash64: hash64(userKey), worker: new MySegmentsUpdateWorker(mySegmentsSyncTask) };
|
|
274
277
|
var hash = hashUserKey(userKey);
|
|
275
278
|
if (!userKeyHashes[hash]) {
|
|
276
279
|
userKeyHashes[hash] = userKey;
|
|
280
|
+
clients[userKey] = { hash64: hash64(userKey), worker: new MySegmentsUpdateWorker(mySegmentsSyncTask) };
|
|
277
281
|
connectForNewClient = true; // we must reconnect on start, to listen the channel for the new user key
|
|
282
|
+
// Reconnects in case of a new client.
|
|
283
|
+
// Run in next event-loop cycle to save authentication calls
|
|
284
|
+
// in case multiple clients are created in the current cycle.
|
|
285
|
+
setTimeout(function checkForReconnect() {
|
|
286
|
+
if (connectForNewClient) {
|
|
287
|
+
connectForNewClient = false;
|
|
288
|
+
connectPush();
|
|
289
|
+
}
|
|
290
|
+
}, 0);
|
|
278
291
|
}
|
|
279
|
-
// Reconnects in case of a new client.
|
|
280
|
-
// Run in next event-loop cycle to save authentication calls
|
|
281
|
-
// in case the user is creating several clients in the current cycle.
|
|
282
|
-
setTimeout(function checkForReconnect() {
|
|
283
|
-
if (connectForNewClient) {
|
|
284
|
-
connectForNewClient = false;
|
|
285
|
-
connectPush();
|
|
286
|
-
}
|
|
287
|
-
}, 0);
|
|
288
292
|
},
|
|
289
293
|
// [Only for client-side]
|
|
290
294
|
remove: function (userKey) {
|
|
@@ -2,7 +2,8 @@ import { syncTaskComposite } from '../syncTaskComposite';
|
|
|
2
2
|
import { eventsSyncTaskFactory } from './eventsSyncTask';
|
|
3
3
|
import { impressionsSyncTaskFactory } from './impressionsSyncTask';
|
|
4
4
|
import { impressionCountsSyncTaskFactory } from './impressionCountsSyncTask';
|
|
5
|
-
export function submitterManagerFactory(
|
|
5
|
+
export function submitterManagerFactory(params) {
|
|
6
|
+
var settings = params.settings, storage = params.storage, splitApi = params.splitApi;
|
|
6
7
|
var log = settings.log;
|
|
7
8
|
var submitters = [
|
|
8
9
|
impressionsSyncTaskFactory(log, splitApi.postTestImpressionsBulk, storage.impressions, settings.scheduler.impressionsRefreshRate, settings.core.labelsEnabled),
|
|
@@ -13,26 +13,25 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
|
|
|
13
13
|
/**
|
|
14
14
|
* SyncManager factory for modular SDK
|
|
15
15
|
*/
|
|
16
|
-
return function (
|
|
17
|
-
var
|
|
18
|
-
var log = settings.log;
|
|
16
|
+
return function (params) {
|
|
17
|
+
var _a = params.settings, log = _a.log, streamingEnabled = _a.streamingEnabled;
|
|
19
18
|
/** Polling Manager */
|
|
20
|
-
var pollingManager = pollingManagerFactory && pollingManagerFactory(
|
|
19
|
+
var pollingManager = pollingManagerFactory && pollingManagerFactory(params);
|
|
21
20
|
/** Push Manager */
|
|
22
|
-
var pushManager =
|
|
23
|
-
pushManagerFactory(
|
|
21
|
+
var pushManager = streamingEnabled && pollingManager && pushManagerFactory ?
|
|
22
|
+
pushManagerFactory(params, pollingManager) :
|
|
24
23
|
undefined;
|
|
25
24
|
/** Submitter Manager */
|
|
26
25
|
// It is not inyected as push and polling managers, because at the moment it is required
|
|
27
|
-
var submitter = submitterManagerFactory(
|
|
26
|
+
var submitter = submitterManagerFactory(params);
|
|
28
27
|
/** Sync Manager logic */
|
|
29
28
|
function startPolling() {
|
|
30
|
-
if (
|
|
31
|
-
log.info(
|
|
32
|
-
pollingManager.start();
|
|
29
|
+
if (pollingManager.isRunning()) {
|
|
30
|
+
log.info(SYNC_CONTINUE_POLLING);
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
35
|
-
log.info(
|
|
33
|
+
log.info(SYNC_START_POLLING);
|
|
34
|
+
pollingManager.start();
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
function stopPollingAndSyncAll() {
|
|
@@ -70,7 +69,8 @@ export function syncManagerOnlineFactory(pollingManagerFactory, pushManagerFacto
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
// start periodic data recording (events, impressions, telemetry).
|
|
73
|
-
|
|
72
|
+
if (submitter)
|
|
73
|
+
submitter.start();
|
|
74
74
|
running = true;
|
|
75
75
|
},
|
|
76
76
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isObject,
|
|
1
|
+
import { isObject, isString, isFiniteNumber, isBoolean } from '../lang';
|
|
2
|
+
import { objectAssign } from '../lang/objectAssign';
|
|
2
3
|
import { ERROR_NOT_PLAIN_OBJECT, ERROR_SIZE_EXCEEDED, WARN_SETTING_NULL, WARN_TRIMMING_PROPERTIES } from '../../logger/constants';
|
|
3
4
|
var ECMA_SIZES = {
|
|
4
5
|
NULL: 0,
|
|
@@ -17,7 +18,8 @@ export function validateEventProperties(log, maybeProperties, method) {
|
|
|
17
18
|
return { properties: false, size: BASE_EVENT_SIZE };
|
|
18
19
|
}
|
|
19
20
|
var keys = Object.keys(maybeProperties);
|
|
20
|
-
|
|
21
|
+
// Shallow clone
|
|
22
|
+
var clone = objectAssign({}, maybeProperties);
|
|
21
23
|
// To avoid calculating the size twice we'll return it from here.
|
|
22
24
|
var output = {
|
|
23
25
|
properties: clone,
|
|
@@ -35,7 +35,8 @@ export function validateKey(log, maybeKey, method) {
|
|
|
35
35
|
var bucketingKey = validateKeyValue(log, maybeKey.bucketingKey, method, 'bucketingKey');
|
|
36
36
|
if (matchingKey && bucketingKey)
|
|
37
37
|
return {
|
|
38
|
-
matchingKey: matchingKey,
|
|
38
|
+
matchingKey: matchingKey,
|
|
39
|
+
bucketingKey: bucketingKey
|
|
39
40
|
};
|
|
40
41
|
log.error(ERROR_INVALID_KEY_OBJECT, [method]);
|
|
41
42
|
return false;
|