@splitsoftware/splitio-browserjs 0.1.1-canary.3 → 0.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 CHANGED
@@ -1,6 +1,13 @@
1
- 0.1.1 (XXX YY, 2021)
2
- - Updated Karma and a transitive dependency with vulnerabilities.
3
- - Updated Javascript-commons dependency to include improvements and fix some log messages typos.
1
+ 0.2.0 (October 20, 2021)
2
+ - Added localhost mode support (Read more in our docs here: https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode).
3
+ - Updated @splitsoftware/splitio-commons dependency to version 1.0.0, which includes:
4
+ - Updated localhost mode to emit SDK_READY_FROM_CACHE event in Browser when using localStorage (Related to issue https://github.com/splitio/react-client/issues/34).
5
+ - Updated streaming logic to use the newest version of our streaming service, including:
6
+ - Integration with Auth service V2, connecting to the new channels and applying the received connection delay.
7
+ - Implemented handling of the new MySegmentsV2 notification types (SegmentRemoval, KeyList, Bounded and Unbounded)
8
+ - New control notification for environment scoped streaming reset.
9
+ - Fix of some log messages typos, among other improvements.
10
+ - Updated some NPM dependencies for vulnerability fixes.
4
11
 
5
12
  0.1.0 (March 30, 2021)
6
13
  - Initial public release. Check the official documentation for details: https://help.split.io/hc/en-us/articles/360058730852
package/README.md CHANGED
@@ -67,11 +67,12 @@ Split has built and maintains SDKs for:
67
67
  * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
68
68
  * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
69
69
  * Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
70
+ * Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
70
71
  * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
71
- * Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852)
72
72
  * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
73
73
  * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
74
74
  * React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
75
+ * React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
75
76
  * Redux [Github](https://github.com/splitio/redux-client) [Docs](https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK)
76
77
  * Ruby [Github](https://github.com/splitio/ruby-client) [Docs](https://help.split.io/hc/en-us/articles/360020673251-Ruby-SDK)
77
78
 
package/cjs/full/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DebugLogger = exports.InfoLogger = exports.WarnLogger = exports.ErrorLogger = exports.SplitToGoogleAnalytics = exports.GoogleAnalyticsToSplit = exports.InLocalStorage = exports.SplitFactory = void 0;
3
+ exports.PluggableStorage = exports.DebugLogger = exports.InfoLogger = exports.WarnLogger = exports.ErrorLogger = exports.SplitToGoogleAnalytics = exports.GoogleAnalyticsToSplit = exports.InLocalStorage = exports.SplitFactory = void 0;
4
4
  var splitFactory_1 = require("./splitFactory");
5
5
  Object.defineProperty(exports, "SplitFactory", { enumerable: true, get: function () { return splitFactory_1.SplitFactory; } });
6
6
  var index_1 = require("@splitsoftware/splitio-commons/cjs/storages/inLocalStorage/index");
@@ -17,3 +17,5 @@ var InfoLogger_1 = require("@splitsoftware/splitio-commons/cjs/logger/browser/In
17
17
  Object.defineProperty(exports, "InfoLogger", { enumerable: true, get: function () { return InfoLogger_1.InfoLogger; } });
18
18
  var DebugLogger_1 = require("@splitsoftware/splitio-commons/cjs/logger/browser/DebugLogger");
19
19
  Object.defineProperty(exports, "DebugLogger", { enumerable: true, get: function () { return DebugLogger_1.DebugLogger; } });
20
+ var pluggable_1 = require("@splitsoftware/splitio-commons/cjs/storages/pluggable");
21
+ Object.defineProperty(exports, "PluggableStorage", { enumerable: true, get: function () { return pluggable_1.PluggableStorage; } });
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SplitFactory = void 0;
4
- var tslib_1 = require("tslib");
5
4
  var full_1 = require("../settings/full");
6
5
  var getModules_1 = require("../platform/getModules");
7
6
  var index_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory/index");
8
7
  var lang_1 = require("@splitsoftware/splitio-commons/cjs/utils/lang");
9
8
  var getFetchFull_1 = require("../platform/getFetchFull");
10
9
  var getEventSource_1 = require("../platform/getEventSource");
11
- var MinEvents_1 = tslib_1.__importDefault(require("@splitsoftware/splitio-commons/cjs/utils/MinEvents"));
12
- var platform = { getFetch: getFetchFull_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.default };
10
+ var MinEvents_1 = require("@splitsoftware/splitio-commons/cjs/utils/MinEvents");
11
+ var platform = { getFetch: getFetchFull_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.EventEmitter };
13
12
  /**
14
13
  * SplitFactory with pluggable modules for Browser.
15
14
  * Includes localhost mode and fetch polyfill out-of-the-box.
package/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalhostFromObject = exports.DebugLogger = exports.InfoLogger = exports.WarnLogger = exports.ErrorLogger = exports.SplitToGoogleAnalytics = exports.GoogleAnalyticsToSplit = exports.InLocalStorage = exports.SplitFactory = void 0;
3
+ exports.PluggableStorage = exports.LocalhostFromObject = exports.DebugLogger = exports.InfoLogger = exports.WarnLogger = exports.ErrorLogger = exports.SplitToGoogleAnalytics = exports.GoogleAnalyticsToSplit = exports.InLocalStorage = exports.SplitFactory = void 0;
4
4
  var splitFactory_1 = require("./splitFactory");
5
5
  Object.defineProperty(exports, "SplitFactory", { enumerable: true, get: function () { return splitFactory_1.SplitFactory; } });
6
6
  var index_1 = require("@splitsoftware/splitio-commons/cjs/storages/inLocalStorage/index");
@@ -19,3 +19,5 @@ var DebugLogger_1 = require("@splitsoftware/splitio-commons/cjs/logger/browser/D
19
19
  Object.defineProperty(exports, "DebugLogger", { enumerable: true, get: function () { return DebugLogger_1.DebugLogger; } });
20
20
  var LocalhostFromObject_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromObject");
21
21
  Object.defineProperty(exports, "LocalhostFromObject", { enumerable: true, get: function () { return LocalhostFromObject_1.LocalhostFromObject; } });
22
+ var pluggable_1 = require("@splitsoftware/splitio-commons/cjs/storages/pluggable");
23
+ Object.defineProperty(exports, "PluggableStorage", { enumerable: true, get: function () { return pluggable_1.PluggableStorage; } });
@@ -13,14 +13,17 @@ var impressionObserverCS_1 = require("@splitsoftware/splitio-commons/cjs/tracker
13
13
  var pluggable_1 = tslib_1.__importDefault(require("@splitsoftware/splitio-commons/cjs/integrations/pluggable"));
14
14
  var utils_1 = require("@splitsoftware/splitio-commons/cjs/trackers/impressionObserver/utils");
15
15
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
16
- var syncManagerOnlineCSFactory = syncManagerOnline_1.syncManagerOnlineFactory(pollingManagerCS_1.default, pushManager_1.default);
16
+ var syncManagerStandaloneFactory;
17
+ var syncManagerSubmittersFactory;
17
18
  function getModules(settings, platform) {
19
+ if (!syncManagerStandaloneFactory)
20
+ syncManagerStandaloneFactory = syncManagerOnline_1.syncManagerOnlineFactory(pollingManagerCS_1.default, pushManager_1.default);
18
21
  var modules = {
19
22
  settings: settings,
20
23
  platform: platform,
21
24
  storageFactory: settings.storage,
22
25
  splitApiFactory: splitApi_1.splitApiFactory,
23
- syncManagerFactory: syncManagerOnlineCSFactory,
26
+ syncManagerFactory: syncManagerStandaloneFactory,
24
27
  sdkManagerFactory: index_1.sdkManagerFactory,
25
28
  sdkClientMethodFactory: sdkClientMethodCS_1.sdkClientMethodCSFactory,
26
29
  SignalListener: browser_1.default,
@@ -28,10 +31,19 @@ function getModules(settings, platform) {
28
31
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? pluggable_1.default.bind(null, settings.integrations) : undefined,
29
32
  impressionsObserverFactory: utils_1.shouldAddPt(settings) ? impressionObserverCS_1.impressionObserverCSFactory : undefined,
30
33
  };
31
- if (settings.mode === constants_1.LOCALHOST_MODE) {
32
- modules.splitApiFactory = undefined;
33
- modules.syncManagerFactory = settings.sync.localhostMode;
34
- modules.SignalListener = undefined;
34
+ switch (settings.mode) {
35
+ case constants_1.LOCALHOST_MODE:
36
+ modules.splitApiFactory = undefined;
37
+ modules.syncManagerFactory = settings.sync.localhostMode;
38
+ modules.SignalListener = undefined;
39
+ break;
40
+ case constants_1.CONSUMER_MODE:
41
+ modules.syncManagerFactory = undefined;
42
+ break;
43
+ case constants_1.CONSUMER_PARTIAL_MODE:
44
+ if (!syncManagerSubmittersFactory)
45
+ syncManagerSubmittersFactory = syncManagerOnline_1.syncManagerOnlineFactory(undefined, undefined);
46
+ modules.syncManagerFactory = syncManagerSubmittersFactory;
35
47
  }
36
48
  return modules;
37
49
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaults = void 0;
4
4
  var index_1 = require("@splitsoftware/splitio-commons/cjs/logger/index");
5
- var packageVersion = '0.1.1-canary.3';
5
+ var packageVersion = '0.2.1-rc.2';
6
6
  /**
7
7
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
8
8
  * Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SplitFactory = void 0;
4
- var tslib_1 = require("tslib");
5
4
  var settings_1 = require("./settings");
6
5
  var getModules_1 = require("./platform/getModules");
7
6
  var index_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory/index");
8
7
  var lang_1 = require("@splitsoftware/splitio-commons/cjs/utils/lang");
9
8
  var getFetchSlim_1 = require("./platform/getFetchSlim");
10
9
  var getEventSource_1 = require("./platform/getEventSource");
11
- var MinEvents_1 = tslib_1.__importDefault(require("@splitsoftware/splitio-commons/cjs/utils/MinEvents"));
12
- var platform = { getFetch: getFetchSlim_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.default };
10
+ var MinEvents_1 = require("@splitsoftware/splitio-commons/cjs/utils/MinEvents");
11
+ var platform = { getFetch: getFetchSlim_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.EventEmitter };
13
12
  /**
14
13
  * Slim SplitFactory with pluggable modules for Browser.
15
14
  * Doesn't include localhost mode and fetch ponyfill out-of-the-box.
package/esm/full/index.js CHANGED
@@ -6,3 +6,4 @@ export { ErrorLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/E
6
6
  export { WarnLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/WarnLogger';
7
7
  export { InfoLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/InfoLogger';
8
8
  export { DebugLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/DebugLogger';
9
+ export { PluggableStorage } from '@splitsoftware/splitio-commons/esm/storages/pluggable';
@@ -4,7 +4,7 @@ import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory/index'
4
4
  import { merge } from '@splitsoftware/splitio-commons/esm/utils/lang';
5
5
  import { getFetch } from '../platform/getFetchFull';
6
6
  import { getEventSource } from '../platform/getEventSource';
7
- import EventEmitter from '@splitsoftware/splitio-commons/esm/utils/MinEvents';
7
+ import { EventEmitter } from '@splitsoftware/splitio-commons/esm/utils/MinEvents';
8
8
  var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitter: EventEmitter };
9
9
  /**
10
10
  * SplitFactory with pluggable modules for Browser.
package/esm/index.js CHANGED
@@ -7,3 +7,4 @@ export { WarnLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/Wa
7
7
  export { InfoLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/InfoLogger';
8
8
  export { DebugLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/DebugLogger';
9
9
  export { LocalhostFromObject } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromObject';
10
+ export { PluggableStorage } from '@splitsoftware/splitio-commons/esm/storages/pluggable';
@@ -8,15 +8,18 @@ import BrowserSignalListener from '@splitsoftware/splitio-commons/esm/listeners/
8
8
  import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/esm/trackers/impressionObserver/impressionObserverCS';
9
9
  import integrationsManagerFactory from '@splitsoftware/splitio-commons/esm/integrations/pluggable';
10
10
  import { shouldAddPt } from '@splitsoftware/splitio-commons/esm/trackers/impressionObserver/utils';
11
- import { LOCALHOST_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
12
- var syncManagerOnlineCSFactory = syncManagerOnlineFactory(pollingManagerCSFactory, pushManagerFactory);
11
+ import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE, LOCALHOST_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
12
+ var syncManagerStandaloneFactory;
13
+ var syncManagerSubmittersFactory;
13
14
  export function getModules(settings, platform) {
15
+ if (!syncManagerStandaloneFactory)
16
+ syncManagerStandaloneFactory = syncManagerOnlineFactory(pollingManagerCSFactory, pushManagerFactory);
14
17
  var modules = {
15
18
  settings: settings,
16
19
  platform: platform,
17
20
  storageFactory: settings.storage,
18
21
  splitApiFactory: splitApiFactory,
19
- syncManagerFactory: syncManagerOnlineCSFactory,
22
+ syncManagerFactory: syncManagerStandaloneFactory,
20
23
  sdkManagerFactory: sdkManagerFactory,
21
24
  sdkClientMethodFactory: sdkClientMethodCSFactory,
22
25
  SignalListener: BrowserSignalListener,
@@ -24,10 +27,19 @@ export function getModules(settings, platform) {
24
27
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? integrationsManagerFactory.bind(null, settings.integrations) : undefined,
25
28
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
26
29
  };
27
- if (settings.mode === LOCALHOST_MODE) {
28
- modules.splitApiFactory = undefined;
29
- modules.syncManagerFactory = settings.sync.localhostMode;
30
- modules.SignalListener = undefined;
30
+ switch (settings.mode) {
31
+ case LOCALHOST_MODE:
32
+ modules.splitApiFactory = undefined;
33
+ modules.syncManagerFactory = settings.sync.localhostMode;
34
+ modules.SignalListener = undefined;
35
+ break;
36
+ case CONSUMER_MODE:
37
+ modules.syncManagerFactory = undefined;
38
+ break;
39
+ case CONSUMER_PARTIAL_MODE:
40
+ if (!syncManagerSubmittersFactory)
41
+ syncManagerSubmittersFactory = syncManagerOnlineFactory(undefined, undefined);
42
+ modules.syncManagerFactory = syncManagerSubmittersFactory;
31
43
  }
32
44
  return modules;
33
45
  }
@@ -1,5 +1,5 @@
1
1
  import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/esm/logger/index';
2
- var packageVersion = '0.1.1-canary.3';
2
+ var packageVersion = '0.2.1-rc.2';
3
3
  /**
4
4
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
5
5
  * Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
@@ -4,7 +4,7 @@ import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory/index'
4
4
  import { merge } from '@splitsoftware/splitio-commons/esm/utils/lang';
5
5
  import { getFetch } from './platform/getFetchSlim';
6
6
  import { getEventSource } from './platform/getEventSource';
7
- import EventEmitter from '@splitsoftware/splitio-commons/esm/utils/MinEvents';
7
+ import { EventEmitter } from '@splitsoftware/splitio-commons/esm/utils/MinEvents';
8
8
  var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitter: EventEmitter };
9
9
  /**
10
10
  * Slim SplitFactory with pluggable modules for Browser.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-browserjs",
3
- "version": "0.1.1-canary.3",
3
+ "version": "0.2.1-rc.2",
4
4
  "description": "Split SDK for Javascript on Browser",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -28,7 +28,7 @@
28
28
  "build:umd": "rollup --config rollup.ci.config.js --branch=$BUILD_BRANCH --commit_hash=$BUILD_COMMIT",
29
29
  "test": "npm run test:unit && npm run test:e2e",
30
30
  "test:unit": "jest",
31
- "test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errors && npm run test:e2e-push && npm run test:e2e-gaintegration",
31
+ "test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errors && npm run test:e2e-push && npm run test:e2e-gaintegration && npm run test:e2e-consumer",
32
32
  "test:e2e-logger": "karma start karma/e2e.logger.karma.conf.js",
33
33
  "test:e2e-offline": "karma start karma/e2e.offline.karma.conf.js",
34
34
  "test:e2e-online": "karma start karma/e2e.online.karma.conf.js",
@@ -36,7 +36,8 @@
36
36
  "test:e2e-errors": "karma start karma/e2e.errors.karma.conf.js",
37
37
  "test:e2e-push": "karma start karma/e2e.push.karma.conf.js",
38
38
  "test:e2e-gaintegration": "karma start karma/e2e.gaintegration.karma.conf.js",
39
- "pretest-ts-decls": "npm run build && npm link",
39
+ "test:e2e-consumer": "karma start karma/e2e.consumer.karma.conf.js",
40
+ "pretest-ts-decls": "npm run build:esm && npm run build:cjs && npm link",
40
41
  "test-ts-decls": "./scripts/ts-tests.sh",
41
42
  "posttest-ts-decls": "npm unlink && npm install",
42
43
  "publish:rc": "npm run check && npm run build && npm publish --tag rc",
@@ -60,7 +61,7 @@
60
61
  "bugs": "https://github.com/splitio/javascript-browser-client/issues",
61
62
  "homepage": "https://github.com/splitio/javascript-browser-client#readme",
62
63
  "dependencies": {
63
- "@splitsoftware/splitio-commons": "0.1.1-rc.20",
64
+ "@splitsoftware/splitio-commons": "1.0.1-rc.5",
64
65
  "@types/google.analytics": "0.0.40"
65
66
  },
66
67
  "devDependencies": {
package/src/full/index.ts CHANGED
@@ -6,3 +6,4 @@ export { ErrorLogger } from '@splitsoftware/splitio-commons/src/logger/browser/E
6
6
  export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/WarnLogger';
7
7
  export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger';
8
8
  export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger';
9
+ export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable';
@@ -5,7 +5,7 @@ import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory
5
5
  import { merge } from '@splitsoftware/splitio-commons/src/utils/lang';
6
6
  import { getFetch } from '../platform/getFetchFull';
7
7
  import { getEventSource } from '../platform/getEventSource';
8
- import EventEmitter from '@splitsoftware/splitio-commons/src/utils/MinEvents';
8
+ import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents';
9
9
 
10
10
  const platform = { getFetch, getEventSource, EventEmitter };
11
11
 
package/src/index.ts CHANGED
@@ -7,3 +7,4 @@ export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/Wa
7
7
  export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger';
8
8
  export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger';
9
9
  export { LocalhostFromObject } from '@splitsoftware/splitio-commons/src/sync/offline/LocalhostFromObject';
10
+ export { PluggableStorage } from '@splitsoftware/splitio-commons/src/storages/pluggable';
@@ -11,12 +11,15 @@ import integrationsManagerFactory from '@splitsoftware/splitio-commons/src/integ
11
11
  import { shouldAddPt } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/utils';
12
12
  import { IPlatform, ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
13
13
  import { SplitIO, ISettings } from '@splitsoftware/splitio-commons/src/types';
14
- import { LOCALHOST_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
14
+ import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE, LOCALHOST_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
15
15
 
16
- const syncManagerOnlineCSFactory = syncManagerOnlineFactory(pollingManagerCSFactory, pushManagerFactory);
16
+ let syncManagerStandaloneFactory: ISdkFactoryParams['syncManagerFactory'];
17
+ let syncManagerSubmittersFactory: ISdkFactoryParams['syncManagerFactory'];
17
18
 
18
19
  export function getModules(settings: ISettings, platform: IPlatform): ISdkFactoryParams {
19
20
 
21
+ if (!syncManagerStandaloneFactory) syncManagerStandaloneFactory = syncManagerOnlineFactory(pollingManagerCSFactory, pushManagerFactory);
22
+
20
23
  const modules: ISdkFactoryParams = {
21
24
  settings,
22
25
 
@@ -24,9 +27,9 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor
24
27
 
25
28
  storageFactory: settings.storage,
26
29
 
27
- splitApiFactory: splitApiFactory,
30
+ splitApiFactory,
28
31
 
29
- syncManagerFactory: syncManagerOnlineCSFactory,
32
+ syncManagerFactory: syncManagerStandaloneFactory,
30
33
 
31
34
  sdkManagerFactory,
32
35
 
@@ -41,10 +44,18 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor
41
44
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
42
45
  };
43
46
 
44
- if (settings.mode === LOCALHOST_MODE) {
45
- modules.splitApiFactory = undefined;
46
- modules.syncManagerFactory = settings.sync.localhostMode;
47
- modules.SignalListener = undefined;
47
+ switch (settings.mode) {
48
+ case LOCALHOST_MODE:
49
+ modules.splitApiFactory = undefined;
50
+ modules.syncManagerFactory = settings.sync.localhostMode;
51
+ modules.SignalListener = undefined;
52
+ break;
53
+ case CONSUMER_MODE:
54
+ modules.syncManagerFactory = undefined;
55
+ break;
56
+ case CONSUMER_PARTIAL_MODE:
57
+ if (!syncManagerSubmittersFactory) syncManagerSubmittersFactory = syncManagerOnlineFactory(undefined, undefined);
58
+ modules.syncManagerFactory = syncManagerSubmittersFactory;
48
59
  }
49
60
 
50
61
  return modules;
@@ -1,7 +1,7 @@
1
1
  import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/logger/index';
2
2
  import { LogLevel } from '@splitsoftware/splitio-commons/src/types';
3
3
 
4
- const packageVersion = '0.1.1-canary.3';
4
+ const packageVersion = '0.2.1-rc.2';
5
5
 
6
6
  /**
7
7
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
@@ -5,7 +5,7 @@ import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory
5
5
  import { merge } from '@splitsoftware/splitio-commons/src/utils/lang';
6
6
  import { getFetch } from './platform/getFetchSlim';
7
7
  import { getEventSource } from './platform/getEventSource';
8
- import EventEmitter from '@splitsoftware/splitio-commons/src/utils/MinEvents';
8
+ import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents';
9
9
 
10
10
  const platform = { getFetch, getEventSource, EventEmitter };
11
11
 
@@ -1,4 +1,4 @@
1
- // Declaration file for Javascript Browser Split Software SDK v1.0.0
1
+ // Declaration file for Javascript Browser Split Software SDK
2
2
  // Project: http://www.split.io/
3
3
  // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
4
4
 
@@ -16,6 +16,7 @@ declare module JsSdk {
16
16
  * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
17
17
  */
18
18
  export function SplitFactory(settings: SplitIO.IBrowserSettings): SplitIO.ISDK;
19
+ export function SplitFactory(settings: SplitIO.IBrowserAsyncSettings): SplitIO.IAsyncSDK;
19
20
 
20
21
  /**
21
22
  * Persistent storage based on the LocalStorage Web API for browsers.
@@ -24,6 +25,13 @@ declare module JsSdk {
24
25
  */
25
26
  export function InLocalStorage(options?: SplitIO.InLocalStorageOptions): SplitIO.StorageSyncFactory;
26
27
 
28
+ /**
29
+ * Pluggable storage to use the SDK in consumer mode.
30
+ *
31
+ * @see {@link @TODO}
32
+ */
33
+ export function PluggableStorage(options: SplitIO.PluggableStorageOptions): SplitIO.StorageAsyncFactory;
34
+
27
35
  /**
28
36
  * Enable 'Google Analytics to Split' integration, to track Google Analytics hits as Split events.
29
37
  *
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Declaration file for Javascript Browser Split Software SDK v1.0.0
1
+ // Declaration file for Javascript Browser Split Software SDK
2
2
  // Project: http://www.split.io/
3
3
  // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
4
4
 
@@ -16,6 +16,7 @@ declare module JsSdk {
16
16
  * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
17
17
  */
18
18
  export function SplitFactory(settings: SplitIO.IBrowserSettings): SplitIO.ISDK;
19
+ export function SplitFactory(settings: SplitIO.IBrowserAsyncSettings): SplitIO.IAsyncSDK;
19
20
 
20
21
  /**
21
22
  * Persistent storage based on the LocalStorage Web API for browsers.
@@ -24,6 +25,13 @@ declare module JsSdk {
24
25
  */
25
26
  export function InLocalStorage(options?: SplitIO.InLocalStorageOptions): SplitIO.StorageSyncFactory;
26
27
 
28
+ /**
29
+ * Pluggable storage to use the SDK in consumer mode.
30
+ *
31
+ * @see {@link @TODO}
32
+ */
33
+ export function PluggableStorage(options: SplitIO.PluggableStorageOptions): SplitIO.StorageAsyncFactory;
34
+
27
35
  /**
28
36
  * Enable 'Google Analytics to Split' integration, to track Google Analytics hits as Split events.
29
37
  *
@@ -1,4 +1,4 @@
1
- // Type definitions for Javascript Browser Split Software SDK v1.0.0
1
+ // Type definitions for Javascript Browser Split Software SDK
2
2
  // Project: http://www.split.io/
3
3
  // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
4
4
 
@@ -11,11 +11,11 @@ export = SplitIO;
11
11
  * EventEmitter interface based on a subset of the NodeJS.EventEmitter methods.
12
12
  */
13
13
  interface IEventEmitter {
14
- addListener(event: string, listener: (...args: any[]) => void): this;
14
+ addListener(event: string, listener: (...args: any[]) => void): this
15
15
  on(event: string, listener: (...args: any[]) => void): this
16
16
  once(event: string, listener: (...args: any[]) => void): this
17
- removeListener(event: string, listener: (...args: any[]) => void): this;
18
- off(event: string, listener: (...args: any[]) => void): this;
17
+ removeListener(event: string, listener: (...args: any[]) => void): this
18
+ off(event: string, listener: (...args: any[]) => void): this
19
19
  removeAllListeners(event?: string): this
20
20
  emit(event: string, ...args: any[]): boolean
21
21
  }
@@ -32,6 +32,11 @@ type EventConsts = {
32
32
  SDK_READY_TIMED_OUT: 'init::timeout',
33
33
  SDK_UPDATE: 'state::update'
34
34
  };
35
+ /**
36
+ * SDK Modes.
37
+ * @typedef {string} SDKMode
38
+ */
39
+ type SDKMode = 'standalone' | 'localhost' | 'consumer' | 'consumer_partial';
35
40
  /**
36
41
  * Storage types.
37
42
  * @typedef {string} StorageType
@@ -49,6 +54,7 @@ interface ISettings {
49
54
  labelsEnabled: boolean,
50
55
  IPAddressesEnabled: boolean
51
56
  },
57
+ readonly mode: SDKMode,
52
58
  readonly scheduler: {
53
59
  featuresRefreshRate: number,
54
60
  impressionsRefreshRate: number,
@@ -64,7 +70,7 @@ interface ISettings {
64
70
  retriesOnFailureBeforeReady: number,
65
71
  eventsFirstPushWindow: number
66
72
  },
67
- readonly storage?: SplitIO.StorageSyncFactory,
73
+ readonly storage?: SplitIO.StorageSyncFactory | SplitIO.StorageAsyncFactory,
68
74
  readonly urls: {
69
75
  events: string,
70
76
  sdk: string,
@@ -82,7 +88,7 @@ interface ISettings {
82
88
  readonly sync: {
83
89
  splitFilters: SplitIO.SplitFilter[],
84
90
  impressionsMode: SplitIO.ImpressionsMode,
85
- localhostMode: SplitIO.LocalhostFactory
91
+ localhostMode?: SplitIO.LocalhostFactory
86
92
  }
87
93
  }
88
94
  /**
@@ -183,17 +189,20 @@ interface ISharedSettings {
183
189
  */
184
190
  impressionsMode?: SplitIO.ImpressionsMode,
185
191
  /**
186
- * Defines the factory function to instanciate the SDK in localhost mode.
192
+ * Defines the factory function to instantiate the SDK in localhost mode.
193
+ *
187
194
  * NOTE: this is only required if using the slim entry point of the library to init the SDK in localhost mode.
195
+ *
188
196
  * For more information @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
189
197
  *
190
198
  * Example:
191
199
  * ```typescript
192
- * config: {
200
+ * SplitFactory({
201
+ * ...
193
202
  * sync: {
194
203
  * localhostMode: LocalhostFromObject()
195
204
  * }
196
- * }
205
+ * })
197
206
  * ```
198
207
  * @property {Object} localhostMode
199
208
  */
@@ -468,7 +477,7 @@ declare namespace SplitIO {
468
477
  (params: {}): (StorageSync | undefined)
469
478
  }
470
479
  /**
471
- * Configuration params for InLocalStorage plugable storage
480
+ * Configuration params for `InLocalStorage`
472
481
  */
473
482
  type InLocalStorageOptions = {
474
483
  /**
@@ -478,6 +487,35 @@ declare namespace SplitIO {
478
487
  */
479
488
  prefix?: string
480
489
  }
490
+ /**
491
+ * Storage for asynchronous (consumer) SDK.
492
+ * Its interface details are not part of the public API.
493
+ */
494
+ type StorageAsync = {}
495
+ /**
496
+ * Storage builder for asynchronous (consumer) SDK.
497
+ * Input parameter details are not part of the public API.
498
+ */
499
+ type StorageAsyncFactory = {
500
+ readonly type: 'PLUGGABLE'
501
+ (params: {}): StorageAsync
502
+ }
503
+ /**
504
+ * Configuration params for `PluggableStorage`
505
+ */
506
+ type PluggableStorageOptions = {
507
+ /**
508
+ * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage wrapper.
509
+ * @property {string} prefix
510
+ * @default SPLITIO
511
+ */
512
+ prefix?: string,
513
+ /**
514
+ * Storage wrapper.
515
+ * @property {Object} wrapper
516
+ */
517
+ wrapper: Object
518
+ }
481
519
  /**
482
520
  * Localhost mode factory.
483
521
  * Its interface details are not part of the public API.
@@ -704,13 +742,87 @@ declare namespace SplitIO {
704
742
  interface ILogger {
705
743
  setLogLevel(logLevel: LogLevel): void
706
744
  }
745
+ /**
746
+ * Common settings interface for SDK instances created on the browser.
747
+ * @interface IBrowserBasicSettings
748
+ * @extends ISharedSettings
749
+ */
750
+ interface IBrowserBasicSettings extends ISharedSettings {
751
+ /**
752
+ * SDK Core settings for the browser.
753
+ * @property {Object} core
754
+ */
755
+ core: {
756
+ /**
757
+ * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
758
+ * @property {string} authorizationKey
759
+ */
760
+ authorizationKey: string,
761
+ /**
762
+ * Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
763
+ * @property {SplitKey} key
764
+ */
765
+ key: SplitKey,
766
+ /**
767
+ * Disable labels from being sent to Split backend. Labels may contain sensitive information.
768
+ * @property {boolean} labelsEnabled
769
+ * @default true
770
+ */
771
+ labelsEnabled?: boolean
772
+ },
773
+ /**
774
+ * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
775
+ * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
776
+ * @property {Object} urls
777
+ */
778
+ urls?: UrlSettings,
779
+ /**
780
+ * Defines an optional list of factory functions used to instantiate SDK integrations.
781
+ *
782
+ * Example:
783
+ * ```typescript
784
+ * SplitFactory({
785
+ * ...
786
+ * integrations: [SplitToGoogleAnalytics(), GoogleAnalyticsToSplit()]
787
+ * })
788
+ * ```
789
+ * @property {Object} integrations
790
+ */
791
+ integrations?: IntegrationFactory[],
792
+ }
707
793
  /**
708
794
  * Settings interface for SDK instances created on the browser.
709
795
  * @interface IBrowserSettings
710
796
  * @extends ISharedSettings
711
797
  * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
712
798
  */
713
- interface IBrowserSettings extends ISharedSettings {
799
+ interface IBrowserSettings extends IBrowserBasicSettings {
800
+ /**
801
+ * The SDK mode. When using the default in memory storage or `InLocalStorage` as storage, the only possible value is "standalone", which is the default.
802
+ * For "localhost" mode, use "localhost" as authorizationKey.
803
+ *
804
+ * @property {'standalone'} mode
805
+ * @default standalone
806
+ */
807
+ mode?: 'standalone',
808
+ /**
809
+ * Mocked features map. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
810
+ * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
811
+ */
812
+ features?: MockedFeaturesMap,
813
+ /**
814
+ * Defines the factory function to instantiate the storage. If not provided, the default IN MEMORY storage is used.
815
+ *
816
+ * Example:
817
+ * ```typescript
818
+ * SplitFactory({
819
+ * ...
820
+ * storage: InLocalStorage()
821
+ * })
822
+ * ```
823
+ * @property {Object} storage
824
+ */
825
+ storage?: StorageSyncFactory,
714
826
  /**
715
827
  * SDK Startup settings for the Browser.
716
828
  * @property {Object} startup
@@ -793,64 +905,89 @@ declare namespace SplitIO {
793
905
  * @default 1
794
906
  */
795
907
  pushRetryBackoffBase?: number,
796
- },
908
+ }
909
+ }
910
+ /**
911
+ * Settings interface with async storage for SDK instances created on the browser.
912
+ * If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.IBrowserSettings instead.
913
+ * @interface IBrowserAsyncSettings
914
+ * @extends IBrowserBasicSettings
915
+ * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
916
+ */
917
+ interface IBrowserAsyncSettings extends IBrowserBasicSettings {
797
918
  /**
798
- * SDK Core settings for the browser.
799
- * @property {Object} core
919
+ * The SDK mode. When using `PluggableStorage` as storage, the possible values are "consumer" and "consumer_partial".
920
+ *
921
+ * @see {@link @TODO}
922
+ *
923
+ * @property {'consumer' | 'consumer_partial'} mode
800
924
  */
801
- core: {
802
- /**
803
- * Your API key. More information: @see {@link https://help.split.io/hc/en-us/articles/360019916211-API-keys}
804
- * @property {string} authorizationKey
805
- */
806
- authorizationKey: string,
807
- /**
808
- * Customer identifier. Whatever this means to you. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
809
- * @property {SplitKey} key
810
- */
811
- key: SplitKey,
812
- /**
813
- * Disable labels from being sent to Split backend. Labels may contain sensitive information.
814
- * @property {boolean} labelsEnabled
815
- * @default true
816
- */
817
- labelsEnabled?: boolean
818
- },
925
+ mode: 'consumer' | 'consumer_partial',
819
926
  /**
820
- * Mocked features map. For testing purposses only. For using this you should specify "localhost" as authorizationKey on core settings.
821
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#localhost-mode}
822
- */
823
- features?: MockedFeaturesMap,
824
- /**
825
- * Defines the factory function to instanciate the storage. If not provided, the default IN MEMORY storage is used.
927
+ * Defines the factory function to instantiate the storage.
826
928
  *
827
929
  * Example:
828
930
  * ```typescript
829
- * config: {
830
- * storage: InLocalStorage()
831
- * }
931
+ * SplitFactory({
932
+ * ...
933
+ * storage: PluggableStorage({ wrapper: SomeWrapper })
934
+ * })
832
935
  * ```
833
936
  * @property {Object} storage
834
937
  */
835
- storage?: StorageSyncFactory,
938
+ storage: StorageAsyncFactory,
836
939
  /**
837
- * List of URLs that the SDK will use as base for it's synchronization functionalities, applicable only when running as standalone.
838
- * Do not change these settings unless you're working an advanced use case, like connecting to the Split proxy.
839
- * @property {Object} urls
940
+ * SDK Startup settings for the Browser.
941
+ * @property {Object} startup
840
942
  */
841
- urls?: UrlSettings,
943
+ startup?: {
944
+ /**
945
+ * Maximum amount of time used before notify a timeout.
946
+ * @property {number} readyTimeout
947
+ * @default 1.5
948
+ */
949
+ readyTimeout?: number,
950
+ /**
951
+ * For SDK posts the queued events data in bulks with a given rate, but the first push window is defined separately,
952
+ * to better control on browsers. This number defines that window before the first events push.
953
+ *
954
+ * NOTE: this param is ignored in 'consumer' mode.
955
+ * @property {number} eventsFirstPushWindow
956
+ * @default 10
957
+ */
958
+ eventsFirstPushWindow?: number,
959
+ },
842
960
  /**
843
- * Defines an optional list of factory functions used to instantiate SDK integrations.
844
- *
845
- * Example:
846
- * ```typescript
847
- * config: {
848
- * integrations: [SplitToGoogleAnalytics(), GoogleAnalyticsToSplit()]
849
- * }
850
- * ```
851
- * @property {Object} integrations
961
+ * SDK scheduler settings.
962
+ * @property {Object} scheduler
852
963
  */
853
- integrations?: IntegrationFactory[],
964
+ scheduler?: {
965
+ /**
966
+ * The SDK sends information on who got what treatment at what time back to Split servers to power analytics. This parameter controls how often this data is sent to Split servers. The parameter should be in seconds.
967
+ *
968
+ * NOTE: this param is ignored in 'consumer' mode.
969
+ * @property {number} impressionsRefreshRate
970
+ * @default 60
971
+ */
972
+ impressionsRefreshRate?: number,
973
+ /**
974
+ * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
975
+ *
976
+ * NOTE: this param is ignored in 'consumer' mode.
977
+ * @property {number} eventsPushRate
978
+ * @default 60
979
+ */
980
+ eventsPushRate?: number,
981
+ /**
982
+ * The maximum number of event items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
983
+ * If you use a 0 here, the queue will have no maximum size.
984
+ *
985
+ * NOTE: this param is ignored in 'consumer' mode.
986
+ * @property {number} eventsQueueSize
987
+ * @default 500
988
+ */
989
+ eventsQueueSize?: number,
990
+ }
854
991
  }
855
992
  /**
856
993
  * This represents the interface for the SDK instance with synchronous storage and client-side API,
@@ -858,7 +995,7 @@ declare namespace SplitIO {
858
995
  * @interface ISDK
859
996
  * @extends IBasicSDK
860
997
  */
861
- export interface ISDK extends IBasicSDK {
998
+ interface ISDK extends IBasicSDK {
862
999
  /**
863
1000
  * Returns the default client instance of the SDK, associated with the key and optional traffic type from settings.
864
1001
  * @function client
@@ -879,7 +1016,26 @@ declare namespace SplitIO {
879
1016
  */
880
1017
  manager(): IManager
881
1018
  }
882
-
1019
+ /**
1020
+ * This represents the interface for the SDK instance with asynchronous storage and client-side API,
1021
+ * i.e., where client instances have a bound user key.
1022
+ * @interface IAsyncSDK
1023
+ * @extends IBasicSDK
1024
+ */
1025
+ interface IAsyncSDK extends IBasicSDK {
1026
+ /**
1027
+ * Returns the default client instance of the SDK.
1028
+ * @function client
1029
+ * @returns {IAsyncClient} The asynchronous client instance.
1030
+ */
1031
+ client(): IAsyncClient,
1032
+ /**
1033
+ * Returns a manager instance of the SDK to explore available information.
1034
+ * @function manager
1035
+ * @returns {IManager} The manager instance.
1036
+ */
1037
+ manager(): IAsyncManager
1038
+ }
883
1039
  /**
884
1040
  * This represents the interface for the Client instance with synchronous storage for server-side SDK, where we don't have only one key.
885
1041
  * @interface IClient
@@ -887,35 +1043,35 @@ declare namespace SplitIO {
887
1043
  */
888
1044
  interface IClientSS extends IBasicClient {
889
1045
  /**
890
- * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1046
+ * Returns a Treatment value, which is the treatment string for the given feature.
891
1047
  * @function getTreatment
892
1048
  * @param {string} key - The string key representing the consumer.
893
1049
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
894
1050
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
895
- * @returns {Treatment} The treatment or treatment promise which will resolve to the treatment string.
1051
+ * @returns {Treatment} The treatment string.
896
1052
  */
897
1053
  getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): Treatment,
898
1054
  /**
899
- * Returns a TreatmentWithConfig value (a map of treatment and config), which will be (or eventually be) the map with treatment and config for the given feature.
1055
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
900
1056
  * @function getTreatmentWithConfig
901
1057
  * @param {string} key - The string key representing the consumer.
902
1058
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
903
1059
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
904
- * @returns {TreatmentWithConfig} The TreatmentWithConfig or TreatmentWithConfig promise which will resolve to the map containing
905
- * the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
1060
+ * @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
1061
+ * configuration stringified JSON (or null if there was no config for that treatment).
906
1062
  */
907
1063
  getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): TreatmentWithConfig,
908
1064
  /**
909
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1065
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
910
1066
  * @function getTreatments
911
1067
  * @param {string} key - The string key representing the consumer.
912
1068
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
913
1069
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
914
- * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1070
+ * @returns {Treatments} The treatments object map.
915
1071
  */
916
1072
  getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): Treatments,
917
1073
  /**
918
- * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
1074
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
919
1075
  * @function getTreatmentsWithConfig
920
1076
  * @param {string} key - The string key representing the consumer.
921
1077
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
@@ -931,7 +1087,7 @@ declare namespace SplitIO {
931
1087
  * @param {string} eventType - The event type corresponding to this event.
932
1088
  * @param {number=} value - The value of this event.
933
1089
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
934
- * @returns {boolean} Whether the event was added to the queue succesfully or not.
1090
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
935
1091
  */
936
1092
  track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
937
1093
  }
@@ -953,7 +1109,7 @@ declare namespace SplitIO {
953
1109
  */
954
1110
  getTreatment(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatment,
955
1111
  /**
956
- * Returns a TreatmentWithConfig value, which will be (or eventually be) a map with both treatment and config string for the given feature.
1112
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
957
1113
  * For usage on NodeJS as we don't have only one key.
958
1114
  * NOTE: Treatment will be a promise only in async storages, like REDIS.
959
1115
  * @function getTreatmentWithConfig
@@ -964,17 +1120,17 @@ declare namespace SplitIO {
964
1120
  */
965
1121
  getTreatmentWithConfig(key: SplitKey, splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
966
1122
  /**
967
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1123
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
968
1124
  * For usage on NodeJS as we don't have only one key.
969
1125
  * @function getTreatments
970
1126
  * @param {string} key - The string key representing the consumer.
971
1127
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
972
1128
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
973
- * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object.
1129
+ * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
974
1130
  */
975
1131
  getTreatments(key: SplitKey, splitNames: string[], attributes?: Attributes): AsyncTreatments,
976
1132
  /**
977
- * Returns a Treatments value, whick will be (or eventually be) an object with all the maps of treatment and config string for the given features.
1133
+ * Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
978
1134
  * For usage on NodeJS as we don't have only one key.
979
1135
  * @function getTreatmentsWithConfig
980
1136
  * @param {string} key - The string key representing the consumer.
@@ -991,7 +1147,7 @@ declare namespace SplitIO {
991
1147
  * @param {string} eventType - The event type corresponding to this event.
992
1148
  * @param {number=} value - The value of this event.
993
1149
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
994
- * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue succesfully or not.
1150
+ * @returns {Promise<boolean>} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
995
1151
  */
996
1152
  track(key: SplitIO.SplitKey, trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>
997
1153
  }
@@ -1002,31 +1158,31 @@ declare namespace SplitIO {
1002
1158
  */
1003
1159
  interface IClient extends IBasicClient {
1004
1160
  /**
1005
- * Returns a Treatment value, which will be the treatment string for the given feature.
1161
+ * Returns a Treatment value, which is the treatment string for the given feature.
1006
1162
  * @function getTreatment
1007
1163
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1008
1164
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1009
- * @returns {Treatment} The treatment result.
1165
+ * @returns {Treatment} The treatment string.
1010
1166
  */
1011
1167
  getTreatment(splitName: string, attributes?: Attributes): Treatment,
1012
1168
  /**
1013
- * Returns a TreatmentWithConfig value, which will be a map of treatment and the config for that treatment.
1014
- * @function getTreatment
1169
+ * Returns a TreatmentWithConfig value, which is an object with both treatment and config string for the given feature.
1170
+ * @function getTreatmentWithConfig
1015
1171
  * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1016
1172
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1017
- * @returns {TreatmentWithConfig} The treatment or treatment promise which will resolve to the treatment string.
1173
+ * @returns {TreatmentWithConfig} The map containing the treatment and the configuration stringified JSON (or null if there was no config for that treatment).
1018
1174
  */
1019
1175
  getTreatmentWithConfig(splitName: string, attributes?: Attributes): TreatmentWithConfig,
1020
1176
  /**
1021
- * Returns a Treatments value, whick will be (or eventually be) an object with the treatments for the given features.
1177
+ * Returns a Treatments value, which is an object map with the treatments for the given features.
1022
1178
  * @function getTreatments
1023
1179
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1024
1180
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1025
- * @returns {Treatments} The treatments or treatments promise which will resolve to the treatments object.
1181
+ * @returns {Treatments} The treatments object map.
1026
1182
  */
1027
1183
  getTreatments(splitNames: string[], attributes?: Attributes): Treatments,
1028
1184
  /**
1029
- * Returns a TreatmentsWithConfig value, whick will be an object with the TreatmentWithConfig (a map with both treatment and config string) for the given features.
1185
+ * Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1030
1186
  * @function getTreatmentsWithConfig
1031
1187
  * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1032
1188
  * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
@@ -1040,10 +1196,59 @@ declare namespace SplitIO {
1040
1196
  * @param {string} eventType - The event type corresponding to this event.
1041
1197
  * @param {number=} value - The value of this event.
1042
1198
  * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1043
- * @returns {boolean} Whether the event was added to the queue succesfully or not.
1199
+ * @returns {boolean} Whether the event was added to the queue successfully or not.
1044
1200
  */
1045
1201
  track(trafficType: string, eventType: string, value?: number, properties?: Properties): boolean,
1046
1202
  }
1203
+ /**
1204
+ * This represents the interface for the Client instance with asynchronous storage for client-side SDK, where each client has associated a key.
1205
+ * @interface IAsyncClient
1206
+ * @extends IBasicClient
1207
+ */
1208
+ interface IAsyncClient extends IBasicClient {
1209
+ /**
1210
+ * Returns a Treatment value, which will be (or eventually be) the treatment string for the given feature.
1211
+ * @function getTreatment
1212
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1213
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1214
+ * @returns {AsyncTreatment} Treatment promise which will resolve to the treatment string.
1215
+ */
1216
+ getTreatment(splitName: string, attributes?: Attributes): AsyncTreatment,
1217
+ /**
1218
+ * Returns a TreatmentWithConfig value, which will be (or eventually be) an object with both treatment and config string for the given feature.
1219
+ * @function getTreatmentWithConfig
1220
+ * @param {string} splitName - The string that represents the split we wan't to get the treatment.
1221
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1222
+ * @returns {AsyncTreatmentWithConfig} TreatmentWithConfig promise which will resolve to the TreatmentWithConfig object.
1223
+ */
1224
+ getTreatmentWithConfig(splitName: string, attributes?: Attributes): AsyncTreatmentWithConfig,
1225
+ /**
1226
+ * Returns a Treatments value, which will be (or eventually be) an object map with the treatments for the given features.
1227
+ * @function getTreatments
1228
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1229
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1230
+ * @returns {AsyncTreatments} Treatments promise which will resolve to the treatments object map.
1231
+ */
1232
+ getTreatments(splitNames: string[], attributes?: Attributes): AsyncTreatments,
1233
+ /**
1234
+ * Returns a TreatmentsWithConfig value, which will be (or eventually be) an object map with the TreatmentWithConfig (an object with both treatment and config string) for the given features.
1235
+ * @function getTreatmentsWithConfig
1236
+ * @param {Array<string>} splitNames - An array of the split names we wan't to get the treatments.
1237
+ * @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
1238
+ * @returns {TreatmentsWithConfig} TreatmentsWithConfig promise which will resolve to the map of TreatmentsWithConfig objects.
1239
+ */
1240
+ getTreatmentsWithConfig(splitNames: string[], attributes?: Attributes): AsyncTreatmentsWithConfig,
1241
+ /**
1242
+ * Tracks an event to be fed to the results product on Split Webconsole and returns a promise to signal when the event was successfully queued (or not).
1243
+ * @function track
1244
+ * @param {string} trafficType - The traffic type of the entity related to this event.
1245
+ * @param {string} eventType - The event type corresponding to this event.
1246
+ * @param {number=} value - The value of this event.
1247
+ * @param {Properties=} properties - The properties of this event. Values can be string, number, boolean or null.
1248
+ * @returns {boolean} A promise that resolves to a boolean indicating if the event was added to the queue successfully or not.
1249
+ */
1250
+ track(trafficType: string, eventType: string, value?: number, properties?: Properties): Promise<boolean>,
1251
+ }
1047
1252
  /**
1048
1253
  * Representation of a manager instance with synchronous storage of the SDK.
1049
1254
  * @interface IManager
@@ -1055,20 +1260,20 @@ declare namespace SplitIO {
1055
1260
  * @function names
1056
1261
  * @returns {SplitNames} The lists of Split names.
1057
1262
  */
1058
- names(): SplitNames;
1263
+ names(): SplitNames,
1059
1264
  /**
1060
1265
  * Get the array of splits data in SplitView format.
1061
1266
  * @function splits
1062
1267
  * @returns {SplitViews} The list of SplitIO.SplitView.
1063
1268
  */
1064
- splits(): SplitViews;
1269
+ splits(): SplitViews,
1065
1270
  /**
1066
1271
  * Get the data of a split in SplitView format.
1067
1272
  * @function split
1068
1273
  * @param {string} splitName The name of the split we wan't to get info of.
1069
1274
  * @returns {SplitView} The SplitIO.SplitView of the given split.
1070
1275
  */
1071
- split(splitName: string): SplitView;
1276
+ split(splitName: string): SplitView,
1072
1277
  }
1073
1278
  /**
1074
1279
  * Representation of a manager instance with asynchronous storage of the SDK.
@@ -1081,19 +1286,19 @@ declare namespace SplitIO {
1081
1286
  * @function names
1082
1287
  * @returns {SplitNamesAsync} A promise that will resolve to the array of Splitio.SplitNames.
1083
1288
  */
1084
- names(): SplitNamesAsync;
1289
+ names(): SplitNamesAsync,
1085
1290
  /**
1086
1291
  * Get the array of splits data in SplitView format.
1087
1292
  * @function splits
1088
1293
  * @returns {SplitViewsAsync} A promise that will resolve to the SplitIO.SplitView list.
1089
1294
  */
1090
- splits(): SplitViewsAsync;
1295
+ splits(): SplitViewsAsync,
1091
1296
  /**
1092
1297
  * Get the data of a split in SplitView format.
1093
1298
  * @function split
1094
1299
  * @param {string} splitName The name of the split we wan't to get info of.
1095
1300
  * @returns {SplitViewAsync} A promise that will resolve to the SplitIO.SplitView value.
1096
1301
  */
1097
- split(splitName: string): SplitViewAsync;
1302
+ split(splitName: string): SplitViewAsync,
1098
1303
  }
1099
1304
  }