@splitsoftware/splitio-commons 1.2.0 → 1.2.1-rc.0

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.
Files changed (82) hide show
  1. package/cjs/logger/messages/info.js +3 -3
  2. package/cjs/sdkClient/client.js +2 -1
  3. package/cjs/sdkClient/clientCS.js +2 -1
  4. package/cjs/services/splitHttpClient.js +1 -1
  5. package/cjs/sync/streaming/AuthClient/index.js +1 -2
  6. package/cjs/sync/streaming/pushManager.js +24 -21
  7. package/cjs/sync/syncManagerOnline.js +12 -7
  8. package/cjs/utils/murmur3/legacy.js +44 -0
  9. package/cjs/utils/promise/timeout.js +1 -1
  10. package/esm/logger/messages/info.js +3 -3
  11. package/esm/sdkClient/client.js +2 -1
  12. package/esm/sdkClient/clientCS.js +2 -1
  13. package/esm/services/splitHttpClient.js +1 -1
  14. package/esm/sync/streaming/AuthClient/index.js +1 -2
  15. package/esm/sync/streaming/pushManager.js +24 -21
  16. package/esm/sync/syncManagerOnline.js +12 -7
  17. package/esm/utils/murmur3/legacy.js +39 -0
  18. package/esm/utils/promise/timeout.js +1 -1
  19. package/package.json +2 -2
  20. package/src/logger/.DS_Store +0 -0
  21. package/src/logger/messages/info.ts +3 -3
  22. package/src/sdkClient/client.ts +2 -1
  23. package/src/sdkClient/clientCS.ts +3 -1
  24. package/src/services/splitHttpClient.ts +1 -1
  25. package/src/sync/streaming/AuthClient/index.ts +1 -2
  26. package/src/sync/streaming/pushManager.ts +24 -25
  27. package/src/sync/syncManagerOnline.ts +10 -6
  28. package/src/types.ts +5 -1
  29. package/src/utils/murmur3/legacy.ts +48 -0
  30. package/src/utils/promise/timeout.ts +1 -1
  31. package/types/integrations/ga/GaToSplitPlugin.d.ts +3 -0
  32. package/types/integrations/ga/SplitToGaPlugin.d.ts +4 -0
  33. package/types/logger/browser/{DebugLogger.d.ts → debugLogger.d.ts} +0 -0
  34. package/types/logger/browser/{ErrorLogger.d.ts → errorLogger.d.ts} +0 -0
  35. package/types/logger/browser/{InfoLogger.d.ts → infoLogger.d.ts} +0 -0
  36. package/types/logger/browser/{WarnLogger.d.ts → warnLogger.d.ts} +0 -0
  37. package/types/logger/codes.d.ts +2 -0
  38. package/types/logger/codesConstants.d.ts +117 -0
  39. package/types/logger/codesConstantsBrowser.d.ts +2 -0
  40. package/types/logger/codesConstantsNode.d.ts +14 -0
  41. package/types/logger/codesDebug.d.ts +1 -0
  42. package/types/logger/codesDebugBrowser.d.ts +1 -0
  43. package/types/logger/codesDebugNode.d.ts +1 -0
  44. package/types/logger/codesError.d.ts +1 -0
  45. package/types/logger/codesErrorNode.d.ts +1 -0
  46. package/types/logger/codesInfo.d.ts +1 -0
  47. package/types/logger/codesWarn.d.ts +1 -0
  48. package/types/logger/codesWarnNode.d.ts +1 -0
  49. package/types/logger/debugLogger.d.ts +2 -0
  50. package/types/logger/errorLogger.d.ts +2 -0
  51. package/types/logger/infoLogger.d.ts +2 -0
  52. package/types/logger/messages/debugBrowser.d.ts +1 -0
  53. package/types/logger/messages/debugNode.d.ts +1 -0
  54. package/types/logger/messages/errorNode.d.ts +1 -0
  55. package/types/logger/messages/warnNode.d.ts +1 -0
  56. package/types/logger/noopLogger.d.ts +2 -0
  57. package/types/logger/warnLogger.d.ts +2 -0
  58. package/types/sdkManager/sdkManagerMethod.d.ts +6 -0
  59. package/types/storages/getRegisteredSegments.d.ts +10 -0
  60. package/types/storages/inMemory/TelemetryCacheInMemory.d.ts +51 -0
  61. package/types/storages/inRedis/TelemetryCacheInRedis.d.ts +0 -0
  62. package/types/storages/pluggable/TelemetryCachePluggable.d.ts +2 -0
  63. package/types/sync/polling/syncTasks/splitsSyncTask.copy.d.ts +35 -0
  64. package/types/sync/polling/syncTasks/splitsSyncTask.morelikeoriginal.d.ts +35 -0
  65. package/types/sync/streaming/AuthClient/indexV1.d.ts +12 -0
  66. package/types/sync/streaming/AuthClient/indexV2.d.ts +8 -0
  67. package/types/sync/streaming/pushManagerCS.d.ts +12 -0
  68. package/types/sync/streaming/pushManagerNoUsers.d.ts +13 -0
  69. package/types/sync/streaming/pushManagerSS.d.ts +11 -0
  70. package/types/sync/submitters/telemetrySyncTask.d.ts +17 -0
  71. package/types/sync/syncManagerFromFile.d.ts +2 -0
  72. package/types/sync/syncManagerFromObject.d.ts +2 -0
  73. package/types/sync/syncManagerOffline.d.ts +9 -0
  74. package/types/trackers/telemetryRecorder.d.ts +0 -0
  75. package/types/types.d.ts +1 -0
  76. package/types/utils/EventEmitter.d.ts +4 -0
  77. package/types/utils/lang/errors.d.ts +10 -0
  78. package/types/utils/murmur3/commons.d.ts +12 -0
  79. package/types/utils/murmur3/legacy.d.ts +2 -0
  80. package/types/utils/settingsValidation/buildMetadata.d.ts +3 -0
  81. package/types/utils/settingsValidation/localhost/index.d.ts +9 -0
  82. package/types/utils/settingsValidation/logger.d.ts +11 -0
@@ -40,7 +40,7 @@ export function pushManagerFactory(
40
40
 
41
41
  // `userKey` is the matching key of main client in client-side SDK.
42
42
  // It can be used to check if running on client-side or server-side SDK.
43
- const userKey = settings.core.key ? getMatching(settings.core.key) : undefined; //
43
+ const userKey = settings.core.key ? getMatching(settings.core.key) : undefined;
44
44
  const log = settings.log;
45
45
 
46
46
  let sseClient: ISSEClient;
@@ -59,7 +59,8 @@ export function pushManagerFactory(
59
59
  sseClient.setEventHandler(sseHandler);
60
60
 
61
61
  // init workers
62
- const segmentsUpdateWorker = userKey ? new MySegmentsUpdateWorker(pollingManager.segmentsSyncTask) : new SegmentsUpdateWorker(storage.segments, pollingManager.segmentsSyncTask);
62
+ // MySegmentsUpdateWorker (client-side) are initiated in `add` method
63
+ const segmentsUpdateWorker = userKey ? undefined : new SegmentsUpdateWorker(storage.segments, pollingManager.segmentsSyncTask);
63
64
  // For server-side we pass the segmentsSyncTask, used by SplitsUpdateWorker to fetch new segments
64
65
  const splitsUpdateWorker = new SplitsUpdateWorker(storage.splits, pollingManager.splitsSyncTask, readiness.splits, userKey ? undefined : pollingManager.segmentsSyncTask);
65
66
 
@@ -68,11 +69,6 @@ export function pushManagerFactory(
68
69
  // [Only for client-side] map of user keys to their corresponding hash64 and MySegmentsUpdateWorkers.
69
70
  // Hash64 is used to process MY_SEGMENTS_UPDATE_V2 events and dispatch actions to the corresponding MySegmentsUpdateWorker.
70
71
  const clients: Record<string, { hash64: Hash64, worker: MySegmentsUpdateWorker }> = {};
71
- if (userKey) {
72
- const hash = hashUserKey(userKey);
73
- userKeyHashes[hash] = userKey;
74
- clients[userKey] = { hash64: hash64(userKey), worker: segmentsUpdateWorker as MySegmentsUpdateWorker };
75
- }
76
72
 
77
73
  // [Only for client-side] variable to flag that a new client was added. It is needed to reconnect streaming.
78
74
  let connectForNewClient = false;
@@ -176,7 +172,7 @@ export function pushManagerFactory(
176
172
  function stopWorkers() {
177
173
  splitsUpdateWorker.backoff.reset();
178
174
  if (userKey) forOwn(clients, ({ worker }) => worker.backoff.reset());
179
- else segmentsUpdateWorker.backoff.reset();
175
+ else (segmentsUpdateWorker as SegmentsUpdateWorker).backoff.reset();
180
176
  }
181
177
 
182
178
  pushEmitter.on(PUSH_SUBSYSTEM_DOWN, stopWorkers);
@@ -306,37 +302,40 @@ export function pushManagerFactory(
306
302
  // Expose Event Emitter functionality and Event constants
307
303
  Object.create(pushEmitter),
308
304
  {
309
- // Expose functionality for starting and stoping push mode:
310
- stop: disconnectPush, // `handleNonRetryableError` cannot be used as `stop`, because it emits PUSH_SUBSYSTEM_DOWN event, which starts polling.
311
-
305
+ // Stop/pause push mode
306
+ stop() {
307
+ disconnectPush(); // `handleNonRetryableError` cannot be used as `stop`, because it emits PUSH_SUBSYSTEM_DOWN event, which starts polling.
308
+ if (userKey) this.remove(userKey); // Necessary to properly resume streaming in client-side (e.g., RN SDK transition to foreground).
309
+ },
310
+ // Start/resume push mode
312
311
  start() {
313
312
  // Guard condition to avoid calling `connectPush` again if the `start` method is called multiple times or if push has been disabled.
314
313
  if (disabled || disconnected === false) return;
315
314
  disconnected = false;
316
- // Run in next event-loop cycle for optimization on client-side: if multiple clients are created in the same cycle than the factory, only one authentication is performed.
317
- setTimeout(connectPush);
315
+
316
+ if (userKey) this.add(userKey, pollingManager.segmentsSyncTask); // client-side
317
+ else setTimeout(connectPush); // server-side runs in next cycle as in client-side, for consistency with client-side
318
318
  },
319
319
 
320
320
  // [Only for client-side]
321
321
  add(userKey: string, mySegmentsSyncTask: ISegmentsSyncTask) {
322
- clients[userKey] = { hash64: hash64(userKey), worker: new MySegmentsUpdateWorker(mySegmentsSyncTask) };
323
-
324
322
  const hash = hashUserKey(userKey);
325
323
 
326
324
  if (!userKeyHashes[hash]) {
327
325
  userKeyHashes[hash] = userKey;
326
+ clients[userKey] = { hash64: hash64(userKey), worker: new MySegmentsUpdateWorker(mySegmentsSyncTask) };
328
327
  connectForNewClient = true; // we must reconnect on start, to listen the channel for the new user key
329
- }
330
328
 
331
- // Reconnects in case of a new client.
332
- // Run in next event-loop cycle to save authentication calls
333
- // in case the user is creating several clients in the current cycle.
334
- setTimeout(function checkForReconnect() {
335
- if (connectForNewClient) {
336
- connectForNewClient = false;
337
- connectPush();
338
- }
339
- }, 0);
329
+ // Reconnects in case of a new client.
330
+ // Run in next event-loop cycle to save authentication calls
331
+ // in case multiple clients are created in the current cycle.
332
+ setTimeout(function checkForReconnect() {
333
+ if (connectForNewClient) {
334
+ connectForNewClient = false;
335
+ connectPush();
336
+ }
337
+ }, 0);
338
+ }
340
339
  },
341
340
  // [Only for client-side]
342
341
  remove(userKey: string) {
@@ -49,11 +49,11 @@ export function syncManagerOnlineFactory(
49
49
  /** Sync Manager logic */
50
50
 
51
51
  function startPolling() {
52
- if (!pollingManager!.isRunning()) {
52
+ if (pollingManager!.isRunning()) {
53
+ log.info(SYNC_CONTINUE_POLLING);
54
+ } else {
53
55
  log.info(SYNC_START_POLLING);
54
56
  pollingManager!.start();
55
- } else {
56
- log.info(SYNC_CONTINUE_POLLING);
57
57
  }
58
58
  }
59
59
 
@@ -81,6 +81,9 @@ export function syncManagerOnlineFactory(
81
81
  * Method used to start the syncManager for the first time, or resume it after being stopped.
82
82
  */
83
83
  start() {
84
+ if (running) return;
85
+ running = true;
86
+
84
87
  // start syncing splits and segments
85
88
  if (pollingManager) {
86
89
  if (pushManager) {
@@ -96,21 +99,22 @@ export function syncManagerOnlineFactory(
96
99
  }
97
100
 
98
101
  // start periodic data recording (events, impressions, telemetry).
99
- submitter && submitter.start();
100
- running = true;
102
+ if (submitter) submitter.start();
101
103
  },
102
104
 
103
105
  /**
104
106
  * Method used to stop/pause the syncManager.
105
107
  */
106
108
  stop() {
109
+ if (!running) return;
110
+ running = false;
111
+
107
112
  // stop syncing
108
113
  if (pushManager) pushManager.stop();
109
114
  if (pollingManager && pollingManager.isRunning()) pollingManager.stop();
110
115
 
111
116
  // stop periodic data recording (events, impressions, telemetry).
112
117
  if (submitter) submitter.stop();
113
- running = false;
114
118
  },
115
119
 
116
120
  isRunning() {
package/src/types.ts CHANGED
@@ -381,6 +381,10 @@ interface IBasicClient extends IStatusInterface {
381
381
  * @returns {Promise<void>}
382
382
  */
383
383
  destroy(): Promise<void>
384
+
385
+ // Whether the client implements the client-side API, i.e, with bound key, (true), or the server-side API (false).
386
+ // Exposed for internal purposes only. Not considered part of the public API, and might be renamed eventually.
387
+ isBrowserClient: boolean
384
388
  }
385
389
  /**
386
390
  * Common definitions between SDK instances for different environments interface.
@@ -1139,7 +1143,7 @@ export namespace SplitIO {
1139
1143
  /**
1140
1144
  * Removes from client's in memory attributes storage the attribute with the given key
1141
1145
  * @function removeAttribute
1142
- * @param {string} attributeName
1146
+ * @param {string} attributeName
1143
1147
  * @returns {boolean} true if attribute was removed and false otherways
1144
1148
  */
1145
1149
  removeAttribute(attributeName: string): boolean,
@@ -0,0 +1,48 @@
1
+ // Deprecated hashing function, used for split bucketing. Replaced by murmur3
2
+
3
+ //
4
+ // JAVA reference implementation for the hashing function.
5
+ //
6
+ // int h = 0;
7
+ // for (int i = 0; i < key.length(); i++) {
8
+ // h = 31 * h + key.charAt(i);
9
+ // }
10
+ // return h ^ seed; // XOR the hash and seed
11
+ //
12
+
13
+ function ToInteger(x: number) {
14
+ x = Number(x);
15
+ return x < 0 ? Math.ceil(x) : Math.floor(x);
16
+ }
17
+
18
+ function modulo(a: number, b: number) {
19
+ return a - Math.floor(a / b) * b;
20
+ }
21
+
22
+ function ToUint32(x: number) {
23
+ return modulo(ToInteger(x), Math.pow(2, 32));
24
+ }
25
+
26
+ function ToInt32(x: number) {
27
+ let uint32 = ToUint32(x);
28
+
29
+ if (uint32 >= Math.pow(2, 31)) {
30
+ return uint32 - Math.pow(2, 32);
31
+ } else {
32
+ return uint32;
33
+ }
34
+ }
35
+
36
+ export function hash(str: string, seed: number): number {
37
+ let h = 0;
38
+
39
+ for (let i = 0; i < str.length; i++) {
40
+ h = ToInt32(ToInt32(31 * h) + str.charCodeAt(i));
41
+ }
42
+
43
+ return ToInt32(h ^ seed);
44
+ }
45
+
46
+ export function bucket(str: string, seed: number): number {
47
+ return Math.abs(hash(str, seed) % 100) + 1;
48
+ }
@@ -3,7 +3,7 @@ export function timeout<T>(ms: number, promise: Promise<T>): Promise<T> {
3
3
 
4
4
  return new Promise((resolve, reject) => {
5
5
  const tid = setTimeout(() => {
6
- reject(new Error(`Operation timed out because it exceeded the configured time limit of ${ms}ms.`));
6
+ reject(new Error(`Operation timed out because it exceeded the configured time limit of ${ms} ms.`));
7
7
  }, ms);
8
8
 
9
9
  promise.then((res) => {
@@ -0,0 +1,3 @@
1
+ import { IIntegrationFactoryParams } from '../types';
2
+ import { GoogleAnalyticsToSplitOptions } from './types';
3
+ export declare function GoogleAnalyticsToSplit(options: GoogleAnalyticsToSplitOptions): (params: IIntegrationFactoryParams) => void;
@@ -0,0 +1,4 @@
1
+ import { IIntegrationFactoryParams } from '../types';
2
+ import SplitToGa from './SplitToGa';
3
+ import { SplitToGoogleAnalyticsOptions } from './types';
4
+ export declare function SplitToGoogleAnalytics(options?: SplitToGoogleAnalyticsOptions): (params: IIntegrationFactoryParams) => SplitToGa;
@@ -0,0 +1,2 @@
1
+ import { ICodes } from './types';
2
+ export declare const codes: ICodes;
@@ -0,0 +1,117 @@
1
+ export declare const DEBUG_0 = 0;
2
+ export declare const DEBUG_1 = 1;
3
+ export declare const DEBUG_2 = 2;
4
+ export declare const DEBUG_3 = 3;
5
+ export declare const DEBUG_4 = 4;
6
+ export declare const DEBUG_5 = 5;
7
+ export declare const DEBUG_6 = 6;
8
+ export declare const DEBUG_7 = 7;
9
+ export declare const DEBUG_8 = 8;
10
+ export declare const DEBUG_9 = 9;
11
+ export declare const DEBUG_10 = 10;
12
+ export declare const DEBUG_11 = 11;
13
+ export declare const DEBUG_12 = 12;
14
+ export declare const DEBUG_13 = 13;
15
+ export declare const DEBUG_14 = 14;
16
+ export declare const DEBUG_15 = 15;
17
+ export declare const DEBUG_16 = 16;
18
+ export declare const DEBUG_17 = 17;
19
+ export declare const DEBUG_18 = 18;
20
+ export declare const DEBUG_19 = 19;
21
+ export declare const DEBUG_20 = 20;
22
+ export declare const DEBUG_21 = 21;
23
+ export declare const DEBUG_22 = 22;
24
+ export declare const DEBUG_23 = 23;
25
+ export declare const DEBUG_24 = 24;
26
+ export declare const DEBUG_25 = 25;
27
+ export declare const DEBUG_31 = 31;
28
+ export declare const DEBUG_32 = 32;
29
+ export declare const DEBUG_33 = 33;
30
+ export declare const DEBUG_36 = 36;
31
+ export declare const DEBUG_42 = 42;
32
+ export declare const DEBUG_43 = 43;
33
+ export declare const DEBUG_44 = 44;
34
+ export declare const DEBUG_45 = 45;
35
+ export declare const DEBUG_46 = 46;
36
+ export declare const DEBUG_47 = 47;
37
+ export declare const DEBUG_48 = 48;
38
+ export declare const DEBUG_49 = 49;
39
+ export declare const DEBUG_50 = 50;
40
+ export declare const DEBUG_51 = 51;
41
+ export declare const INFO_0 = 100;
42
+ export declare const INFO_1 = 101;
43
+ export declare const INFO_2 = 102;
44
+ export declare const INFO_3 = 103;
45
+ export declare const INFO_4 = 104;
46
+ export declare const INFO_5 = 105;
47
+ export declare const INFO_6 = 106;
48
+ export declare const INFO_7 = 107;
49
+ export declare const INFO_8 = 108;
50
+ export declare const INFO_9 = 109;
51
+ export declare const INFO_10 = 110;
52
+ export declare const INFO_11 = 111;
53
+ export declare const INFO_12 = 112;
54
+ export declare const INFO_13 = 113;
55
+ export declare const INFO_14 = 114;
56
+ export declare const INFO_15 = 115;
57
+ export declare const INFO_16 = 116;
58
+ export declare const INFO_17 = 117;
59
+ export declare const INFO_18 = 118;
60
+ export declare const INFO_19 = 119;
61
+ export declare const INFO_20 = 120;
62
+ export declare const INFO_21 = 121;
63
+ export declare const WARN_0 = 200;
64
+ export declare const WARN_1 = 201;
65
+ export declare const WARN_2 = 202;
66
+ export declare const WARN_4 = 204;
67
+ export declare const WARN_5 = 205;
68
+ export declare const WARN_6 = 206;
69
+ export declare const WARN_7 = 207;
70
+ export declare const WARN_8 = 208;
71
+ export declare const WARN_9 = 209;
72
+ export declare const WARN_10 = 210;
73
+ export declare const WARN_11 = 211;
74
+ export declare const WARN_12 = 212;
75
+ export declare const WARN_13 = 213;
76
+ export declare const WARN_14 = 214;
77
+ export declare const WARN_15 = 215;
78
+ export declare const WARN_17 = 217;
79
+ export declare const WARN_18 = 218;
80
+ export declare const WARN_19 = 219;
81
+ export declare const WARN_20 = 220;
82
+ export declare const WARN_21 = 221;
83
+ export declare const WARN_22 = 222;
84
+ export declare const WARN_23 = 223;
85
+ export declare const WARN_24 = 224;
86
+ export declare const WARN_25 = 225;
87
+ export declare const ERROR_0 = 300;
88
+ export declare const ERROR_2 = 302;
89
+ export declare const ERROR_3 = 303;
90
+ export declare const ERROR_4 = 304;
91
+ export declare const ERROR_5 = 305;
92
+ export declare const ERROR_7 = 307;
93
+ export declare const ERROR_9 = 309;
94
+ export declare const ERROR_10 = 310;
95
+ export declare const ERROR_11 = 311;
96
+ export declare const ERROR_12 = 312;
97
+ export declare const ERROR_13 = 313;
98
+ export declare const ERROR_14 = 314;
99
+ export declare const ERROR_15 = 315;
100
+ export declare const ERROR_16 = 316;
101
+ export declare const ERROR_17 = 317;
102
+ export declare const ERROR_18 = 318;
103
+ export declare const ERROR_19 = 319;
104
+ export declare const ERROR_20 = 320;
105
+ export declare const ERROR_21 = 321;
106
+ export declare const ERROR_22 = 322;
107
+ export declare const ERROR_23 = 323;
108
+ export declare const ERROR_24 = 324;
109
+ export declare const ERROR_25 = 325;
110
+ export declare const ERROR_26 = 326;
111
+ export declare const ERROR_32 = 332;
112
+ export declare const ERROR_33 = 333;
113
+ export declare const ERROR_34 = 334;
114
+ export declare const ERROR_35 = 335;
115
+ export declare const ERROR_36 = 336;
116
+ export declare const ERROR_37 = 337;
117
+ export declare const ERROR_38 = 338;
@@ -0,0 +1,2 @@
1
+ export declare const DEBUG_26 = 26;
2
+ export declare const DEBUG_27 = 27;
@@ -0,0 +1,14 @@
1
+ export declare const DEBUG_28 = 28;
2
+ export declare const DEBUG_29 = 29;
3
+ export declare const DEBUG_30 = 30;
4
+ export declare const ERROR_1 = 301;
5
+ export declare const DEBUG_39 = 39;
6
+ export declare const DEBUG_40 = 40;
7
+ export declare const DEBUG_41 = 41;
8
+ export declare const ERROR_8 = 308;
9
+ export declare const DEBUG_34 = 34;
10
+ export declare const DEBUG_35 = 35;
11
+ export declare const ERROR_6 = 306;
12
+ export declare const WARN_3 = 203;
13
+ export declare const DEBUG_37 = 37;
14
+ export declare const DEBUG_38 = 38;
@@ -0,0 +1 @@
1
+ export declare const codesDebug: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesDebugBrowser: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesDebugNode: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesError: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesErrorNode: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesInfo: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesWarn: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesWarnNode: [number, string][];
@@ -0,0 +1,2 @@
1
+ import { Logger } from '.';
2
+ export declare const debugLogger: Logger;
@@ -0,0 +1,2 @@
1
+ import { Logger } from '.';
2
+ export declare const errorLogger: Logger;
@@ -0,0 +1,2 @@
1
+ import { Logger } from '.';
2
+ export declare const infoLogger: Logger;
@@ -0,0 +1 @@
1
+ export declare const codesDebugBrowser: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesDebugNode: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesErrorNode: [number, string][];
@@ -0,0 +1 @@
1
+ export declare const codesWarnNode: [number, string][];
@@ -0,0 +1,2 @@
1
+ import { ILogger } from './types';
2
+ export declare const noopLogger: ILogger;
@@ -0,0 +1,2 @@
1
+ import { Logger } from '.';
2
+ export declare const warnLogger: Logger;
@@ -0,0 +1,6 @@
1
+ import { ISdkClientFactoryParams } from '../sdkClient/types';
2
+ import { SplitIO } from '../types';
3
+ /**
4
+ * Factory of client method for server-side SDKs (ISDK and IAsyncSDK)
5
+ */
6
+ export declare function sdkManagerMethodFactory(params: ISdkClientFactoryParams): () => SplitIO.IManager | SplitIO.IAsyncManager;
@@ -0,0 +1,10 @@
1
+ import { ISplit } from '../dtos/types';
2
+ /**
3
+ * Collect segments from a raw split definition.
4
+ * Exported for testing purposes.
5
+ */
6
+ export declare function _parseSegments({ conditions }: ISplit): import("../utils/lang/sets").ISet<string>;
7
+ /**
8
+ * Computes the set of segments used by splits.
9
+ */
10
+ export declare function getRegisteredSegments(splitDefs: string[]): string[];
@@ -0,0 +1,51 @@
1
+ import { ImpressionDataType, EventDataType, StreamingEvent, Method, OperationType } from '../../sync/submitters/types';
2
+ import { TelemetryCacheSync } from '../types';
3
+ export declare class TelemetryCacheInMemory implements TelemetryCacheSync {
4
+ private timeUntilReady?;
5
+ getTimeUntilReady(): number | undefined;
6
+ recordTimeUntilReady(ms: number): void;
7
+ private timeUntilReadyFromCache?;
8
+ getTimeUntilReadyFromCache(): number | undefined;
9
+ recordTimeUntilReadyFromCache(ms: number): void;
10
+ private notReadyUsage;
11
+ getNonReadyUsage(): number;
12
+ recordNonReadyUsage(): void;
13
+ private impressionStats;
14
+ getImpressionStats(type: ImpressionDataType): number;
15
+ recordImpressionStats(type: ImpressionDataType, count: number): void;
16
+ private eventStats;
17
+ getEventStats(type: EventDataType): number;
18
+ recordEventStats(type: EventDataType, count: number): void;
19
+ private lastSync;
20
+ getLastSynchronization(): Record<OperationType, number | undefined>;
21
+ recordSuccessfulSync(resource: OperationType, timeMs: number): void;
22
+ private httpErrors;
23
+ popHttpErrors(): Record<OperationType, {
24
+ [statusCode: string]: number;
25
+ }>;
26
+ recordSyncError(resource: OperationType, status: number): void;
27
+ private httpLatencies;
28
+ popHttpLatencies(): Record<OperationType, number[]>;
29
+ recordSyncLatency(resource: OperationType, latencyMs: number): void;
30
+ private authRejections;
31
+ popAuthRejections(): number;
32
+ recordAuthRejections(): void;
33
+ private tokenRefreshes;
34
+ popTokenRefreshes(): number;
35
+ recordTokenRefreshes(): void;
36
+ private streamingEvents;
37
+ popStreamingEvents(): StreamingEvent[];
38
+ recordStreamingEvents(streamingEvent: StreamingEvent): void;
39
+ private tags;
40
+ popTags(): string[];
41
+ addTag(tag: string): void;
42
+ private sessionLength?;
43
+ getSessionLength(): number | undefined;
44
+ recordSessionLength(ms: number): void;
45
+ private exceptions;
46
+ popExceptions(): Record<Method, number>;
47
+ recordException(method: Method): void;
48
+ private latencies;
49
+ popLatencies(): Record<Method, number[]>;
50
+ recordLatency(method: Method, latencyMs: number): void;
51
+ }
@@ -0,0 +1,2 @@
1
+ export declare class TelemetryCachePluggable {
2
+ }
@@ -0,0 +1,35 @@
1
+ import { ISet } from '../../../utils/lang/sets';
2
+ import { ISegmentsCacheSync, ISplitsCacheSync, IStorageSync } from '../../../storages/types';
3
+ import { ISplitChangesFetcher } from '../fetchers/types';
4
+ import { ISplit } from '../../../dtos/types';
5
+ import { IReadinessManager, ISplitsEventEmitter } from '../../../readiness/types';
6
+ import { ISplitsSyncTask } from '../types';
7
+ import { IFetchSplitChanges } from '../../../services/types';
8
+ import { ISettings } from '../../../types';
9
+ declare type ISplitChangesUpdater = (noCache?: boolean) => Promise<boolean>;
10
+ /**
11
+ * Collect segments from a raw split definition.
12
+ * Exported for testing purposes.
13
+ */
14
+ export declare function parseSegments({ conditions }: ISplit): ISet<string>;
15
+ interface ISplitMutations {
16
+ added: [string, string][];
17
+ removed: string[];
18
+ segments: string[];
19
+ }
20
+ /**
21
+ * Given the list of splits from /splitChanges endpoint, it returns the mutations,
22
+ * i.e., an object with added splits, removed splits and used segments.
23
+ * Exported for testing purposes.
24
+ */
25
+ export declare function computeSplitsMutation(entries: ISplit[]): ISplitMutations;
26
+ /**
27
+ * factory of SplitChanges updater (a.k.a, SplitsSyncTask), a task that:
28
+ * - fetches split changes using `splitChangesFetcher`
29
+ * - updates `splitsCache`
30
+ * - uses `splitsEventEmitter` to emit events related to split data updates
31
+ * Exported for testing purposes.
32
+ */
33
+ export declare function splitChangesUpdaterFactory(splitChangesFetcher: ISplitChangesFetcher, splitsCache: ISplitsCacheSync, segmentsCache: ISegmentsCacheSync, splitsEventEmitter: ISplitsEventEmitter, requestTimeoutBeforeReady: number, retriesOnFailureBeforeReady: number): ISplitChangesUpdater;
34
+ export default function splitsSyncTaskFactory(fetchSplitChanges: IFetchSplitChanges, storage: IStorageSync, readiness: IReadinessManager, settings: ISettings): ISplitsSyncTask;
35
+ export {};
@@ -0,0 +1,35 @@
1
+ import { ISet } from '../../../utils/lang/sets';
2
+ import { ISegmentsCacheSync, ISplitsCacheSync, IStorageSync } from '../../../storages/types';
3
+ import { ISplitChangesFetcher } from '../fetchers/types';
4
+ import { ISplit } from '../../../dtos/types';
5
+ import { IReadinessManager, ISplitsEventEmitter } from '../../../readiness/types';
6
+ import { ISplitsSyncTask } from '../types';
7
+ import { IFetchSplitChanges } from '../../../services/types';
8
+ import { ISettings } from '../../../types';
9
+ declare type ISplitChangesUpdater = (noCache?: boolean) => Promise<boolean>;
10
+ /**
11
+ * Collect segments from a raw split definition.
12
+ * Exported for testing purposes.
13
+ */
14
+ export declare function parseSegments({ conditions }: ISplit): ISet<string>;
15
+ interface ISplitMutations {
16
+ added: [string, string][];
17
+ removed: string[];
18
+ segments: string[];
19
+ }
20
+ /**
21
+ * Given the list of splits from /splitChanges endpoint, it returns the mutations,
22
+ * i.e., an object with added splits, removed splits and used segments.
23
+ * Exported for testing purposes.
24
+ */
25
+ export declare function computeSplitsMutation(entries: ISplit[]): ISplitMutations;
26
+ /**
27
+ * factory of SplitChanges updater (a.k.a, SplitsSyncTask), a task that:
28
+ * - fetches split changes using `splitChangesFetcher`
29
+ * - updates `splitsCache`
30
+ * - uses `splitsEventEmitter` to emit events related to split data updates
31
+ * Exported for testing purposes.
32
+ */
33
+ export declare function splitChangesUpdaterFactory(splitChangesFetcher: ISplitChangesFetcher, splitsCache: ISplitsCacheSync, segmentsCache: ISegmentsCacheSync, splitsEventEmitter: ISplitsEventEmitter, requestTimeoutBeforeReady: number, retriesOnFailureBeforeReady: number): ISplitChangesUpdater;
34
+ export default function splitsSyncTaskFactory(fetchSplitChanges: IFetchSplitChanges, storage: IStorageSync, readiness: IReadinessManager, settings: ISettings): ISplitsSyncTask;
35
+ export {};
@@ -0,0 +1,12 @@
1
+ import { IFetchAuth } from '../../../services/types';
2
+ import { IAuthenticate } from './types';
3
+ /**
4
+ * Factory of authentication function.
5
+ *
6
+ * @param fetchAuth `SplitAPI.fetchAuth` endpoint
7
+ */
8
+ export declare function authenticateFactory(fetchAuth: IFetchAuth): IAuthenticate;
9
+ /**
10
+ * Returns the hash of a given user key
11
+ */
12
+ export declare function hashUserKey(userKey: string): string;
@@ -0,0 +1,8 @@
1
+ import { IFetchAuthV2 } from '../../../services/types';
2
+ import { IAuthenticateV2 } from './types';
3
+ /**
4
+ * Factory of authentication function.
5
+ *
6
+ * @param fetchAuth `SplitAPI.fetchAuth` endpoint
7
+ */
8
+ export declare function authenticateFactory(fetchAuthV2: IFetchAuthV2): IAuthenticateV2;
@@ -0,0 +1,12 @@
1
+ import { IPushManagerCS } from './types';
2
+ import { IStorageSync } from '../../storages/types';
3
+ import { IReadinessManager } from '../../readiness/types';
4
+ import { IPollingManager } from '../polling/types';
5
+ import { IFetchAuth } from '../../services/types';
6
+ import { ISettings } from '../../types';
7
+ import { IPlatform } from '../../sdkFactory/types';
8
+ /**
9
+ * PushManager factory for client-side, with support for multiple clients.
10
+ * It assumes settings contains a key.
11
+ */
12
+ export default function pushManagerCSFactory(pollingManager: IPollingManager, storage: IStorageSync, readiness: IReadinessManager, fetchAuth: IFetchAuth, platform: IPlatform, settings: ISettings): IPushManagerCS | undefined;