@splitsoftware/splitio-browserjs 0.4.1-rc.0 → 0.5.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.
package/CHANGES.txt CHANGED
@@ -1,3 +1,14 @@
1
+ 0.5.0 (April 7, 2022)
2
+ - Added user consent feature to allow delaying or disabling the data tracking from SDK until user consent is explicitly granted or declined. Read more in our docs.
3
+ - Added `scheduler.impressionsQueueSize` property to SDK configuration to limit the amount of impressions tracked in memory. Read more in our docs.
4
+ - Updated format for MySegments keys in LocalStorage, keeping backwards compatibility (issue https://github.com/splitio/javascript-client/issues/638).
5
+ - Updated some dependencies for vulnerability fixes.
6
+ - Bugfixing - Updated internal isObject utility function, to avoid unexpected behaviors on frameworks and libraries that uses multiple VM contexts, like NuxtJS dev server.
7
+ - Bugfixing - Fixed validation of `core.key` SDK configuration param, to parse it into a string and log a warning when passing a number (Related to issue https://github.com/splitio/react-native-client/issues/19).
8
+ - Bugfixing - Fixed validation of `sync.impressionsMode` SDK configuration param, to avoid an exception on SplitFactory instantiation when passing a non-string value.
9
+ - Bugfixing - Fixed streaming synchronization issue when using multiple clients.
10
+ - Bugfixing - Fixed issue with internal Map ponyfill that results in logger not working properly on IE11 browser.
11
+
1
12
  0.4.1 (February 22, 2022)
2
13
  - Updated karma and some transitive dependencies for vulnerability fixes.
3
14
 
@@ -4,7 +4,6 @@ exports.SplitFactory = void 0;
4
4
  var full_1 = require("../settings/full");
5
5
  var getModules_1 = require("../platform/getModules");
6
6
  var index_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory/index");
7
- var lang_1 = require("@splitsoftware/splitio-commons/cjs/utils/lang");
8
7
  var getFetchFull_1 = require("../platform/getFetchFull");
9
8
  var getEventSource_1 = require("../platform/getEventSource");
10
9
  var MinEvents_1 = require("@splitsoftware/splitio-commons/cjs/utils/MinEvents");
@@ -13,13 +12,16 @@ var platform = { getFetch: getFetchFull_1.getFetch, getEventSource: getEventSour
13
12
  * SplitFactory with pluggable modules for Browser.
14
13
  * Includes localhost mode and fetch polyfill out-of-the-box.
15
14
  *
16
- * @param config configuration object used to instantiates the SDK
17
- * @param customModules optional object of SDK modules to overwrite default ones. Use with caution since, unlike `config`, this param is not validated.
15
+ * @param config configuration object used to instantiate the SDK
16
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
17
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
18
  * @throws Will throw an error if the provided config is invalid.
19
19
  */
20
- function SplitFactory(config, customModules) {
21
- var settings = full_1.settingsValidator(config);
22
- var modules = getModules_1.getModules(settings, platform);
23
- return index_1.sdkFactory(customModules ? lang_1.merge(modules, customModules) : modules);
20
+ function SplitFactory(config, __updateModules) {
21
+ var settings = (0, full_1.settingsValidator)(config);
22
+ var modules = (0, getModules_1.getModules)(settings, platform);
23
+ if (__updateModules)
24
+ __updateModules(modules);
25
+ return (0, index_1.sdkFactory)(modules);
24
26
  }
25
27
  exports.SplitFactory = SplitFactory;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // @ts-nocheck
4
+ var index_1 = require("./index");
5
+ // Include all pluggable modules as properties to expose at the global `splitio` object
6
+ index_1.SplitFactory.SplitFactory = index_1.SplitFactory;
7
+ index_1.SplitFactory.InLocalStorage = index_1.InLocalStorage;
8
+ index_1.SplitFactory.GoogleAnalyticsToSplit = index_1.GoogleAnalyticsToSplit;
9
+ index_1.SplitFactory.SplitToGoogleAnalytics = index_1.SplitToGoogleAnalytics;
10
+ index_1.SplitFactory.ErrorLogger = index_1.ErrorLogger;
11
+ index_1.SplitFactory.WarnLogger = index_1.WarnLogger;
12
+ index_1.SplitFactory.InfoLogger = index_1.InfoLogger;
13
+ index_1.SplitFactory.DebugLogger = index_1.DebugLogger;
14
+ // eslint-disable-next-line import/no-default-export
15
+ exports.default = index_1.SplitFactory;
package/cjs/index.js CHANGED
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ /**
3
+ Copyright 2022 Split Software
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ **/
2
17
  Object.defineProperty(exports, "__esModule", { value: true });
3
18
  exports.PluggableStorage = exports.LocalhostFromObject = exports.DebugLogger = exports.InfoLogger = exports.WarnLogger = exports.ErrorLogger = exports.SplitToGoogleAnalytics = exports.GoogleAnalyticsToSplit = exports.InLocalStorage = exports.SplitFactory = void 0;
4
19
  var splitFactory_1 = require("./splitFactory");
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFetch = void 0;
4
4
  var tslib_1 = require("tslib");
5
- var unfetch_1 = tslib_1.__importDefault(require("unfetch"));
5
+ var unfetch_1 = (0, tslib_1.__importDefault)(require("unfetch"));
6
6
  function getFetch() {
7
7
  return typeof fetch === 'function' ? fetch : unfetch_1.default;
8
8
  }
@@ -12,11 +12,12 @@ var impressionObserverCS_1 = require("@splitsoftware/splitio-commons/cjs/tracker
12
12
  var pluggable_1 = require("@splitsoftware/splitio-commons/cjs/integrations/pluggable");
13
13
  var utils_1 = require("@splitsoftware/splitio-commons/cjs/trackers/impressionObserver/utils");
14
14
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
15
+ var sdkUserConsent_1 = require("@splitsoftware/splitio-commons/cjs/consent/sdkUserConsent");
15
16
  var syncManagerStandaloneFactory;
16
17
  var syncManagerSubmittersFactory;
17
18
  function getModules(settings, platform) {
18
19
  if (!syncManagerStandaloneFactory)
19
- syncManagerStandaloneFactory = syncManagerOnline_1.syncManagerOnlineFactory(pollingManagerCS_1.pollingManagerCSFactory, pushManager_1.pushManagerFactory);
20
+ syncManagerStandaloneFactory = (0, syncManagerOnline_1.syncManagerOnlineFactory)(pollingManagerCS_1.pollingManagerCSFactory, pushManager_1.pushManagerFactory);
20
21
  var modules = {
21
22
  settings: settings,
22
23
  platform: platform,
@@ -26,9 +27,13 @@ function getModules(settings, platform) {
26
27
  sdkManagerFactory: index_1.sdkManagerFactory,
27
28
  sdkClientMethodFactory: sdkClientMethodCS_1.sdkClientMethodCSFactory,
28
29
  SignalListener: browser_1.BrowserSignalListener,
29
- impressionListener: settings.impressionListener,
30
30
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? pluggable_1.pluggableIntegrationsManagerFactory.bind(null, settings.integrations) : undefined,
31
- impressionsObserverFactory: utils_1.shouldAddPt(settings) ? impressionObserverCS_1.impressionObserverCSFactory : undefined,
31
+ impressionsObserverFactory: (0, utils_1.shouldAddPt)(settings) ? impressionObserverCS_1.impressionObserverCSFactory : undefined,
32
+ extraProps: function (params) {
33
+ return {
34
+ UserConsent: (0, sdkUserConsent_1.createUserConsentAPI)(params)
35
+ };
36
+ },
32
37
  };
33
38
  switch (settings.mode) {
34
39
  case constants_1.LOCALHOST_MODE:
@@ -41,7 +46,7 @@ function getModules(settings, platform) {
41
46
  break;
42
47
  case constants_1.CONSUMER_PARTIAL_MODE:
43
48
  if (!syncManagerSubmittersFactory)
44
- syncManagerSubmittersFactory = syncManagerOnline_1.syncManagerOnlineFactory(undefined, undefined);
49
+ syncManagerSubmittersFactory = (0, syncManagerOnline_1.syncManagerOnlineFactory)(undefined, undefined);
45
50
  modules.syncManagerFactory = syncManagerSubmittersFactory;
46
51
  }
47
52
  return modules;
@@ -2,7 +2,8 @@
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.4.1-rc.0';
5
+ var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
6
+ var packageVersion = '0.5.0';
6
7
  /**
7
8
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
8
9
  * Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
@@ -14,7 +15,7 @@ var LS_KEY = 'splitio_debug';
14
15
  try {
15
16
  var initialState = localStorage.getItem(LS_KEY) || '';
16
17
  // Kept to avoid a breaking change ('on', 'enable' and 'enabled' are equivalent)
17
- initialLogLevel = /^(enabled?|on)/i.test(initialState) ? index_1.LogLevels.DEBUG : index_1.isLogLevelString(initialState) ? initialState : index_1.LogLevels.NONE;
18
+ initialLogLevel = /^(enabled?|on)/i.test(initialState) ? index_1.LogLevels.DEBUG : (0, index_1.isLogLevelString)(initialState) ? initialState : index_1.LogLevels.NONE;
18
19
  // eslint-disable-next-line no-empty
19
20
  }
20
21
  catch (_a) { }
@@ -29,6 +30,8 @@ exports.defaults = {
29
30
  // Amount of time we will wait before the first push of events.
30
31
  eventsFirstPushWindow: 10
31
32
  },
33
+ // Consent is considered granted by default
34
+ userConsent: constants_1.CONSENT_GRANTED,
32
35
  // Instance version.
33
36
  version: "browserjs-" + packageVersion,
34
37
  debug: initialLogLevel
@@ -3,19 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.settingsValidator = void 0;
4
4
  var index_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/index");
5
5
  var defaults_1 = require("./defaults");
6
+ var runtime_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime");
6
7
  var storageCS_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/storage/storageCS");
7
8
  var pluggable_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/integrations/pluggable");
8
9
  var pluggableLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/pluggableLogger");
9
10
  var builtin_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/localhost/builtin");
11
+ var consent_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/consent");
10
12
  var params = {
11
13
  defaults: defaults_1.defaults,
14
+ acceptKey: true,
15
+ runtime: runtime_1.validateRuntime,
12
16
  storage: storageCS_1.validateStorageCS,
13
17
  integrations: pluggable_1.validatePluggableIntegrations,
14
18
  logger: pluggableLogger_1.validateLogger,
15
- // Full SplitFactory returns a default instance, except a valid one is provided
16
- localhost: builtin_1.validateLocalhostWithDefault
19
+ localhost: builtin_1.validateLocalhostWithDefault,
20
+ consent: consent_1.validateConsent,
17
21
  };
18
22
  function settingsValidator(config) {
19
- return index_1.settingsValidation(config, params);
23
+ return (0, index_1.settingsValidation)(config, params);
20
24
  }
21
25
  exports.settingsValidator = settingsValidator;
@@ -3,19 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.settingsValidator = void 0;
4
4
  var index_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/index");
5
5
  var defaults_1 = require("./defaults");
6
+ var runtime_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime");
6
7
  var storageCS_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/storage/storageCS");
7
8
  var pluggable_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/integrations/pluggable");
8
9
  var pluggableLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/pluggableLogger");
9
10
  var pluggable_2 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/localhost/pluggable");
11
+ var consent_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/consent");
10
12
  var params = {
11
13
  defaults: defaults_1.defaults,
14
+ acceptKey: true,
15
+ runtime: runtime_1.validateRuntime,
12
16
  storage: storageCS_1.validateStorageCS,
13
17
  integrations: pluggable_1.validatePluggableIntegrations,
14
18
  logger: pluggableLogger_1.validateLogger,
15
- // Slim SplitFactory validates that the localhost module is passed in localhost mode
16
- localhost: pluggable_2.validateLocalhost
19
+ localhost: pluggable_2.validateLocalhost,
20
+ consent: consent_1.validateConsent,
17
21
  };
18
22
  function settingsValidator(config) {
19
- return index_1.settingsValidation(config, params);
23
+ return (0, index_1.settingsValidation)(config, params);
20
24
  }
21
25
  exports.settingsValidator = settingsValidator;
@@ -4,7 +4,6 @@ exports.SplitFactory = void 0;
4
4
  var settings_1 = require("./settings");
5
5
  var getModules_1 = require("./platform/getModules");
6
6
  var index_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory/index");
7
- var lang_1 = require("@splitsoftware/splitio-commons/cjs/utils/lang");
8
7
  var getFetchSlim_1 = require("./platform/getFetchSlim");
9
8
  var getEventSource_1 = require("./platform/getEventSource");
10
9
  var MinEvents_1 = require("@splitsoftware/splitio-commons/cjs/utils/MinEvents");
@@ -13,13 +12,16 @@ var platform = { getFetch: getFetchSlim_1.getFetch, getEventSource: getEventSour
13
12
  * Slim SplitFactory with pluggable modules for Browser.
14
13
  * Doesn't include localhost mode and fetch ponyfill out-of-the-box.
15
14
  *
16
- * @param config configuration object used to instantiates the SDK
17
- * @param customModules optional object of SDK modules to overwrite default ones. Use with caution since, unlike `config`, this param is not validated.
15
+ * @param config configuration object used to instantiate the SDK
16
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
17
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
18
  * @throws Will throw an error if the provided config is invalid.
19
19
  */
20
- function SplitFactory(config, customModules) {
21
- var settings = settings_1.settingsValidator(config);
22
- var modules = getModules_1.getModules(settings, platform);
23
- return index_1.sdkFactory(customModules ? lang_1.merge(modules, customModules) : modules);
20
+ function SplitFactory(config, __updateModules) {
21
+ var settings = (0, settings_1.settingsValidator)(config);
22
+ var modules = (0, getModules_1.getModules)(settings, platform);
23
+ if (__updateModules)
24
+ __updateModules(modules);
25
+ return (0, index_1.sdkFactory)(modules);
24
26
  }
25
27
  exports.SplitFactory = SplitFactory;
package/cjs/umd.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // @ts-nocheck
4
+ var splitFactory_1 = require("./splitFactory");
5
+ splitFactory_1.SplitFactory.SplitFactory = splitFactory_1.SplitFactory;
6
+ // eslint-disable-next-line import/no-default-export
7
+ exports.default = splitFactory_1.SplitFactory;
@@ -1,7 +1,6 @@
1
1
  import { settingsValidator } from '../settings/full';
2
2
  import { getModules } from '../platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory/index';
4
- import { merge } from '@splitsoftware/splitio-commons/esm/utils/lang';
5
4
  import { getFetch } from '../platform/getFetchFull';
6
5
  import { getEventSource } from '../platform/getEventSource';
7
6
  import { EventEmitter } from '@splitsoftware/splitio-commons/esm/utils/MinEvents';
@@ -10,12 +9,15 @@ var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitte
10
9
  * SplitFactory with pluggable modules for Browser.
11
10
  * Includes localhost mode and fetch polyfill out-of-the-box.
12
11
  *
13
- * @param config configuration object used to instantiates the SDK
14
- * @param customModules optional object of SDK modules to overwrite default ones. Use with caution since, unlike `config`, this param is not validated.
12
+ * @param config configuration object used to instantiate the SDK
13
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
14
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
15
15
  * @throws Will throw an error if the provided config is invalid.
16
16
  */
17
- export function SplitFactory(config, customModules) {
17
+ export function SplitFactory(config, __updateModules) {
18
18
  var settings = settingsValidator(config);
19
19
  var modules = getModules(settings, platform);
20
- return sdkFactory(customModules ? merge(modules, customModules) : modules);
20
+ if (__updateModules)
21
+ __updateModules(modules);
22
+ return sdkFactory(modules);
21
23
  }
@@ -0,0 +1,13 @@
1
+ // @ts-nocheck
2
+ import { SplitFactory, InLocalStorage, GoogleAnalyticsToSplit, SplitToGoogleAnalytics, ErrorLogger, WarnLogger, InfoLogger, DebugLogger } from './index';
3
+ // Include all pluggable modules as properties to expose at the global `splitio` object
4
+ SplitFactory.SplitFactory = SplitFactory;
5
+ SplitFactory.InLocalStorage = InLocalStorage;
6
+ SplitFactory.GoogleAnalyticsToSplit = GoogleAnalyticsToSplit;
7
+ SplitFactory.SplitToGoogleAnalytics = SplitToGoogleAnalytics;
8
+ SplitFactory.ErrorLogger = ErrorLogger;
9
+ SplitFactory.WarnLogger = WarnLogger;
10
+ SplitFactory.InfoLogger = InfoLogger;
11
+ SplitFactory.DebugLogger = DebugLogger;
12
+ // eslint-disable-next-line import/no-default-export
13
+ export default SplitFactory;
package/esm/index.js CHANGED
@@ -1,3 +1,18 @@
1
+ /**
2
+ Copyright 2022 Split Software
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ **/
1
16
  export { SplitFactory } from './splitFactory';
2
17
  export { InLocalStorage } from '@splitsoftware/splitio-commons/esm/storages/inLocalStorage/index';
3
18
  export { GoogleAnalyticsToSplit } from '@splitsoftware/splitio-commons/esm/integrations/ga/GoogleAnalyticsToSplit';
@@ -9,6 +9,7 @@ import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/esm/
9
9
  import { pluggableIntegrationsManagerFactory } from '@splitsoftware/splitio-commons/esm/integrations/pluggable';
10
10
  import { shouldAddPt } from '@splitsoftware/splitio-commons/esm/trackers/impressionObserver/utils';
11
11
  import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE, LOCALHOST_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
12
+ import { createUserConsentAPI } from '@splitsoftware/splitio-commons/esm/consent/sdkUserConsent';
12
13
  var syncManagerStandaloneFactory;
13
14
  var syncManagerSubmittersFactory;
14
15
  export function getModules(settings, platform) {
@@ -23,9 +24,13 @@ export function getModules(settings, platform) {
23
24
  sdkManagerFactory: sdkManagerFactory,
24
25
  sdkClientMethodFactory: sdkClientMethodCSFactory,
25
26
  SignalListener: BrowserSignalListener,
26
- impressionListener: settings.impressionListener,
27
27
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? pluggableIntegrationsManagerFactory.bind(null, settings.integrations) : undefined,
28
28
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
29
+ extraProps: function (params) {
30
+ return {
31
+ UserConsent: createUserConsentAPI(params)
32
+ };
33
+ },
29
34
  };
30
35
  switch (settings.mode) {
31
36
  case LOCALHOST_MODE:
@@ -1,5 +1,6 @@
1
1
  import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/esm/logger/index';
2
- var packageVersion = '0.4.1-rc.0';
2
+ import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/esm/utils/constants';
3
+ var packageVersion = '0.5.0';
3
4
  /**
4
5
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
5
6
  * Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
@@ -26,6 +27,8 @@ export var defaults = {
26
27
  // Amount of time we will wait before the first push of events.
27
28
  eventsFirstPushWindow: 10
28
29
  },
30
+ // Consent is considered granted by default
31
+ userConsent: CONSENT_GRANTED,
29
32
  // Instance version.
30
33
  version: "browserjs-" + packageVersion,
31
34
  debug: initialLogLevel
@@ -1,16 +1,20 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/index';
2
2
  import { defaults } from './defaults';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime';
3
4
  import { validateStorageCS } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/storage/storageCS';
4
5
  import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/integrations/pluggable';
5
6
  import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/pluggableLogger';
6
7
  import { validateLocalhostWithDefault } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/localhost/builtin';
8
+ import { validateConsent } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/consent';
7
9
  var params = {
8
10
  defaults: defaults,
11
+ acceptKey: true,
12
+ runtime: validateRuntime,
9
13
  storage: validateStorageCS,
10
14
  integrations: validatePluggableIntegrations,
11
15
  logger: validateLogger,
12
- // Full SplitFactory returns a default instance, except a valid one is provided
13
- localhost: validateLocalhostWithDefault
16
+ localhost: validateLocalhostWithDefault,
17
+ consent: validateConsent,
14
18
  };
15
19
  export function settingsValidator(config) {
16
20
  return settingsValidation(config, params);
@@ -1,16 +1,20 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/index';
2
2
  import { defaults } from './defaults';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime';
3
4
  import { validateStorageCS } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/storage/storageCS';
4
5
  import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/integrations/pluggable';
5
6
  import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/pluggableLogger';
6
7
  import { validateLocalhost } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/localhost/pluggable';
8
+ import { validateConsent } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/consent';
7
9
  var params = {
8
10
  defaults: defaults,
11
+ acceptKey: true,
12
+ runtime: validateRuntime,
9
13
  storage: validateStorageCS,
10
14
  integrations: validatePluggableIntegrations,
11
15
  logger: validateLogger,
12
- // Slim SplitFactory validates that the localhost module is passed in localhost mode
13
- localhost: validateLocalhost
16
+ localhost: validateLocalhost,
17
+ consent: validateConsent,
14
18
  };
15
19
  export function settingsValidator(config) {
16
20
  return settingsValidation(config, params);
@@ -1,7 +1,6 @@
1
1
  import { settingsValidator } from './settings';
2
2
  import { getModules } from './platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory/index';
4
- import { merge } from '@splitsoftware/splitio-commons/esm/utils/lang';
5
4
  import { getFetch } from './platform/getFetchSlim';
6
5
  import { getEventSource } from './platform/getEventSource';
7
6
  import { EventEmitter } from '@splitsoftware/splitio-commons/esm/utils/MinEvents';
@@ -10,12 +9,15 @@ var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitte
10
9
  * Slim SplitFactory with pluggable modules for Browser.
11
10
  * Doesn't include localhost mode and fetch ponyfill out-of-the-box.
12
11
  *
13
- * @param config configuration object used to instantiates the SDK
14
- * @param customModules optional object of SDK modules to overwrite default ones. Use with caution since, unlike `config`, this param is not validated.
12
+ * @param config configuration object used to instantiate the SDK
13
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
14
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
15
15
  * @throws Will throw an error if the provided config is invalid.
16
16
  */
17
- export function SplitFactory(config, customModules) {
17
+ export function SplitFactory(config, __updateModules) {
18
18
  var settings = settingsValidator(config);
19
19
  var modules = getModules(settings, platform);
20
- return sdkFactory(customModules ? merge(modules, customModules) : modules);
20
+ if (__updateModules)
21
+ __updateModules(modules);
22
+ return sdkFactory(modules);
21
23
  }
package/esm/umd.js ADDED
@@ -0,0 +1,5 @@
1
+ // @ts-nocheck
2
+ import { SplitFactory } from './splitFactory';
3
+ SplitFactory.SplitFactory = SplitFactory;
4
+ // eslint-disable-next-line import/no-default-export
5
+ export default SplitFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-browserjs",
3
- "version": "0.4.1-rc.0",
3
+ "version": "0.5.0",
4
4
  "description": "Split SDK for Javascript on Browser",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -22,8 +22,8 @@
22
22
  "check:types": "tsc --noEmit",
23
23
  "check:version": "./scripts/check_version.sh",
24
24
  "build": "npm run build:cjs && npm run build:esm && npm run build:umd",
25
- "build:esm": "rimraf esm && tsc -outDir esm --importHelpers && ./scripts/build_esm_replace_imports.sh",
26
- "build:cjs": "rimraf cjs && tsc -outDir cjs -m CommonJS --importHelpers && ./scripts/build_cjs_replace_imports.sh",
25
+ "build:esm": "rimraf esm && tsc -outDir esm && ./scripts/build_esm_replace_imports.sh",
26
+ "build:cjs": "rimraf cjs && tsc -outDir cjs -m CommonJS && ./scripts/build_cjs_replace_imports.sh",
27
27
  "build:umd-visualizer": "rollup --config rollup.visualizer.config.js",
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",
@@ -61,7 +61,7 @@
61
61
  "bugs": "https://github.com/splitio/javascript-browser-client/issues",
62
62
  "homepage": "https://github.com/splitio/javascript-browser-client#readme",
63
63
  "dependencies": {
64
- "@splitsoftware/splitio-commons": "^1.2.0",
64
+ "@splitsoftware/splitio-commons": "1.3.0",
65
65
  "@types/google.analytics": "0.0.40"
66
66
  },
67
67
  "devDependencies": {
@@ -87,13 +87,13 @@
87
87
  "rollup-plugin-node-polyfills": "^0.2.1",
88
88
  "rollup-plugin-string": "^3.0.0",
89
89
  "rollup-plugin-terser": "^7.0.2",
90
- "rollup-plugin-ts": "^1.4.0",
90
+ "rollup-plugin-ts": "^1.4.7",
91
91
  "rollup-plugin-visualizer": "^4.2.0",
92
92
  "sinon": "^9.2.2",
93
93
  "tape": "4.13.2",
94
94
  "tape-catch": "1.0.6",
95
95
  "ts-jest": "^27.0.5",
96
- "typescript": "^4.1.3",
96
+ "typescript": "4.4.4",
97
97
  "unfetch": "^4.2.0"
98
98
  },
99
99
  "sideEffects": false
@@ -2,7 +2,6 @@ import { settingsValidator } from '../settings/full';
2
2
  import { getModules } from '../platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index';
4
4
  import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
5
- import { merge } from '@splitsoftware/splitio-commons/src/utils/lang';
6
5
  import { getFetch } from '../platform/getFetchFull';
7
6
  import { getEventSource } from '../platform/getEventSource';
8
7
  import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents';
@@ -13,12 +12,14 @@ const platform = { getFetch, getEventSource, EventEmitter };
13
12
  * SplitFactory with pluggable modules for Browser.
14
13
  * Includes localhost mode and fetch polyfill out-of-the-box.
15
14
  *
16
- * @param config configuration object used to instantiates the SDK
17
- * @param customModules optional object of SDK modules to overwrite default ones. Use with caution since, unlike `config`, this param is not validated.
15
+ * @param config configuration object used to instantiate the SDK
16
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
17
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
18
  * @throws Will throw an error if the provided config is invalid.
19
19
  */
20
- export function SplitFactory(config: any, customModules?: Partial<ISdkFactoryParams>) {
20
+ export function SplitFactory(config: any, __updateModules: (modules: ISdkFactoryParams) => void) {
21
21
  const settings = settingsValidator(config);
22
22
  const modules = getModules(settings, platform);
23
- return sdkFactory(customModules ? merge(modules, customModules) as ISdkFactoryParams : modules);
23
+ if (__updateModules) __updateModules(modules);
24
+ return sdkFactory(modules);
24
25
  }
package/src/index.ts CHANGED
@@ -1,3 +1,19 @@
1
+ /**
2
+ Copyright 2022 Split Software
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ **/
16
+
1
17
  export { SplitFactory } from './splitFactory';
2
18
  export { InLocalStorage } from '@splitsoftware/splitio-commons/src/storages/inLocalStorage/index';
3
19
  export { GoogleAnalyticsToSplit } from '@splitsoftware/splitio-commons/src/integrations/ga/GoogleAnalyticsToSplit';
@@ -10,8 +10,9 @@ import { pluggableIntegrationsManagerFactory } from '@splitsoftware/splitio-comm
10
10
 
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
- import { SplitIO, ISettings } from '@splitsoftware/splitio-commons/src/types';
13
+ import { ISettings } from '@splitsoftware/splitio-commons/src/types';
14
14
  import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE, LOCALHOST_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
15
+ import { createUserConsentAPI } from '@splitsoftware/splitio-commons/src/consent/sdkUserConsent';
15
16
 
16
17
  let syncManagerStandaloneFactory: ISdkFactoryParams['syncManagerFactory'];
17
18
  let syncManagerSubmittersFactory: ISdkFactoryParams['syncManagerFactory'];
@@ -37,11 +38,15 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor
37
38
 
38
39
  SignalListener: BrowserSignalListener as ISdkFactoryParams['SignalListener'],
39
40
 
40
- impressionListener: settings.impressionListener as SplitIO.IImpressionListener,
41
-
42
41
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? pluggableIntegrationsManagerFactory.bind(null, settings.integrations) : undefined,
43
42
 
44
43
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
44
+
45
+ extraProps: (params) => {
46
+ return {
47
+ UserConsent: createUserConsentAPI(params)
48
+ };
49
+ },
45
50
  };
46
51
 
47
52
  switch (settings.mode) {
@@ -1,7 +1,8 @@
1
1
  import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/logger/index';
2
- import { LogLevel } from '@splitsoftware/splitio-commons/src/types';
2
+ import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types';
3
+ import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants';
3
4
 
4
- const packageVersion = '0.4.1-rc.0';
5
+ const packageVersion = '0.5.0';
5
6
 
6
7
  /**
7
8
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
@@ -32,6 +33,9 @@ export const defaults = {
32
33
  eventsFirstPushWindow: 10
33
34
  },
34
35
 
36
+ // Consent is considered granted by default
37
+ userConsent: CONSENT_GRANTED as ConsentStatus,
38
+
35
39
  // Instance version.
36
40
  version: `browserjs-${packageVersion}`,
37
41
 
@@ -1,17 +1,21 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/index';
2
2
  import { defaults } from './defaults';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime';
3
4
  import { validateStorageCS } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS';
4
5
  import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/integrations/pluggable';
5
6
  import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/pluggableLogger';
6
7
  import { validateLocalhostWithDefault } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/localhost/builtin';
8
+ import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/consent';
7
9
 
8
10
  const params = {
9
11
  defaults,
12
+ acceptKey: true, // Client with bound key
13
+ runtime: validateRuntime,
10
14
  storage: validateStorageCS,
11
15
  integrations: validatePluggableIntegrations,
12
16
  logger: validateLogger,
13
- // Full SplitFactory returns a default instance, except a valid one is provided
14
- localhost: validateLocalhostWithDefault
17
+ localhost: validateLocalhostWithDefault, // Full SplitFactory provides a default localhost module, except a valid one is provided
18
+ consent: validateConsent,
15
19
  };
16
20
 
17
21
  export function settingsValidator(config: any) {
@@ -1,17 +1,21 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/index';
2
2
  import { defaults } from './defaults';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime';
3
4
  import { validateStorageCS } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS';
4
5
  import { validatePluggableIntegrations } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/integrations/pluggable';
5
6
  import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/pluggableLogger';
6
7
  import { validateLocalhost } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/localhost/pluggable';
8
+ import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/consent';
7
9
 
8
10
  const params = {
9
11
  defaults,
12
+ acceptKey: true, // Client with bound key
13
+ runtime: validateRuntime,
10
14
  storage: validateStorageCS,
11
15
  integrations: validatePluggableIntegrations,
12
16
  logger: validateLogger,
13
- // Slim SplitFactory validates that the localhost module is passed in localhost mode
14
- localhost: validateLocalhost
17
+ localhost: validateLocalhost, // Slim SplitFactory validates that the localhost module is passed in localhost mode
18
+ consent: validateConsent,
15
19
  };
16
20
 
17
21
  export function settingsValidator(config: any) {
@@ -2,7 +2,6 @@ import { settingsValidator } from './settings';
2
2
  import { getModules } from './platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index';
4
4
  import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
5
- import { merge } from '@splitsoftware/splitio-commons/src/utils/lang';
6
5
  import { getFetch } from './platform/getFetchSlim';
7
6
  import { getEventSource } from './platform/getEventSource';
8
7
  import { EventEmitter } from '@splitsoftware/splitio-commons/src/utils/MinEvents';
@@ -13,12 +12,14 @@ const platform = { getFetch, getEventSource, EventEmitter };
13
12
  * Slim SplitFactory with pluggable modules for Browser.
14
13
  * Doesn't include localhost mode and fetch ponyfill out-of-the-box.
15
14
  *
16
- * @param config configuration object used to instantiates the SDK
17
- * @param customModules optional object of SDK modules to overwrite default ones. Use with caution since, unlike `config`, this param is not validated.
15
+ * @param config configuration object used to instantiate the SDK
16
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
17
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
18
  * @throws Will throw an error if the provided config is invalid.
19
19
  */
20
- export function SplitFactory(config: any, customModules?: Partial<ISdkFactoryParams>) {
20
+ export function SplitFactory(config: any, __updateModules: (modules: ISdkFactoryParams) => void) {
21
21
  const settings = settingsValidator(config);
22
22
  const modules = getModules(settings, platform);
23
- return sdkFactory(customModules ? merge(modules, customModules) as ISdkFactoryParams : modules);
23
+ if (__updateModules) __updateModules(modules);
24
+ return sdkFactory(modules);
24
25
  }
@@ -58,6 +58,7 @@ interface ISettings {
58
58
  readonly scheduler: {
59
59
  featuresRefreshRate: number,
60
60
  impressionsRefreshRate: number,
61
+ impressionsQueueSize: number,
61
62
  segmentsRefreshRate: number,
62
63
  offlineRefreshRate: number,
63
64
  eventsPushRate: number,
@@ -89,7 +90,8 @@ interface ISettings {
89
90
  splitFilters: SplitIO.SplitFilter[],
90
91
  impressionsMode: SplitIO.ImpressionsMode,
91
92
  localhostMode?: SplitIO.LocalhostFactory
92
- }
93
+ },
94
+ readonly userConsent: SplitIO.ConsentStatus
93
95
  }
94
96
  /**
95
97
  * Log levels.
@@ -123,7 +125,38 @@ interface ILoggerAPI {
123
125
  * Log level constants. Use this to pass them to setLogLevel function.
124
126
  */
125
127
  LogLevel: {
126
- [level: string]: LogLevel
128
+ [level in LogLevel]: LogLevel
129
+ }
130
+ }
131
+ /**
132
+ * User consent API
133
+ * @interface IUserConsentAPI
134
+ */
135
+ interface IUserConsentAPI {
136
+ /**
137
+ * Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
138
+ * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
139
+ * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
140
+ *
141
+ * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
142
+ *
143
+ * @function setStatus
144
+ * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
145
+ * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
146
+ */
147
+ setStatus(userConsent: boolean): boolean;
148
+ /**
149
+ * Get the user consent status.
150
+ *
151
+ * @function getStatus
152
+ * @returns {ConsentStatus} The user consent status.
153
+ */
154
+ getStatus(): SplitIO.ConsentStatus;
155
+ /**
156
+ * Consent status constants. Use this to compare with the getStatus function result.
157
+ */
158
+ Status: {
159
+ [status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus
127
160
  }
128
161
  }
129
162
  /**
@@ -268,7 +301,12 @@ interface IBasicSDK {
268
301
  * Logger API.
269
302
  * @property Logger
270
303
  */
271
- Logger: ILoggerAPI
304
+ Logger: ILoggerAPI,
305
+ /**
306
+ * User consent API.
307
+ * @property UserConsent
308
+ */
309
+ UserConsent: IUserConsentAPI
272
310
  }
273
311
  /****** Exposed namespace ******/
274
312
  /**
@@ -548,7 +586,10 @@ declare namespace SplitIO {
548
586
  * By returning an integration, the SDK will queue events and impressions into it.
549
587
  * Input parameter details are not part of the public API.
550
588
  */
551
- type IntegrationFactory = (params: {}) => (Integration | void)
589
+ type IntegrationFactory = {
590
+ readonly type: string
591
+ (params: {}): (Integration | void)
592
+ }
552
593
  /**
553
594
  * A pair of user key and it's trafficType, required for tracking valid Split events.
554
595
  * @typedef {Object} Identity
@@ -739,6 +780,11 @@ declare namespace SplitIO {
739
780
  * @typedef {string} ImpressionsMode
740
781
  */
741
782
  type ImpressionsMode = 'OPTIMIZED' | 'DEBUG';
783
+ /**
784
+ * User consent status.
785
+ * @typedef {string} ConsentStatus
786
+ */
787
+ type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
742
788
  /**
743
789
  * Logger
744
790
  * Its interface details are not part of the public API. It shouldn't be used directly.
@@ -794,6 +840,17 @@ declare namespace SplitIO {
794
840
  * @property {Object} integrations
795
841
  */
796
842
  integrations?: IntegrationFactory[],
843
+ /**
844
+ * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
845
+ * - `'GRANTED'`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
846
+ * - `'DECLINED'`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
847
+ * - `'UNKNOWN'`: the user has neither granted nor declined consent for tracking events and impressions. The SDK will track them in its internal storage, and eventually send
848
+ * them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `setUserConsent` factory method.
849
+ *
850
+ * @typedef {string} userConsent
851
+ * @default 'GRANTED'
852
+ */
853
+ userConsent?: ConsentStatus
797
854
  }
798
855
  /**
799
856
  * Settings interface for SDK instances created on the browser.
@@ -877,6 +934,13 @@ declare namespace SplitIO {
877
934
  * @default 60
878
935
  */
879
936
  impressionsRefreshRate?: number,
937
+ /**
938
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
939
+ * If you use a 0 here, the queue will have no maximum size.
940
+ * @property {number} impressionsQueueSize
941
+ * @default 30000
942
+ */
943
+ impressionsQueueSize?: number,
880
944
  /**
881
945
  * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
882
946
  * @property {number} segmentsRefreshRate
@@ -975,6 +1039,13 @@ declare namespace SplitIO {
975
1039
  * @default 60
976
1040
  */
977
1041
  impressionsRefreshRate?: number,
1042
+ /**
1043
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1044
+ * If you use a 0 here, the queue will have no maximum size.
1045
+ * @property {number} impressionsQueueSize
1046
+ * @default 30000
1047
+ */
1048
+ impressionsQueueSize?: number,
978
1049
  /**
979
1050
  * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
980
1051
  *
@@ -1002,13 +1073,13 @@ declare namespace SplitIO {
1002
1073
  */
1003
1074
  interface ISDK extends IBasicSDK {
1004
1075
  /**
1005
- * Returns the default client instance of the SDK, associated with the key and optional traffic type from settings.
1076
+ * Returns the default client instance of the SDK, associated with the key provided on settings.
1006
1077
  * @function client
1007
1078
  * @returns {IClient} The client instance.
1008
1079
  */
1009
1080
  client(): IClient,
1010
1081
  /**
1011
- * Returns a shared client of the SDK, associated with the given key and optional traffic type.
1082
+ * Returns a shared client of the SDK, associated with the given key.
1012
1083
  * @function client
1013
1084
  * @param {SplitKey} key The key for the new client instance.
1014
1085
  * @returns {IClient} The client instance.
@@ -1029,11 +1100,18 @@ declare namespace SplitIO {
1029
1100
  */
1030
1101
  interface IAsyncSDK extends IBasicSDK {
1031
1102
  /**
1032
- * Returns the default client instance of the SDK.
1103
+ * Returns the default client instance of the SDK, associated with the key provided on settings.
1033
1104
  * @function client
1034
1105
  * @returns {IAsyncClient} The asynchronous client instance.
1035
1106
  */
1036
1107
  client(): IAsyncClient,
1108
+ /**
1109
+ * Returns a shared client of the SDK, associated with the given key.
1110
+ * @function client
1111
+ * @param {SplitKey} key The key for the new client instance.
1112
+ * @returns {IAsyncClient} The asynchronous client instance.
1113
+ */
1114
+ client(key: SplitKey): IAsyncClient,
1037
1115
  /**
1038
1116
  * Returns a manager instance of the SDK to explore available information.
1039
1117
  * @function manager
@@ -1207,7 +1285,7 @@ declare namespace SplitIO {
1207
1285
  /**
1208
1286
  * Add an attribute to client's in memory attributes storage.
1209
1287
  *
1210
- * @param {string} attributeName Attrinute name
1288
+ * @param {string} attributeName Attribute name
1211
1289
  * @param {AttributeType} attributeValue Attribute value
1212
1290
  * @returns {boolean} true if the attribute was stored and false otherwise
1213
1291
  */
@@ -1297,7 +1375,7 @@ declare namespace SplitIO {
1297
1375
  /**
1298
1376
  * Add an attribute to client's in memory attributes storage.
1299
1377
  *
1300
- * @param {string} attributeName Attrinute name
1378
+ * @param {string} attributeName Attribute name
1301
1379
  * @param {AttributeType} attributeValue Attribute value
1302
1380
  * @returns {boolean} true if the attribute was stored and false otherwise
1303
1381
  */