@splitsoftware/splitio-browserjs 0.4.1 → 0.5.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,22 +4,25 @@ 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");
11
- var platform = { getFetch: getFetchFull_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.EventEmitter };
10
+ var browser_1 = require("@splitsoftware/splitio-commons/cjs/utils/timeTracker/now/browser");
11
+ var platform = { getFetch: getFetchFull_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.EventEmitter, now: browser_1.now };
12
12
  /**
13
13
  * SplitFactory with pluggable modules for Browser.
14
14
  * Includes localhost mode and fetch polyfill out-of-the-box.
15
15
  *
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.
16
+ * @param config configuration object used to instantiate the SDK
17
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
18
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
19
  * @throws Will throw an error if the provided config is invalid.
19
20
  */
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);
21
+ function SplitFactory(config, __updateModules) {
22
+ var settings = (0, full_1.settingsValidator)(config);
23
+ var modules = (0, getModules_1.getModules)(settings, platform);
24
+ if (__updateModules)
25
+ __updateModules(modules);
26
+ return (0, index_1.sdkFactory)(modules);
24
27
  }
25
28
  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';
5
+ var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
6
+ var packageVersion = '0.5.1-rc.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,22 +4,25 @@ 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");
11
- var platform = { getFetch: getFetchSlim_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.EventEmitter };
10
+ var browser_1 = require("@splitsoftware/splitio-commons/cjs/utils/timeTracker/now/browser");
11
+ var platform = { getFetch: getFetchSlim_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.EventEmitter, now: browser_1.now };
12
12
  /**
13
13
  * Slim SplitFactory with pluggable modules for Browser.
14
14
  * Doesn't include localhost mode and fetch ponyfill out-of-the-box.
15
15
  *
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.
16
+ * @param config configuration object used to instantiate the SDK
17
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
18
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
19
  * @throws Will throw an error if the provided config is invalid.
19
20
  */
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);
21
+ function SplitFactory(config, __updateModules) {
22
+ var settings = (0, settings_1.settingsValidator)(config);
23
+ var modules = (0, getModules_1.getModules)(settings, platform);
24
+ if (__updateModules)
25
+ __updateModules(modules);
26
+ return (0, index_1.sdkFactory)(modules);
24
27
  }
25
28
  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,21 +1,24 @@
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';
8
- var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitter: EventEmitter };
7
+ import { now } from '@splitsoftware/splitio-commons/esm/utils/timeTracker/now/browser';
8
+ var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitter: EventEmitter, now: now };
9
9
  /**
10
10
  * SplitFactory with pluggable modules for Browser.
11
11
  * Includes localhost mode and fetch polyfill out-of-the-box.
12
12
  *
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.
13
+ * @param config configuration object used to instantiate the SDK
14
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
15
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
15
16
  * @throws Will throw an error if the provided config is invalid.
16
17
  */
17
- export function SplitFactory(config, customModules) {
18
+ export function SplitFactory(config, __updateModules) {
18
19
  var settings = settingsValidator(config);
19
20
  var modules = getModules(settings, platform);
20
- return sdkFactory(customModules ? merge(modules, customModules) : modules);
21
+ if (__updateModules)
22
+ __updateModules(modules);
23
+ return sdkFactory(modules);
21
24
  }
@@ -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';
2
+ import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/esm/utils/constants';
3
+ var packageVersion = '0.5.1-rc.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,21 +1,24 @@
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';
8
- var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitter: EventEmitter };
7
+ import { now } from '@splitsoftware/splitio-commons/esm/utils/timeTracker/now/browser';
8
+ var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitter: EventEmitter, now: now };
9
9
  /**
10
10
  * Slim SplitFactory with pluggable modules for Browser.
11
11
  * Doesn't include localhost mode and fetch ponyfill out-of-the-box.
12
12
  *
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.
13
+ * @param config configuration object used to instantiate the SDK
14
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
15
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
15
16
  * @throws Will throw an error if the provided config is invalid.
16
17
  */
17
- export function SplitFactory(config, customModules) {
18
+ export function SplitFactory(config, __updateModules) {
18
19
  var settings = settingsValidator(config);
19
20
  var modules = getModules(settings, platform);
20
- return sdkFactory(customModules ? merge(modules, customModules) : modules);
21
+ if (__updateModules)
22
+ __updateModules(modules);
23
+ return sdkFactory(modules);
21
24
  }
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",
3
+ "version": "0.5.1-rc.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.2-rc.6",
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,23 +2,25 @@ 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';
8
+ import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser';
9
9
 
10
- const platform = { getFetch, getEventSource, EventEmitter };
10
+ const platform = { getFetch, getEventSource, EventEmitter, now };
11
11
 
12
12
  /**
13
13
  * SplitFactory with pluggable modules for Browser.
14
14
  * Includes localhost mode and fetch polyfill out-of-the-box.
15
15
  *
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.
16
+ * @param config configuration object used to instantiate the SDK
17
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
18
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
19
  * @throws Will throw an error if the provided config is invalid.
19
20
  */
20
- export function SplitFactory(config: any, customModules?: Partial<ISdkFactoryParams>) {
21
+ export function SplitFactory(config: any, __updateModules?: (modules: ISdkFactoryParams) => void) {
21
22
  const settings = settingsValidator(config);
22
23
  const modules = getModules(settings, platform);
23
- return sdkFactory(customModules ? merge(modules, customModules) as ISdkFactoryParams : modules);
24
+ if (__updateModules) __updateModules(modules);
25
+ return sdkFactory(modules);
24
26
  }
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';
5
+ const packageVersion = '0.5.1-rc.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,23 +2,25 @@ 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';
8
+ import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/browser';
9
9
 
10
- const platform = { getFetch, getEventSource, EventEmitter };
10
+ const platform = { getFetch, getEventSource, EventEmitter, now };
11
11
 
12
12
  /**
13
13
  * Slim SplitFactory with pluggable modules for Browser.
14
14
  * Doesn't include localhost mode and fetch ponyfill out-of-the-box.
15
15
  *
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.
16
+ * @param config configuration object used to instantiate the SDK
17
+ * @param __updateModules optional function that lets redefine internal SDK modules. Use with
18
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
18
19
  * @throws Will throw an error if the provided config is invalid.
19
20
  */
20
- export function SplitFactory(config: any, customModules?: Partial<ISdkFactoryParams>) {
21
+ export function SplitFactory(config: any, __updateModules?: (modules: ISdkFactoryParams) => void) {
21
22
  const settings = settingsValidator(config);
22
23
  const modules = getModules(settings, platform);
23
- return sdkFactory(customModules ? merge(modules, customModules) as ISdkFactoryParams : modules);
24
+ if (__updateModules) __updateModules(modules);
25
+ return sdkFactory(modules);
24
26
  }
@@ -58,6 +58,8 @@ interface ISettings {
58
58
  readonly scheduler: {
59
59
  featuresRefreshRate: number,
60
60
  impressionsRefreshRate: number,
61
+ impressionsQueueSize: number,
62
+ telemetryRefreshRate: number,
61
63
  segmentsRefreshRate: number,
62
64
  offlineRefreshRate: number,
63
65
  eventsPushRate: number,
@@ -75,7 +77,8 @@ interface ISettings {
75
77
  events: string,
76
78
  sdk: string,
77
79
  auth: string,
78
- streaming: string
80
+ streaming: string,
81
+ telemetry: string
79
82
  },
80
83
  readonly integrations?: SplitIO.IntegrationFactory[],
81
84
  readonly debug: boolean | LogLevel | SplitIO.ILogger,
@@ -89,7 +92,8 @@ interface ISettings {
89
92
  splitFilters: SplitIO.SplitFilter[],
90
93
  impressionsMode: SplitIO.ImpressionsMode,
91
94
  localhostMode?: SplitIO.LocalhostFactory
92
- }
95
+ },
96
+ readonly userConsent: SplitIO.ConsentStatus
93
97
  }
94
98
  /**
95
99
  * Log levels.
@@ -123,7 +127,38 @@ interface ILoggerAPI {
123
127
  * Log level constants. Use this to pass them to setLogLevel function.
124
128
  */
125
129
  LogLevel: {
126
- [level: string]: LogLevel
130
+ [level in LogLevel]: LogLevel
131
+ }
132
+ }
133
+ /**
134
+ * User consent API
135
+ * @interface IUserConsentAPI
136
+ */
137
+ interface IUserConsentAPI {
138
+ /**
139
+ * Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
140
+ * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
141
+ * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
142
+ *
143
+ * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
144
+ *
145
+ * @function setStatus
146
+ * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
147
+ * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
148
+ */
149
+ setStatus(userConsent: boolean): boolean;
150
+ /**
151
+ * Get the user consent status.
152
+ *
153
+ * @function getStatus
154
+ * @returns {ConsentStatus} The user consent status.
155
+ */
156
+ getStatus(): SplitIO.ConsentStatus;
157
+ /**
158
+ * Consent status constants. Use this to compare with the getStatus function result.
159
+ */
160
+ Status: {
161
+ [status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus
127
162
  }
128
163
  }
129
164
  /**
@@ -268,7 +303,12 @@ interface IBasicSDK {
268
303
  * Logger API.
269
304
  * @property Logger
270
305
  */
271
- Logger: ILoggerAPI
306
+ Logger: ILoggerAPI,
307
+ /**
308
+ * User consent API.
309
+ * @property UserConsent
310
+ */
311
+ UserConsent: IUserConsentAPI
272
312
  }
273
313
  /****** Exposed namespace ******/
274
314
  /**
@@ -548,7 +588,10 @@ declare namespace SplitIO {
548
588
  * By returning an integration, the SDK will queue events and impressions into it.
549
589
  * Input parameter details are not part of the public API.
550
590
  */
551
- type IntegrationFactory = (params: {}) => (Integration | void)
591
+ type IntegrationFactory = {
592
+ readonly type: string
593
+ (params: {}): (Integration | void)
594
+ }
552
595
  /**
553
596
  * A pair of user key and it's trafficType, required for tracking valid Split events.
554
597
  * @typedef {Object} Identity
@@ -711,7 +754,13 @@ declare namespace SplitIO {
711
754
  * @property {string} streaming
712
755
  * @default 'https://streaming.split.io'
713
756
  */
714
- streaming?: string
757
+ streaming?: string,
758
+ /**
759
+ * String property to override the base URL where the SDK will post telemetry data.
760
+ * @property {string} telemetry
761
+ * @default 'https://telemetry.split.io/api'
762
+ */
763
+ telemetry?: string
715
764
  };
716
765
 
717
766
  /**
@@ -739,6 +788,11 @@ declare namespace SplitIO {
739
788
  * @typedef {string} ImpressionsMode
740
789
  */
741
790
  type ImpressionsMode = 'OPTIMIZED' | 'DEBUG';
791
+ /**
792
+ * User consent status.
793
+ * @typedef {string} ConsentStatus
794
+ */
795
+ type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
742
796
  /**
743
797
  * Logger
744
798
  * Its interface details are not part of the public API. It shouldn't be used directly.
@@ -794,6 +848,17 @@ declare namespace SplitIO {
794
848
  * @property {Object} integrations
795
849
  */
796
850
  integrations?: IntegrationFactory[],
851
+ /**
852
+ * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
853
+ * - `'GRANTED'`: the user grants consent for tracking events and impressions. The SDK sends them to Split cloud.
854
+ * - `'DECLINED'`: the user declines consent for tracking events and impressions. The SDK does not send them to Split cloud.
855
+ * - `'UNKNOWN'`: the user neither grants nor declines consent for tracking events and impressions. The SDK tracks them in its internal storage, and eventually either sends
856
+ * them or not if the consent status is updated to 'GRANTED' or 'DECLINED' respectively. The status can be updated at any time with the `UserConsent.setStatus` factory method.
857
+ *
858
+ * @typedef {string} userConsent
859
+ * @default 'GRANTED'
860
+ */
861
+ userConsent?: ConsentStatus
797
862
  }
798
863
  /**
799
864
  * Settings interface for SDK instances created on the browser.
@@ -877,6 +942,19 @@ declare namespace SplitIO {
877
942
  * @default 60
878
943
  */
879
944
  impressionsRefreshRate?: number,
945
+ /**
946
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
947
+ * If you use a 0 here, the queue will have no maximum size.
948
+ * @property {number} impressionsQueueSize
949
+ * @default 30000
950
+ */
951
+ impressionsQueueSize?: number,
952
+ /**
953
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
954
+ * @property {number} telemetryRefreshRate
955
+ * @default 3600
956
+ */
957
+ telemetryRefreshRate?: number,
880
958
  /**
881
959
  * The SDK polls Split servers for changes to segment definitions. This parameter controls this polling period in seconds.
882
960
  * @property {number} segmentsRefreshRate
@@ -975,6 +1053,19 @@ declare namespace SplitIO {
975
1053
  * @default 60
976
1054
  */
977
1055
  impressionsRefreshRate?: number,
1056
+ /**
1057
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
1058
+ * If you use a 0 here, the queue will have no maximum size.
1059
+ * @property {number} impressionsQueueSize
1060
+ * @default 30000
1061
+ */
1062
+ impressionsQueueSize?: number,
1063
+ /**
1064
+ * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
1065
+ * @property {number} telemetryRefreshRate
1066
+ * @default 3600
1067
+ */
1068
+ telemetryRefreshRate?: number,
978
1069
  /**
979
1070
  * The SDK posts the queued events data in bulks. This parameter controls the posting rate in seconds.
980
1071
  *
@@ -1002,13 +1093,13 @@ declare namespace SplitIO {
1002
1093
  */
1003
1094
  interface ISDK extends IBasicSDK {
1004
1095
  /**
1005
- * Returns the default client instance of the SDK, associated with the key and optional traffic type from settings.
1096
+ * Returns the default client instance of the SDK, associated with the key provided on settings.
1006
1097
  * @function client
1007
1098
  * @returns {IClient} The client instance.
1008
1099
  */
1009
1100
  client(): IClient,
1010
1101
  /**
1011
- * Returns a shared client of the SDK, associated with the given key and optional traffic type.
1102
+ * Returns a shared client of the SDK, associated with the given key.
1012
1103
  * @function client
1013
1104
  * @param {SplitKey} key The key for the new client instance.
1014
1105
  * @returns {IClient} The client instance.
@@ -1029,11 +1120,18 @@ declare namespace SplitIO {
1029
1120
  */
1030
1121
  interface IAsyncSDK extends IBasicSDK {
1031
1122
  /**
1032
- * Returns the default client instance of the SDK.
1123
+ * Returns the default client instance of the SDK, associated with the key provided on settings.
1033
1124
  * @function client
1034
1125
  * @returns {IAsyncClient} The asynchronous client instance.
1035
1126
  */
1036
1127
  client(): IAsyncClient,
1128
+ /**
1129
+ * Returns a shared client of the SDK, associated with the given key.
1130
+ * @function client
1131
+ * @param {SplitKey} key The key for the new client instance.
1132
+ * @returns {IAsyncClient} The asynchronous client instance.
1133
+ */
1134
+ client(key: SplitKey): IAsyncClient,
1037
1135
  /**
1038
1136
  * Returns a manager instance of the SDK to explore available information.
1039
1137
  * @function manager
@@ -1207,7 +1305,7 @@ declare namespace SplitIO {
1207
1305
  /**
1208
1306
  * Add an attribute to client's in memory attributes storage.
1209
1307
  *
1210
- * @param {string} attributeName Attrinute name
1308
+ * @param {string} attributeName Attribute name
1211
1309
  * @param {AttributeType} attributeValue Attribute value
1212
1310
  * @returns {boolean} true if the attribute was stored and false otherwise
1213
1311
  */
@@ -1297,7 +1395,7 @@ declare namespace SplitIO {
1297
1395
  /**
1298
1396
  * Add an attribute to client's in memory attributes storage.
1299
1397
  *
1300
- * @param {string} attributeName Attrinute name
1398
+ * @param {string} attributeName Attribute name
1301
1399
  * @param {AttributeType} attributeValue Attribute value
1302
1400
  * @returns {boolean} true if the attribute was stored and false otherwise
1303
1401
  */