@splitsoftware/splitio-commons 1.2.1-rc.0 → 1.2.1-rc.4
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 +1 -1
- package/cjs/listeners/node.js +1 -1
- package/cjs/logger/constants.js +4 -2
- package/cjs/logger/index.js +2 -2
- package/cjs/logger/messages/debug.js +1 -1
- package/cjs/logger/messages/error.js +2 -2
- package/cjs/logger/messages/info.js +3 -3
- 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 +9 -9
- package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
- package/cjs/sdkClient/clientCS.js +2 -2
- 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 +9 -8
- 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 -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 +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 +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 +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/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 +4 -3
- package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
- package/cjs/sync/submitters/impressionsSyncTask.js +11 -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 +8 -13
- 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/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/index.js +7 -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.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/logger/constants.js +1 -1
- package/esm/logger/messages/error.js +1 -1
- package/esm/logger/messages/info.js +2 -2
- package/esm/sdkFactory/index.js +1 -0
- package/esm/services/splitApi.js +2 -1
- 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 +7 -1
- 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/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
- package/esm/sync/streaming/pushManager.js +13 -5
- package/esm/sync/submitters/eventsSyncTask.js +5 -4
- package/esm/sync/submitters/impressionsSyncTask.js +9 -1
- package/esm/sync/submitters/submitterManager.js +2 -1
- package/esm/sync/syncManagerOnline.js +8 -13
- 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/settingsValidation/index.js +3 -6
- package/esm/utils/settingsValidation/runtime.js +7 -0
- package/package.json +6 -6
- package/src/evaluator/matchers/ew.ts +4 -4
- package/src/integrations/ga/GoogleAnalyticsToSplit.ts +7 -4
- package/src/integrations/ga/SplitToGoogleAnalytics.ts +7 -4
- package/src/integrations/types.ts +5 -0
- package/src/logger/constants.ts +1 -1
- package/src/logger/messages/error.ts +1 -1
- package/src/logger/messages/info.ts +2 -2
- package/src/logger/types.ts +4 -0
- package/src/sdkFactory/index.ts +1 -0
- 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/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/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 +6 -4
- package/src/sync/submitters/impressionsSyncTask.ts +12 -1
- package/src/sync/submitters/submitterManager.ts +4 -8
- package/src/sync/syncManagerOnline.ts +14 -24
- package/src/types.ts +15 -0
- package/src/utils/inputValidation/eventProperties.ts +4 -2
- package/src/utils/lang/index.ts +0 -14
- package/src/utils/settingsValidation/index.ts +3 -6
- package/src/utils/settingsValidation/runtime.ts +9 -0
- package/src/utils/settingsValidation/types.ts +6 -6
- 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 +1 -1
- package/types/logger/types.d.ts +4 -0
- package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
- package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +9 -0
- package/types/storages/inMemory/index.d.ts +10 -0
- 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/types.d.ts +15 -0
- package/types/utils/lang/index.d.ts +0 -4
- 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 +6 -6
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { ISegmentsSyncTask, ISplitsSyncTask, IPollingManagerCS } from './types';
|
|
2
2
|
import { forOwn } from '../../utils/lang';
|
|
3
3
|
import { IReadinessManager } from '../../readiness/types';
|
|
4
|
-
import { ISplitApi } from '../../services/types';
|
|
5
4
|
import { IStorageSync } from '../../storages/types';
|
|
6
5
|
import { mySegmentsSyncTaskFactory } from './syncTasks/mySegmentsSyncTask';
|
|
7
6
|
import { splitsSyncTaskFactory } from './syncTasks/splitsSyncTask';
|
|
8
|
-
import { ISettings } from '../../types';
|
|
9
7
|
import { getMatching } from '../../utils/key';
|
|
10
8
|
import { SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED } from '../../readiness/constants';
|
|
11
9
|
import { POLLING_SMART_PAUSING, POLLING_START, POLLING_STOP } from '../../logger/constants';
|
|
10
|
+
import { ISyncManagerFactoryParams } from '../types';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Expose start / stop mechanism for polling data from services.
|
|
15
14
|
* For client-side API with multiple clients.
|
|
16
15
|
*/
|
|
17
16
|
export function pollingManagerCSFactory(
|
|
18
|
-
|
|
19
|
-
storage: IStorageSync,
|
|
20
|
-
readiness: IReadinessManager,
|
|
21
|
-
settings: ISettings,
|
|
17
|
+
params: ISyncManagerFactoryParams
|
|
22
18
|
): IPollingManagerCS {
|
|
23
19
|
|
|
20
|
+
const { splitApi, storage, readiness, settings } = params;
|
|
24
21
|
const log = settings.log;
|
|
25
22
|
|
|
26
23
|
const splitsSyncTask: ISplitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
import { splitsSyncTaskFactory } from './syncTasks/splitsSyncTask';
|
|
2
2
|
import { segmentsSyncTaskFactory } from './syncTasks/segmentsSyncTask';
|
|
3
|
-
import { IStorageSync } from '../../storages/types';
|
|
4
|
-
import { IReadinessManager } from '../../readiness/types';
|
|
5
|
-
import { ISplitApi } from '../../services/types';
|
|
6
|
-
import { ISettings } from '../../types';
|
|
7
3
|
import { IPollingManager, ISegmentsSyncTask, ISplitsSyncTask } from './types';
|
|
8
4
|
import { thenable } from '../../utils/promise/thenable';
|
|
9
5
|
import { POLLING_START, POLLING_STOP, LOG_PREFIX_SYNC_POLLING } from '../../logger/constants';
|
|
6
|
+
import { ISyncManagerFactoryParams } from '../types';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* Expose start / stop mechanism for pulling data from services.
|
|
13
10
|
*/
|
|
14
11
|
export function pollingManagerSSFactory(
|
|
15
|
-
|
|
16
|
-
storage: IStorageSync,
|
|
17
|
-
readiness: IReadinessManager,
|
|
18
|
-
settings: ISettings
|
|
12
|
+
params: ISyncManagerFactoryParams
|
|
19
13
|
): IPollingManager {
|
|
20
14
|
|
|
15
|
+
const { splitApi, storage, readiness, settings } = params;
|
|
21
16
|
const log = settings.log;
|
|
22
17
|
|
|
23
18
|
const splitsSyncTask: ISplitsSyncTask = splitsSyncTaskFactory(splitApi.fetchSplitChanges, storage, readiness, settings);
|
|
@@ -21,12 +21,13 @@ export function mySegmentsSyncTaskFactory(
|
|
|
21
21
|
settings.log,
|
|
22
22
|
mySegmentsUpdaterFactory(
|
|
23
23
|
settings.log,
|
|
24
|
-
mySegmentsFetcherFactory(fetchMySegments
|
|
24
|
+
mySegmentsFetcherFactory(fetchMySegments),
|
|
25
25
|
storage.splits,
|
|
26
26
|
storage.segments,
|
|
27
27
|
readiness.segments,
|
|
28
28
|
settings.startup.requestTimeoutBeforeReady,
|
|
29
29
|
settings.startup.retriesOnFailureBeforeReady,
|
|
30
|
+
matchingKey
|
|
30
31
|
),
|
|
31
32
|
settings.scheduler.segmentsRefreshRate,
|
|
32
33
|
'mySegmentsUpdater',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { IReadinessManager } from '../../readiness/types';
|
|
2
|
-
import { ISplitApi } from '../../services/types';
|
|
3
2
|
import { IStorageSync } from '../../storages/types';
|
|
4
|
-
import { ISettings } from '../../types';
|
|
5
3
|
import { SegmentsData } from '../streaming/SSEHandler/types';
|
|
6
4
|
import { ITask, ISyncTask } from '../types';
|
|
7
5
|
|
|
@@ -23,13 +21,3 @@ export interface IPollingManagerCS extends IPollingManager {
|
|
|
23
21
|
remove(matchingKey: string): void;
|
|
24
22
|
get(matchingKey: string): ISegmentsSyncTask | undefined
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Signature of polling manager factory/constructor
|
|
29
|
-
*/
|
|
30
|
-
export type IPollingManagerFactoryParams = [
|
|
31
|
-
splitApi: ISplitApi,
|
|
32
|
-
storage: IStorageSync,
|
|
33
|
-
readiness: IReadinessManager,
|
|
34
|
-
settings: ISettings,
|
|
35
|
-
]
|
|
@@ -23,6 +23,7 @@ export function mySegmentsUpdaterFactory(
|
|
|
23
23
|
segmentsEventEmitter: ISegmentsEventEmitter,
|
|
24
24
|
requestTimeoutBeforeReady: number,
|
|
25
25
|
retriesOnFailureBeforeReady: number,
|
|
26
|
+
matchingKey: string
|
|
26
27
|
): IMySegmentsUpdater {
|
|
27
28
|
|
|
28
29
|
let readyOnAlreadyExistentState = true;
|
|
@@ -69,7 +70,7 @@ export function mySegmentsUpdaterFactory(
|
|
|
69
70
|
// If segmentsData is provided, there is no need to fetch mySegments
|
|
70
71
|
new Promise((res) => { updateSegments(segmentsData); res(true); }) :
|
|
71
72
|
// If not provided, fetch mySegments
|
|
72
|
-
mySegmentsFetcher(noCache, _promiseDecorator).then(segments => {
|
|
73
|
+
mySegmentsFetcher(matchingKey, noCache, _promiseDecorator).then(segments => {
|
|
73
74
|
// Only when we have downloaded segments completely, we should not keep retrying anymore
|
|
74
75
|
startingUp = false;
|
|
75
76
|
|
|
@@ -19,7 +19,7 @@ export class SegmentsUpdateWorker implements IUpdateWorker {
|
|
|
19
19
|
* @param {Object} segmentsCache segments data cache
|
|
20
20
|
* @param {Object} segmentsSyncTask task for syncing segments data
|
|
21
21
|
*/
|
|
22
|
-
constructor(
|
|
22
|
+
constructor(segmentsSyncTask: ISegmentsSyncTask, segmentsCache: ISegmentsCacheSync) {
|
|
23
23
|
this.segmentsCache = segmentsCache;
|
|
24
24
|
this.segmentsSyncTask = segmentsSyncTask;
|
|
25
25
|
this.maxChangeNumbers = {};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { IPushEventEmitter,
|
|
1
|
+
import { IPushEventEmitter, IPushManager } from './types';
|
|
2
2
|
import { ISSEClient } from './SSEClient/types';
|
|
3
|
-
import { IStorageSync } from '../../storages/types';
|
|
4
|
-
import { IReadinessManager } from '../../readiness/types';
|
|
5
3
|
import { ISegmentsSyncTask, IPollingManager } from '../polling/types';
|
|
6
4
|
import { objectAssign } from '../../utils/lang/objectAssign';
|
|
7
5
|
import { Backoff } from '../../utils/Backoff';
|
|
@@ -12,17 +10,15 @@ import { SplitsUpdateWorker } from './UpdateWorkers/SplitsUpdateWorker';
|
|
|
12
10
|
import { authenticateFactory, hashUserKey } from './AuthClient';
|
|
13
11
|
import { forOwn } from '../../utils/lang';
|
|
14
12
|
import { SSEClient } from './SSEClient';
|
|
15
|
-
import { IFetchAuth } from '../../services/types';
|
|
16
|
-
import { ISettings } from '../../types';
|
|
17
13
|
import { getMatching } from '../../utils/key';
|
|
18
14
|
import { MY_SEGMENTS_UPDATE, MY_SEGMENTS_UPDATE_V2, PUSH_NONRETRYABLE_ERROR, PUSH_SUBSYSTEM_DOWN, SECONDS_BEFORE_EXPIRATION, SEGMENT_UPDATE, SPLIT_KILL, SPLIT_UPDATE, PUSH_RETRYABLE_ERROR, PUSH_SUBSYSTEM_UP, ControlType } from './constants';
|
|
19
|
-
import { IPlatform } from '../../sdkFactory/types';
|
|
20
15
|
import { STREAMING_FALLBACK, STREAMING_REFRESH_TOKEN, STREAMING_CONNECTING, STREAMING_DISABLED, ERROR_STREAMING_AUTH, STREAMING_DISCONNECTING, STREAMING_RECONNECT, STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 } from '../../logger/constants';
|
|
21
16
|
import { KeyList, UpdateStrategy } from './SSEHandler/types';
|
|
22
17
|
import { isInBitmap, parseBitmap, parseKeyList } from './mySegmentsV2utils';
|
|
23
18
|
import { ISet, _Set } from '../../utils/lang/sets';
|
|
24
19
|
import { Hash64, hash64 } from '../../utils/murmur3/murmur3_64';
|
|
25
20
|
import { IAuthTokenPushEnabled } from './AuthClient/types';
|
|
21
|
+
import { ISyncManagerFactoryParams } from '../types';
|
|
26
22
|
|
|
27
23
|
/**
|
|
28
24
|
* PushManager factory:
|
|
@@ -30,13 +26,11 @@ import { IAuthTokenPushEnabled } from './AuthClient/types';
|
|
|
30
26
|
* - for client-side, with support for multiple clients, if key is provided in settings
|
|
31
27
|
*/
|
|
32
28
|
export function pushManagerFactory(
|
|
29
|
+
params: ISyncManagerFactoryParams,
|
|
33
30
|
pollingManager: IPollingManager,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
platform: IPlatform,
|
|
38
|
-
settings: ISettings,
|
|
39
|
-
): IPushManagerCS | undefined {
|
|
31
|
+
): IPushManager | undefined {
|
|
32
|
+
|
|
33
|
+
const { settings, storage, splitApi, readiness, platform } = params;
|
|
40
34
|
|
|
41
35
|
// `userKey` is the matching key of main client in client-side SDK.
|
|
42
36
|
// It can be used to check if running on client-side or server-side SDK.
|
|
@@ -51,7 +45,7 @@ export function pushManagerFactory(
|
|
|
51
45
|
log.warn(STREAMING_FALLBACK, [e]);
|
|
52
46
|
return;
|
|
53
47
|
}
|
|
54
|
-
const authenticate = authenticateFactory(fetchAuth);
|
|
48
|
+
const authenticate = authenticateFactory(splitApi.fetchAuth);
|
|
55
49
|
|
|
56
50
|
// init feedback loop
|
|
57
51
|
const pushEmitter = new platform.EventEmitter() as IPushEventEmitter;
|
|
@@ -60,7 +54,7 @@ export function pushManagerFactory(
|
|
|
60
54
|
|
|
61
55
|
// init workers
|
|
62
56
|
// MySegmentsUpdateWorker (client-side) are initiated in `add` method
|
|
63
|
-
const segmentsUpdateWorker = userKey ? undefined : new SegmentsUpdateWorker(
|
|
57
|
+
const segmentsUpdateWorker = userKey ? undefined : new SegmentsUpdateWorker(pollingManager.segmentsSyncTask, storage.segments);
|
|
64
58
|
// For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
|
|
65
59
|
const splitsUpdateWorker = new SplitsUpdateWorker(storage.splits, pollingManager.splitsSyncTask, readiness.splits, userKey ? undefined : pollingManager.segmentsSyncTask);
|
|
66
60
|
|
|
@@ -77,6 +71,7 @@ export function pushManagerFactory(
|
|
|
77
71
|
// It is used to halt the `connectPush` process if it was in progress.
|
|
78
72
|
let disconnected: boolean | undefined;
|
|
79
73
|
// flag that indicates a PUSH_NONRETRYABLE_ERROR, condition with which starting pushManager again is ignored.
|
|
74
|
+
// true if STREAMING_DISABLED control event, or 'pushEnabled: false', or non-recoverable SSE or Auth errors.
|
|
80
75
|
let disabled: boolean | undefined; // `disabled` implies `disconnected === true`
|
|
81
76
|
|
|
82
77
|
/** PushManager functions related to initialization */
|
|
@@ -302,12 +297,15 @@ export function pushManagerFactory(
|
|
|
302
297
|
// Expose Event Emitter functionality and Event constants
|
|
303
298
|
Object.create(pushEmitter),
|
|
304
299
|
{
|
|
305
|
-
// Stop/pause push mode
|
|
300
|
+
// Stop/pause push mode.
|
|
301
|
+
// It doesn't emit events. Neither PUSH_SUBSYSTEM_DOWN to start polling.
|
|
306
302
|
stop() {
|
|
307
303
|
disconnectPush(); // `handleNonRetryableError` cannot be used as `stop`, because it emits PUSH_SUBSYSTEM_DOWN event, which starts polling.
|
|
308
304
|
if (userKey) this.remove(userKey); // Necessary to properly resume streaming in client-side (e.g., RN SDK transition to foreground).
|
|
309
305
|
},
|
|
310
|
-
|
|
306
|
+
|
|
307
|
+
// Start/resume push mode.
|
|
308
|
+
// It eventually emits PUSH_SUBSYSTEM_DOWN, that starts polling, or PUSH_SUBSYSTEM_UP, that executes a syncAll
|
|
311
309
|
start() {
|
|
312
310
|
// Guard condition to avoid calling `connectPush` again if the `start` method is called multiple times or if push has been disabled.
|
|
313
311
|
if (disabled || disconnected === false) return;
|
|
@@ -317,6 +315,11 @@ export function pushManagerFactory(
|
|
|
317
315
|
else setTimeout(connectPush); // server-side runs in next cycle as in client-side, for consistency with client-side
|
|
318
316
|
},
|
|
319
317
|
|
|
318
|
+
// true/false if start or stop was called last respectively
|
|
319
|
+
isRunning(){
|
|
320
|
+
return disconnected === false;
|
|
321
|
+
},
|
|
322
|
+
|
|
320
323
|
// [Only for client-side]
|
|
321
324
|
add(userKey: string, mySegmentsSyncTask: ISegmentsSyncTask) {
|
|
322
325
|
const hash = hashUserKey(userKey);
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { IMySegmentsUpdateData, IMySegmentsUpdateV2Data, ISegmentUpdateData, ISplitUpdateData, ISplitKillData } from './SSEHandler/types';
|
|
2
2
|
import { ITask } from '../types';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { IFetchAuth } from '../../services/types';
|
|
6
|
-
import { IStorageSync } from '../../storages/types';
|
|
7
|
-
import { IEventEmitter, ISettings } from '../../types';
|
|
8
|
-
import { IPlatform } from '../../sdkFactory/types';
|
|
3
|
+
import { ISegmentsSyncTask } from '../polling/types';
|
|
4
|
+
import { IEventEmitter } from '../../types';
|
|
9
5
|
import { ControlType } from './constants';
|
|
10
6
|
|
|
11
7
|
// Internal SDK events, subscribed by SyncManager and PushManager
|
|
@@ -45,26 +41,10 @@ export interface IPushEventEmitter extends IEventEmitter {
|
|
|
45
41
|
}
|
|
46
42
|
|
|
47
43
|
/**
|
|
48
|
-
* PushManager
|
|
44
|
+
* PushManager
|
|
49
45
|
*/
|
|
50
|
-
export interface IPushManager extends ITask, IPushEventEmitter {
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* PushManager for client-side with support for multiple clients
|
|
54
|
-
*/
|
|
55
|
-
export interface IPushManagerCS extends IPushManager {
|
|
46
|
+
export interface IPushManager extends ITask, IPushEventEmitter {
|
|
47
|
+
// Methods used in client-side, to support multiple clients
|
|
56
48
|
add(userKey: string, mySegmentsSyncTask: ISegmentsSyncTask): void,
|
|
57
49
|
remove(userKey: string): void
|
|
58
50
|
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Signature of push manager factory/constructor
|
|
62
|
-
*/
|
|
63
|
-
export type IPushManagerFactoryParams = [
|
|
64
|
-
pollingManager: IPollingManager,
|
|
65
|
-
storage: IStorageSync,
|
|
66
|
-
readiness: IReadinessManager,
|
|
67
|
-
fetchAuth: IFetchAuth,
|
|
68
|
-
platform: IPlatform,
|
|
69
|
-
settings: ISettings
|
|
70
|
-
]
|
|
@@ -3,7 +3,9 @@ import { IPostEventsBulk } from '../../services/types';
|
|
|
3
3
|
import { ISyncTask, ITimeTracker } from '../types';
|
|
4
4
|
import { submitterSyncTaskFactory } from './submitterSyncTask';
|
|
5
5
|
import { ILogger } from '../../logger/types';
|
|
6
|
-
import {
|
|
6
|
+
import { SUBMITTERS_PUSH_FULL_QUEUE } from '../../logger/constants';
|
|
7
|
+
|
|
8
|
+
const DATA_NAME = 'events';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Sync task that periodically posts tracked events
|
|
@@ -18,7 +20,7 @@ export function eventsSyncTaskFactory(
|
|
|
18
20
|
): ISyncTask {
|
|
19
21
|
|
|
20
22
|
// don't retry events.
|
|
21
|
-
const syncTask = submitterSyncTaskFactory(log, postEventsBulk, eventsCache, eventsPushRate,
|
|
23
|
+
const syncTask = submitterSyncTaskFactory(log, postEventsBulk, eventsCache, eventsPushRate, DATA_NAME, latencyTracker);
|
|
22
24
|
|
|
23
25
|
// Set a timer for the first push of events,
|
|
24
26
|
if (eventsFirstPushWindow > 0) {
|
|
@@ -34,9 +36,9 @@ export function eventsSyncTaskFactory(
|
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
// register
|
|
39
|
+
// register events submitter to be executed when events cache is full
|
|
38
40
|
eventsCache.setOnFullQueueCb(() => {
|
|
39
|
-
log.info(
|
|
41
|
+
log.info(SUBMITTERS_PUSH_FULL_QUEUE, [DATA_NAME]);
|
|
40
42
|
syncTask.execute();
|
|
41
43
|
});
|
|
42
44
|
|
|
@@ -6,6 +6,9 @@ import { ImpressionDTO } from '../../types';
|
|
|
6
6
|
import { submitterSyncTaskFactory } from './submitterSyncTask';
|
|
7
7
|
import { ImpressionsPayload } from './types';
|
|
8
8
|
import { ILogger } from '../../logger/types';
|
|
9
|
+
import { SUBMITTERS_PUSH_FULL_QUEUE } from '../../logger/constants';
|
|
10
|
+
|
|
11
|
+
const DATA_NAME = 'impressions';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Converts `impressions` data from cache into request payload.
|
|
@@ -50,5 +53,13 @@ export function impressionsSyncTaskFactory(
|
|
|
50
53
|
): ISyncTask {
|
|
51
54
|
|
|
52
55
|
// retry impressions only once.
|
|
53
|
-
|
|
56
|
+
const syncTask = submitterSyncTaskFactory(log, postTestImpressionsBulk, impressionsCache, impressionsRefreshRate, DATA_NAME, latencyTracker, fromImpressionsCollector.bind(undefined, sendLabels), 1);
|
|
57
|
+
|
|
58
|
+
// register impressions submitter to be executed when impressions cache is full
|
|
59
|
+
impressionsCache.setOnFullQueueCb(() => {
|
|
60
|
+
log.info(SUBMITTERS_PUSH_FULL_QUEUE, [DATA_NAME]);
|
|
61
|
+
syncTask.execute();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return syncTask;
|
|
54
65
|
}
|
|
@@ -2,15 +2,11 @@ import { syncTaskComposite } from '../syncTaskComposite';
|
|
|
2
2
|
import { eventsSyncTaskFactory } from './eventsSyncTask';
|
|
3
3
|
import { impressionsSyncTaskFactory } from './impressionsSyncTask';
|
|
4
4
|
import { impressionCountsSyncTaskFactory } from './impressionCountsSyncTask';
|
|
5
|
-
import {
|
|
6
|
-
import { IStorageSync } from '../../storages/types';
|
|
7
|
-
import { ISettings } from '../../types';
|
|
5
|
+
import { ISyncManagerFactoryParams } from '../types';
|
|
8
6
|
|
|
9
|
-
export function submitterManagerFactory(
|
|
10
|
-
|
|
11
|
-
storage
|
|
12
|
-
splitApi: ISplitApi,
|
|
13
|
-
) {
|
|
7
|
+
export function submitterManagerFactory(params: ISyncManagerFactoryParams) {
|
|
8
|
+
|
|
9
|
+
const { settings, storage, splitApi } = params;
|
|
14
10
|
const log = settings.log;
|
|
15
11
|
const submitters = [
|
|
16
12
|
impressionsSyncTaskFactory(log, splitApi.postTestImpressionsBulk, storage.impressions, settings.scheduler.impressionsRefreshRate, settings.core.labelsEnabled),
|
|
@@ -2,8 +2,8 @@ import { ISyncManagerCS, ISyncManagerFactoryParams } from './types';
|
|
|
2
2
|
import { submitterManagerFactory } from './submitters/submitterManager';
|
|
3
3
|
import { IReadinessManager } from '../readiness/types';
|
|
4
4
|
import { IStorageSync } from '../storages/types';
|
|
5
|
-
import {
|
|
6
|
-
import { IPollingManager, IPollingManagerCS
|
|
5
|
+
import { IPushManager } from './streaming/types';
|
|
6
|
+
import { IPollingManager, IPollingManagerCS } from './polling/types';
|
|
7
7
|
import { PUSH_SUBSYSTEM_UP, PUSH_SUBSYSTEM_DOWN } from './streaming/constants';
|
|
8
8
|
import { SYNC_START_POLLING, SYNC_CONTINUE_POLLING, SYNC_STOP_POLLING } from '../logger/constants';
|
|
9
9
|
|
|
@@ -16,34 +16,28 @@ import { SYNC_START_POLLING, SYNC_CONTINUE_POLLING, SYNC_STOP_POLLING } from '..
|
|
|
16
16
|
* @param pushManagerFactory optional to build a SyncManager with or without streaming support
|
|
17
17
|
*/
|
|
18
18
|
export function syncManagerOnlineFactory(
|
|
19
|
-
pollingManagerFactory?: (
|
|
20
|
-
pushManagerFactory?: (
|
|
19
|
+
pollingManagerFactory?: (params: ISyncManagerFactoryParams) => IPollingManager,
|
|
20
|
+
pushManagerFactory?: (params: ISyncManagerFactoryParams, pollingManager: IPollingManager) => IPushManager | undefined,
|
|
21
21
|
): (params: ISyncManagerFactoryParams) => ISyncManagerCS {
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* SyncManager factory for modular SDK
|
|
25
25
|
*/
|
|
26
|
-
return function ({
|
|
27
|
-
settings,
|
|
28
|
-
platform,
|
|
29
|
-
splitApi,
|
|
30
|
-
storage,
|
|
31
|
-
readiness
|
|
32
|
-
}: ISyncManagerFactoryParams): ISyncManagerCS {
|
|
26
|
+
return function (params: ISyncManagerFactoryParams): ISyncManagerCS {
|
|
33
27
|
|
|
34
|
-
const log = settings
|
|
28
|
+
const { log, streamingEnabled } = params.settings;
|
|
35
29
|
|
|
36
30
|
/** Polling Manager */
|
|
37
|
-
const pollingManager = pollingManagerFactory && pollingManagerFactory(
|
|
31
|
+
const pollingManager = pollingManagerFactory && pollingManagerFactory(params);
|
|
38
32
|
|
|
39
33
|
/** Push Manager */
|
|
40
|
-
const pushManager =
|
|
41
|
-
pushManagerFactory(
|
|
34
|
+
const pushManager = streamingEnabled && pollingManager && pushManagerFactory ?
|
|
35
|
+
pushManagerFactory(params, pollingManager) :
|
|
42
36
|
undefined;
|
|
43
37
|
|
|
44
38
|
/** Submitter Manager */
|
|
45
39
|
// It is not inyected as push and polling managers, because at the moment it is required
|
|
46
|
-
const submitter = submitterManagerFactory(
|
|
40
|
+
const submitter = submitterManagerFactory(params);
|
|
47
41
|
|
|
48
42
|
|
|
49
43
|
/** Sync Manager logic */
|
|
@@ -81,9 +75,6 @@ export function syncManagerOnlineFactory(
|
|
|
81
75
|
* Method used to start the syncManager for the first time, or resume it after being stopped.
|
|
82
76
|
*/
|
|
83
77
|
start() {
|
|
84
|
-
if (running) return;
|
|
85
|
-
running = true;
|
|
86
|
-
|
|
87
78
|
// start syncing splits and segments
|
|
88
79
|
if (pollingManager) {
|
|
89
80
|
if (pushManager) {
|
|
@@ -100,21 +91,20 @@ export function syncManagerOnlineFactory(
|
|
|
100
91
|
|
|
101
92
|
// start periodic data recording (events, impressions, telemetry).
|
|
102
93
|
if (submitter) submitter.start();
|
|
94
|
+
running = true;
|
|
103
95
|
},
|
|
104
96
|
|
|
105
97
|
/**
|
|
106
98
|
* Method used to stop/pause the syncManager.
|
|
107
99
|
*/
|
|
108
100
|
stop() {
|
|
109
|
-
if (!running) return;
|
|
110
|
-
running = false;
|
|
111
|
-
|
|
112
101
|
// stop syncing
|
|
113
102
|
if (pushManager) pushManager.stop();
|
|
114
103
|
if (pollingManager && pollingManager.isRunning()) pollingManager.stop();
|
|
115
104
|
|
|
116
105
|
// stop periodic data recording (events, impressions, telemetry).
|
|
117
106
|
if (submitter) submitter.stop();
|
|
107
|
+
running = false;
|
|
118
108
|
},
|
|
119
109
|
|
|
120
110
|
isRunning() {
|
|
@@ -145,7 +135,7 @@ export function syncManagerOnlineFactory(
|
|
|
145
135
|
// of segments since `syncAll` was already executed when starting the main client
|
|
146
136
|
mySegmentsSyncTask.execute();
|
|
147
137
|
}
|
|
148
|
-
|
|
138
|
+
pushManager.add(matchingKey, mySegmentsSyncTask);
|
|
149
139
|
} else {
|
|
150
140
|
if (storage.splits.usesSegments()) mySegmentsSyncTask.start();
|
|
151
141
|
}
|
|
@@ -155,7 +145,7 @@ export function syncManagerOnlineFactory(
|
|
|
155
145
|
const mySegmentsSyncTask = (pollingManager as IPollingManagerCS).get(matchingKey);
|
|
156
146
|
if (mySegmentsSyncTask) {
|
|
157
147
|
// stop syncing
|
|
158
|
-
if (pushManager)
|
|
148
|
+
if (pushManager) pushManager.remove(matchingKey);
|
|
159
149
|
if (mySegmentsSyncTask.isRunning()) mySegmentsSyncTask.stop();
|
|
160
150
|
|
|
161
151
|
(pollingManager as IPollingManagerCS).remove(matchingKey);
|
package/src/types.ts
CHANGED
|
@@ -73,6 +73,7 @@ export interface ISettings {
|
|
|
73
73
|
readonly scheduler: {
|
|
74
74
|
featuresRefreshRate: number,
|
|
75
75
|
impressionsRefreshRate: number,
|
|
76
|
+
impressionsQueueSize: number,
|
|
76
77
|
metricsRefreshRate: number,
|
|
77
78
|
segmentsRefreshRate: number,
|
|
78
79
|
offlineRefreshRate: number,
|
|
@@ -255,6 +256,13 @@ interface INodeBasicSettings extends ISharedSettings {
|
|
|
255
256
|
* @default 300
|
|
256
257
|
*/
|
|
257
258
|
impressionsRefreshRate?: number,
|
|
259
|
+
/**
|
|
260
|
+
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
261
|
+
* If you use a 0 here, the queue will have no maximum size.
|
|
262
|
+
* @property {number} impressionsQueueSize
|
|
263
|
+
* @default 30000
|
|
264
|
+
*/
|
|
265
|
+
impressionsQueueSize?: number,
|
|
258
266
|
/**
|
|
259
267
|
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
260
268
|
* @property {number} metricsRefreshRate
|
|
@@ -769,6 +777,13 @@ export namespace SplitIO {
|
|
|
769
777
|
* @default 60
|
|
770
778
|
*/
|
|
771
779
|
impressionsRefreshRate?: number,
|
|
780
|
+
/**
|
|
781
|
+
* The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
|
|
782
|
+
* If you use a 0 here, the queue will have no maximum size.
|
|
783
|
+
* @property {number} impressionsQueueSize
|
|
784
|
+
* @default 30000
|
|
785
|
+
*/
|
|
786
|
+
impressionsQueueSize?: number,
|
|
772
787
|
/**
|
|
773
788
|
* The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
|
|
774
789
|
* @property {number} metricsRefreshRate
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isObject,
|
|
1
|
+
import { isObject, isString, isFiniteNumber, isBoolean } from '../lang';
|
|
2
|
+
import { objectAssign } from '../lang/objectAssign';
|
|
2
3
|
import { SplitIO } from '../../types';
|
|
3
4
|
import { ILogger } from '../../logger/types';
|
|
4
5
|
import { ERROR_NOT_PLAIN_OBJECT, ERROR_SIZE_EXCEEDED, WARN_SETTING_NULL, WARN_TRIMMING_PROPERTIES } from '../../logger/constants';
|
|
@@ -22,7 +23,8 @@ export function validateEventProperties(log: ILogger, maybeProperties: any, meth
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
const keys = Object.keys(maybeProperties);
|
|
25
|
-
|
|
26
|
+
// Shallow clone
|
|
27
|
+
const clone = objectAssign({}, maybeProperties);
|
|
26
28
|
// To avoid calculating the size twice we'll return it from here.
|
|
27
29
|
const output = {
|
|
28
30
|
properties: clone,
|
package/src/utils/lang/index.ts
CHANGED
|
@@ -194,20 +194,6 @@ export function merge(target: { [key: string]: any }, source: { [key: string]: a
|
|
|
194
194
|
return res;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
/**
|
|
198
|
-
* Shallow clone an object
|
|
199
|
-
*/
|
|
200
|
-
export function shallowClone(obj: any): any {
|
|
201
|
-
const keys = Object.keys(obj);
|
|
202
|
-
const output: Record<string, any> = {};
|
|
203
|
-
|
|
204
|
-
for (let i = 0; i < keys.length; i++) {
|
|
205
|
-
output[keys[i]] = obj[keys[i]];
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return output;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
197
|
/**
|
|
212
198
|
* Checks if the target string starts with the sub string.
|
|
213
199
|
*/
|
|
@@ -38,6 +38,8 @@ const base = {
|
|
|
38
38
|
eventsPushRate: 60,
|
|
39
39
|
// how many events will be queued before flushing
|
|
40
40
|
eventsQueueSize: 500,
|
|
41
|
+
// how many impressions will be queued before flushing
|
|
42
|
+
impressionsQueueSize: 30000,
|
|
41
43
|
// backoff base seconds to wait before re attempting to connect to push notifications
|
|
42
44
|
pushRetryBackoffBase: 1,
|
|
43
45
|
},
|
|
@@ -78,11 +80,6 @@ const base = {
|
|
|
78
80
|
localhostMode: undefined
|
|
79
81
|
},
|
|
80
82
|
|
|
81
|
-
runtime: {
|
|
82
|
-
ip: false,
|
|
83
|
-
hostname: false
|
|
84
|
-
},
|
|
85
|
-
|
|
86
83
|
// Logger
|
|
87
84
|
log: undefined
|
|
88
85
|
};
|
|
@@ -139,7 +136,7 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
|
|
|
139
136
|
|
|
140
137
|
// Current ip/hostname information
|
|
141
138
|
// @ts-ignore, modify readonly prop
|
|
142
|
-
|
|
139
|
+
withDefaults.runtime = runtime(withDefaults);
|
|
143
140
|
|
|
144
141
|
// ensure a valid list of integrations.
|
|
145
142
|
// `integrations` returns an array of valid integration items.
|
|
@@ -6,15 +6,15 @@ import { ISettings } from '../../types';
|
|
|
6
6
|
*/
|
|
7
7
|
export interface ISettingsValidationParams {
|
|
8
8
|
/**
|
|
9
|
-
* Object of values to overwrite
|
|
10
|
-
* Version and startup properties are
|
|
9
|
+
* Object of values to overwrite base settings.
|
|
10
|
+
* Version and startup properties are required, because they are not defined in the base settings.
|
|
11
11
|
*/
|
|
12
12
|
defaults: Partial<ISettings> & { version: string } & { startup: ISettings['startup'] },
|
|
13
|
-
/** Function to
|
|
14
|
-
runtime
|
|
15
|
-
/** Storage validator */
|
|
13
|
+
/** Function to define runtime values (`settings.runtime`) */
|
|
14
|
+
runtime: (settings: ISettings) => ISettings['runtime'],
|
|
15
|
+
/** Storage validator (`settings.storage`) */
|
|
16
16
|
storage?: (settings: ISettings) => ISettings['storage'],
|
|
17
|
-
/** Integrations validator */
|
|
17
|
+
/** Integrations validator (`settings.integrations`) */
|
|
18
18
|
integrations?: (settings: ISettings) => ISettings['integrations'],
|
|
19
19
|
/** Logger validator (`settings.debug`) */
|
|
20
20
|
logger: (settings: ISettings) => ISettings['log'],
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntegrationFactory } from '../types';
|
|
2
2
|
import { GoogleAnalyticsToSplitOptions } from './types';
|
|
3
|
-
export declare function GoogleAnalyticsToSplit(options: GoogleAnalyticsToSplitOptions):
|
|
3
|
+
export declare function GoogleAnalyticsToSplit(options: GoogleAnalyticsToSplitOptions): IntegrationFactory;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SplitToGa } from './SplitToGa';
|
|
1
|
+
import { IntegrationFactory } from '../types';
|
|
3
2
|
import { SplitToGoogleAnalyticsOptions } from './types';
|
|
4
|
-
export declare function SplitToGoogleAnalytics(options?: SplitToGoogleAnalyticsOptions):
|
|
3
|
+
export declare function SplitToGoogleAnalytics(options?: SplitToGoogleAnalyticsOptions): IntegrationFactory;
|
|
@@ -60,7 +60,7 @@ export declare const STREAMING_RECONNECT = 111;
|
|
|
60
60
|
export declare const STREAMING_CONNECTING = 112;
|
|
61
61
|
export declare const STREAMING_DISABLED = 113;
|
|
62
62
|
export declare const STREAMING_DISCONNECTING = 114;
|
|
63
|
-
export declare const
|
|
63
|
+
export declare const SUBMITTERS_PUSH_FULL_QUEUE = 115;
|
|
64
64
|
export declare const SUBMITTERS_PUSH = 116;
|
|
65
65
|
export declare const SYNC_START_POLLING = 117;
|
|
66
66
|
export declare const SYNC_CONTINUE_POLLING = 118;
|
package/types/logger/types.d.ts
CHANGED
|
@@ -6,8 +6,12 @@ export interface ILoggerOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export interface ILogger {
|
|
8
8
|
setLogLevel(logLevel: LogLevel): void;
|
|
9
|
+
debug(msg: any): void;
|
|
9
10
|
debug(msg: string | number, args?: any[]): void;
|
|
11
|
+
info(msg: any): void;
|
|
10
12
|
info(msg: string | number, args?: any[]): void;
|
|
13
|
+
warn(msg: any): void;
|
|
11
14
|
warn(msg: string | number, args?: any[]): void;
|
|
15
|
+
error(msg: any): void;
|
|
12
16
|
error(msg: string | number, args?: any[]): void;
|
|
13
17
|
}
|