@splitsoftware/splitio-commons 1.4.2-rc.5 → 1.5.1-rc.1
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 +3 -3
- package/cjs/integrations/ga/GaToSplit.js +11 -12
- package/cjs/listeners/browser.js +35 -15
- package/cjs/services/splitApi.js +4 -4
- package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +5 -5
- package/cjs/sync/polling/fetchers/splitChangesFetcher.js +2 -2
- package/cjs/sync/polling/updaters/segmentChangesUpdater.js +34 -34
- package/cjs/sync/polling/updaters/splitChangesUpdater.js +4 -3
- package/cjs/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +46 -46
- package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +82 -64
- package/cjs/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +74 -58
- package/cjs/sync/streaming/UpdateWorkers/constants.js +6 -0
- package/cjs/sync/streaming/pushManager.js +6 -7
- package/cjs/sync/syncTask.js +13 -16
- package/cjs/utils/Backoff.js +3 -2
- package/esm/integrations/ga/GaToSplit.js +11 -12
- package/esm/listeners/browser.js +35 -15
- package/esm/services/splitApi.js +4 -4
- package/esm/sync/polling/fetchers/segmentChangesFetcher.js +5 -5
- package/esm/sync/polling/fetchers/splitChangesFetcher.js +2 -2
- package/esm/sync/polling/updaters/segmentChangesUpdater.js +34 -34
- package/esm/sync/polling/updaters/splitChangesUpdater.js +4 -3
- package/esm/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.js +46 -47
- package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +82 -65
- package/esm/sync/streaming/UpdateWorkers/SplitsUpdateWorker.js +74 -59
- package/esm/sync/streaming/UpdateWorkers/constants.js +3 -0
- package/esm/sync/streaming/pushManager.js +6 -7
- package/esm/sync/syncTask.js +13 -16
- package/esm/utils/Backoff.js +3 -2
- package/package.json +1 -1
- package/src/integrations/ga/GaToSplit.ts +8 -14
- package/src/integrations/ga/types.ts +2 -13
- package/src/listeners/browser.ts +34 -14
- package/src/services/splitApi.ts +4 -4
- package/src/services/types.ts +2 -2
- package/src/sync/polling/fetchers/segmentChangesFetcher.ts +5 -4
- package/src/sync/polling/fetchers/splitChangesFetcher.ts +2 -1
- package/src/sync/polling/fetchers/types.ts +2 -0
- package/src/sync/polling/pollingManagerCS.ts +5 -5
- package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +2 -2
- package/src/sync/polling/types.ts +14 -6
- package/src/sync/polling/updaters/mySegmentsUpdater.ts +4 -4
- package/src/sync/polling/updaters/segmentChangesUpdater.ts +34 -32
- package/src/sync/polling/updaters/splitChangesUpdater.ts +5 -4
- package/src/sync/streaming/SSEHandler/types.ts +0 -7
- package/src/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.ts +45 -54
- package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +78 -63
- package/src/sync/streaming/UpdateWorkers/SplitsUpdateWorker.ts +73 -61
- package/src/sync/streaming/UpdateWorkers/constants.ts +3 -0
- package/src/sync/streaming/UpdateWorkers/types.ts +2 -4
- package/src/sync/streaming/pushManager.ts +12 -12
- package/src/sync/streaming/types.ts +2 -2
- package/src/sync/syncTask.ts +16 -18
- package/src/utils/Backoff.ts +7 -2
- package/types/integrations/ga/types.d.ts +2 -13
- package/types/listeners/browser.d.ts +6 -6
- package/types/services/types.d.ts +2 -2
- package/types/sync/polling/fetchers/types.d.ts +2 -2
- package/types/sync/polling/syncTasks/mySegmentsSyncTask.d.ts +2 -2
- package/types/sync/polling/types.d.ts +11 -6
- package/types/sync/polling/updaters/segmentChangesUpdater.d.ts +1 -1
- package/types/sync/polling/updaters/splitChangesUpdater.d.ts +1 -1
- package/types/sync/streaming/SSEHandler/types.d.ts +0 -4
- package/types/sync/streaming/UpdateWorkers/MySegmentsUpdateWorker.d.ts +3 -24
- package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +3 -23
- package/types/sync/streaming/UpdateWorkers/SplitsUpdateWorker.d.ts +6 -33
- package/types/sync/streaming/UpdateWorkers/constants.d.ts +3 -0
- package/types/sync/streaming/UpdateWorkers/types.d.ts +1 -2
- package/types/sync/streaming/types.d.ts +2 -2
- package/types/sync/syncTask.d.ts +2 -3
- package/types/utils/Backoff.d.ts +2 -0
- package/src/integrations/ga/autoRequire.js +0 -33
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import { IReadinessManager } from '../../readiness/types';
|
|
2
2
|
import { IStorageSync } from '../../storages/types';
|
|
3
|
-
import { SegmentsData } from '../streaming/SSEHandler/types';
|
|
4
3
|
import { ITask, ISyncTask } from '../types';
|
|
5
|
-
export interface ISplitsSyncTask extends ISyncTask<[noCache?: boolean], boolean> {
|
|
4
|
+
export interface ISplitsSyncTask extends ISyncTask<[noCache?: boolean, till?: number], boolean> {
|
|
6
5
|
}
|
|
7
|
-
export interface ISegmentsSyncTask extends ISyncTask<[
|
|
6
|
+
export interface ISegmentsSyncTask extends ISyncTask<[fetchOnlyNew?: boolean, segmentName?: string, noCache?: boolean, till?: number], boolean> {
|
|
7
|
+
}
|
|
8
|
+
export declare type MySegmentsData = string[] | {
|
|
9
|
+
name: string;
|
|
10
|
+
add: boolean;
|
|
11
|
+
};
|
|
12
|
+
export interface IMySegmentsSyncTask extends ISyncTask<[segmentsData?: MySegmentsData, noCache?: boolean], boolean> {
|
|
8
13
|
}
|
|
9
14
|
export interface IPollingManager extends ITask {
|
|
10
15
|
syncAll(): Promise<any>;
|
|
11
16
|
splitsSyncTask: ISplitsSyncTask;
|
|
12
|
-
segmentsSyncTask:
|
|
17
|
+
segmentsSyncTask: ISyncTask;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* PollingManager for client-side with support for multiple clients
|
|
16
21
|
*/
|
|
17
22
|
export interface IPollingManagerCS extends IPollingManager {
|
|
18
|
-
add(matchingKey: string, readiness: IReadinessManager, storage: IStorageSync):
|
|
23
|
+
add(matchingKey: string, readiness: IReadinessManager, storage: IStorageSync): IMySegmentsSyncTask;
|
|
19
24
|
remove(matchingKey: string): void;
|
|
20
|
-
get(matchingKey: string):
|
|
25
|
+
get(matchingKey: string): IMySegmentsSyncTask | undefined;
|
|
21
26
|
}
|
|
@@ -2,7 +2,7 @@ import { ISegmentChangesFetcher } from '../fetchers/types';
|
|
|
2
2
|
import { ISegmentsCacheBase } from '../../../storages/types';
|
|
3
3
|
import { IReadinessManager } from '../../../readiness/types';
|
|
4
4
|
import { ILogger } from '../../../logger/types';
|
|
5
|
-
declare type ISegmentChangesUpdater = (
|
|
5
|
+
declare type ISegmentChangesUpdater = (fetchOnlyNew?: boolean, segmentName?: string, noCache?: boolean, till?: number) => Promise<boolean>;
|
|
6
6
|
/**
|
|
7
7
|
* Factory of SegmentChanges updater, a task that:
|
|
8
8
|
* - fetches segment changes using `segmentChangesFetcher`
|
|
@@ -4,7 +4,7 @@ import { ISplitChangesFetcher } from '../fetchers/types';
|
|
|
4
4
|
import { ISplit } from '../../../dtos/types';
|
|
5
5
|
import { ISplitsEventEmitter } from '../../../readiness/types';
|
|
6
6
|
import { ILogger } from '../../../logger/types';
|
|
7
|
-
declare type ISplitChangesUpdater = (noCache?: boolean) => Promise<boolean>;
|
|
7
|
+
declare type ISplitChangesUpdater = (noCache?: boolean, till?: number) => Promise<boolean>;
|
|
8
8
|
/**
|
|
9
9
|
* Collect segments from a raw split definition.
|
|
10
10
|
* Exported for testing purposes.
|
|
@@ -1,27 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Backoff } from '../../../utils/Backoff';
|
|
1
|
+
import { IMySegmentsSyncTask } from '../../polling/types';
|
|
3
2
|
import { IUpdateWorker } from './types';
|
|
4
|
-
import { SegmentsData } from '../SSEHandler/types';
|
|
5
3
|
/**
|
|
6
|
-
* MySegmentsUpdateWorker
|
|
4
|
+
* MySegmentsUpdateWorker factory
|
|
7
5
|
*/
|
|
8
|
-
export declare
|
|
9
|
-
private readonly mySegmentsSyncTask;
|
|
10
|
-
private maxChangeNumber;
|
|
11
|
-
private handleNewEvent;
|
|
12
|
-
private segmentsData?;
|
|
13
|
-
private currentChangeNumber;
|
|
14
|
-
readonly backoff: Backoff;
|
|
15
|
-
/**
|
|
16
|
-
* @param {Object} mySegmentsSyncTask task for syncing mySegments data
|
|
17
|
-
*/
|
|
18
|
-
constructor(mySegmentsSyncTask: ISegmentsSyncTask);
|
|
19
|
-
__handleMySegmentsUpdateCall(): void;
|
|
20
|
-
/**
|
|
21
|
-
* Invoked by NotificationProcessor on MY_SEGMENTS_UPDATE event
|
|
22
|
-
*
|
|
23
|
-
* @param {number} changeNumber change number of the MY_SEGMENTS_UPDATE notification
|
|
24
|
-
* @param {SegmentsData | undefined} segmentsData might be undefined
|
|
25
|
-
*/
|
|
26
|
-
put(changeNumber: number, segmentsData?: SegmentsData): void;
|
|
27
|
-
}
|
|
6
|
+
export declare function MySegmentsUpdateWorker(mySegmentsSyncTask: IMySegmentsSyncTask): IUpdateWorker;
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
+
import { ILogger } from '../../../logger/types';
|
|
1
2
|
import { ISegmentsCacheSync } from '../../../storages/types';
|
|
2
|
-
import { Backoff } from '../../../utils/Backoff';
|
|
3
3
|
import { ISegmentsSyncTask } from '../../polling/types';
|
|
4
|
-
import { ISegmentUpdateData } from '../SSEHandler/types';
|
|
5
4
|
import { IUpdateWorker } from './types';
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* SegmentsUpdateWorker factory
|
|
8
7
|
*/
|
|
9
|
-
export declare
|
|
10
|
-
private readonly segmentsCache;
|
|
11
|
-
private readonly segmentsSyncTask;
|
|
12
|
-
private readonly maxChangeNumbers;
|
|
13
|
-
private handleNewEvent;
|
|
14
|
-
readonly backoff: Backoff;
|
|
15
|
-
/**
|
|
16
|
-
* @param {Object} segmentsCache segments data cache
|
|
17
|
-
* @param {Object} segmentsSyncTask task for syncing segments data
|
|
18
|
-
*/
|
|
19
|
-
constructor(segmentsSyncTask: ISegmentsSyncTask, segmentsCache: ISegmentsCacheSync);
|
|
20
|
-
__handleSegmentUpdateCall(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Invoked by NotificationProcessor on SEGMENT_UPDATE event
|
|
23
|
-
*
|
|
24
|
-
* @param {number} changeNumber change number of the SEGMENT_UPDATE notification
|
|
25
|
-
* @param {string} segmentName segment name of the SEGMENT_UPDATE notification
|
|
26
|
-
*/
|
|
27
|
-
put({ changeNumber, segmentName }: ISegmentUpdateData): void;
|
|
28
|
-
}
|
|
8
|
+
export declare function SegmentsUpdateWorker(log: ILogger, segmentsSyncTask: ISegmentsSyncTask, segmentsCache: ISegmentsCacheSync): IUpdateWorker;
|
|
@@ -1,39 +1,12 @@
|
|
|
1
|
+
import { ILogger } from '../../../logger/types';
|
|
1
2
|
import { ISplitsEventEmitter } from '../../../readiness/types';
|
|
2
3
|
import { ISplitsCacheSync } from '../../../storages/types';
|
|
3
|
-
import { Backoff } from '../../../utils/Backoff';
|
|
4
4
|
import { ISegmentsSyncTask, ISplitsSyncTask } from '../../polling/types';
|
|
5
|
-
import { ISplitKillData
|
|
5
|
+
import { ISplitKillData } from '../SSEHandler/types';
|
|
6
6
|
import { IUpdateWorker } from './types';
|
|
7
7
|
/**
|
|
8
|
-
* SplitsUpdateWorker
|
|
8
|
+
* SplitsUpdateWorker factory
|
|
9
9
|
*/
|
|
10
|
-
export declare
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private readonly splitsEventEmitter;
|
|
14
|
-
private readonly segmentsSyncTask?;
|
|
15
|
-
private maxChangeNumber;
|
|
16
|
-
private handleNewEvent;
|
|
17
|
-
readonly backoff: Backoff;
|
|
18
|
-
/**
|
|
19
|
-
* @param {Object} splitsCache splits data cache
|
|
20
|
-
* @param {Object} splitsSyncTask task for syncing splits data
|
|
21
|
-
* @param {Object} splitsEventEmitter emitter for splits data events
|
|
22
|
-
*/
|
|
23
|
-
constructor(splitsCache: ISplitsCacheSync, splitsSyncTask: ISplitsSyncTask, splitsEventEmitter: ISplitsEventEmitter, segmentsSyncTask?: ISegmentsSyncTask);
|
|
24
|
-
__handleSplitUpdateCall(): void;
|
|
25
|
-
/**
|
|
26
|
-
* Invoked by NotificationProcessor on SPLIT_UPDATE event
|
|
27
|
-
*
|
|
28
|
-
* @param {number} changeNumber change number of the SPLIT_UPDATE notification
|
|
29
|
-
*/
|
|
30
|
-
put({ changeNumber }: Pick<ISplitUpdateData, 'changeNumber'>): void;
|
|
31
|
-
/**
|
|
32
|
-
* Invoked by NotificationProcessor on SPLIT_KILL event
|
|
33
|
-
*
|
|
34
|
-
* @param {number} changeNumber change number of the SPLIT_UPDATE notification
|
|
35
|
-
* @param {string} splitName name of split to kill
|
|
36
|
-
* @param {string} defaultTreatment default treatment value
|
|
37
|
-
*/
|
|
38
|
-
killSplit({ changeNumber, splitName, defaultTreatment }: ISplitKillData): void;
|
|
39
|
-
}
|
|
10
|
+
export declare function SplitsUpdateWorker(log: ILogger, splitsCache: ISplitsCacheSync, splitsSyncTask: ISplitsSyncTask, splitsEventEmitter: ISplitsEventEmitter, segmentsSyncTask?: ISegmentsSyncTask): IUpdateWorker & {
|
|
11
|
+
killSplit(event: ISplitKillData): void;
|
|
12
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IMySegmentsUpdateData, IMySegmentsUpdateV2Data, ISegmentUpdateData, ISplitUpdateData, ISplitKillData } from './SSEHandler/types';
|
|
2
2
|
import { ITask } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { IMySegmentsSyncTask } from '../polling/types';
|
|
4
4
|
import { IEventEmitter } from '../../types';
|
|
5
5
|
import { ControlType } from './constants';
|
|
6
6
|
export declare type PUSH_SUBSYSTEM_UP = 'PUSH_SUBSYSTEM_UP';
|
|
@@ -29,7 +29,7 @@ export interface IPushEventEmitter extends IEventEmitter {
|
|
|
29
29
|
* PushManager
|
|
30
30
|
*/
|
|
31
31
|
export interface IPushManager extends ITask, IPushEventEmitter {
|
|
32
|
-
add(userKey: string, mySegmentsSyncTask:
|
|
32
|
+
add(userKey: string, mySegmentsSyncTask: IMySegmentsSyncTask): void;
|
|
33
33
|
remove(userKey: string): void;
|
|
34
34
|
}
|
|
35
35
|
export {};
|
package/types/sync/syncTask.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ILogger } from '../logger/types';
|
|
2
2
|
import { ISyncTask } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Creates
|
|
5
|
-
* The task can be also executed by calling the "execute" method. Multiple
|
|
6
|
-
* For example, submitters executed on SDK destroy or full queue, while periodic execution is pending.
|
|
4
|
+
* Creates an object that handles the periodic execution of a given task via "start" and "stop" methods.
|
|
5
|
+
* The task can be also executed by calling the "execute" method. Multiple calls run sequentially to avoid race conditions (e.g., submitters executed on SDK destroy or full queue, while periodic execution is pending).
|
|
7
6
|
*
|
|
8
7
|
* @param log Logger instance.
|
|
9
8
|
* @param task Task to execute that returns a promise that NEVER REJECTS. Otherwise, periodic execution can result in Unhandled Promise Rejections.
|
package/types/utils/Backoff.d.ts
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
/**
|
|
3
|
-
* Auto-require script to use with GoogleAnalyticsToSplit integration
|
|
4
|
-
*/
|
|
5
|
-
(function (i, r, s) {
|
|
6
|
-
i[s] = i[s] || r;
|
|
7
|
-
i[r] = i[r] || function () { i[r].q.push(arguments); };
|
|
8
|
-
i[r].q = i[r].q || [];
|
|
9
|
-
|
|
10
|
-
var ts = {}; // Tracker names
|
|
11
|
-
function n(arg) { return typeof arg === 'object' && typeof arg.name === 'string' && arg.name; }
|
|
12
|
-
|
|
13
|
-
function p(v) { // Queue a `require` command if v is a `create` command
|
|
14
|
-
if (v && v[0] === 'create') {
|
|
15
|
-
var t = n(v[1]) || n(v[2]) || n(v[3]) || (typeof v[3] === 'string' ? v[3] : undefined); // Get tracker name
|
|
16
|
-
|
|
17
|
-
if (!ts[t]) {
|
|
18
|
-
ts[t] = true;
|
|
19
|
-
i[r]((t ? t + '.' : '') + 'require', 'splitTracker'); // Auto-require
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
i[r].q.forEach(function (v) { p(v); }); // Process already queued commands
|
|
25
|
-
|
|
26
|
-
var o = i[r].q.push;
|
|
27
|
-
i[r].q.push = function (v) { // Spy new queued commands
|
|
28
|
-
var result = o.apply(this, arguments);
|
|
29
|
-
p(v);
|
|
30
|
-
return result;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
})(window, 'ga', 'GoogleAnalyticsObject');
|