@splitsoftware/splitio 10.17.3-rc.3 → 10.17.4-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.
@@ -12,6 +12,7 @@ import { __InLocalStorageMockFactory } from '@splitsoftware/splitio-commons/esm/
12
12
  import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory';
13
13
  import { LOCALHOST_MODE, STORAGE_LOCALSTORAGE } from '@splitsoftware/splitio-commons/esm/utils/constants';
14
14
  import { shouldAddPt } from '@splitsoftware/splitio-commons/esm/trackers/impressionObserver/utils';
15
+ import { userConsentProps } from '@splitsoftware/splitio-commons/esm/sdkFactory/userConsentProps';
15
16
  import { settingsFactory } from '../settings/browser';
16
17
  import { platform, SignalListener } from '../platform';
17
18
  var syncManagerOnlineCSFactory = syncManagerOnlineFactory(pollingManagerCSFactory, pushManagerFactory);
@@ -36,9 +37,9 @@ function getModules(settings) {
36
37
  sdkManagerFactory: sdkManagerFactory,
37
38
  sdkClientMethodFactory: sdkClientMethodCSFactory,
38
39
  SignalListener: SignalListener,
39
- impressionListener: settings.impressionListener,
40
40
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? integrationsManagerFactory.bind(null, settings.integrations) : undefined,
41
41
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
42
+ extraProps: userConsentProps
42
43
  };
43
44
  switch (settings.mode) {
44
45
  case LOCALHOST_MODE:
@@ -32,7 +32,6 @@ function getModules(settings) {
32
32
  sdkManagerFactory: sdkManagerFactory,
33
33
  sdkClientMethodFactory: sdkClientMethodFactory,
34
34
  SignalListener: SignalListener,
35
- impressionListener: settings.impressionListener,
36
35
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverSSFactory : undefined,
37
36
  };
38
37
  switch (settings.mode) {
@@ -1,10 +1,11 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
2
2
  import { defaults } from './defaults/browser';
3
- import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime/browser';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime';
4
4
  import { validateStorage } from './storage/browser';
5
5
  import { validateIntegrations } from './integrations/browser';
6
6
  import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
7
7
  import { LocalhostFromObject } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromObject';
8
+ import { validateConsent } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/consent';
8
9
  var params = {
9
10
  defaults: defaults,
10
11
  runtime: validateRuntime,
@@ -12,6 +13,7 @@ var params = {
12
13
  integrations: validateIntegrations,
13
14
  logger: validateLogger,
14
15
  localhost: function () { return LocalhostFromObject(); },
16
+ consent: validateConsent,
15
17
  };
16
18
  export function settingsFactory(config) {
17
19
  return settingsValidation(config, params);
@@ -1,4 +1,5 @@
1
1
  import { packageVersion } from './version';
2
+ import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/esm/utils/constants';
2
3
  export var defaults = {
3
4
  startup: {
4
5
  // Stress the request time used while starting up the SDK.
@@ -10,6 +11,8 @@ export var defaults = {
10
11
  // Amount of time we will wait before the first push of events.
11
12
  eventsFirstPushWindow: 10
12
13
  },
14
+ // Consent is considered granted by default
15
+ userConsent: CONSENT_GRANTED,
13
16
  // Instance version.
14
17
  version: "javascript-" + packageVersion,
15
18
  };
@@ -1 +1 @@
1
- export var packageVersion = '10.17.3-rc.3';
1
+ export var packageVersion = '10.17.4-rc.0';
@@ -1,6 +1,6 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
2
2
  import { defaults } from './defaults/node';
3
- import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime/node';
3
+ import { validateRuntime } from './runtime/node';
4
4
  import { validateStorage } from './storage/node';
5
5
  import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
6
6
  import { LocalhostFromFile } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromFile';
@@ -10,7 +10,8 @@ var params = {
10
10
  storage: validateStorage,
11
11
  logger: validateLogger,
12
12
  localhost: function () { return LocalhostFromFile(); },
13
- // For now, Node SDK ignores settings.integrations, so no integration validator is passed
13
+ consent: function () { return undefined; }, // resets settings.userConsent to the default
14
+ // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
14
15
  };
15
16
  export function settingsFactory(config) {
16
17
  return settingsValidation(config, params);
@@ -0,0 +1,17 @@
1
+ import osFunction from 'os';
2
+ import ipFunction from 'ip';
3
+ import { UNKNOWN, NA, CONSUMER_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
4
+ export function validateRuntime(settings) {
5
+ var isIPAddressesEnabled = settings.core.IPAddressesEnabled === true;
6
+ var isConsumerMode = settings.mode === CONSUMER_MODE;
7
+ // If the values are not available, default to false (for standalone) or "unknown" (for consumer mode, to be used on Redis keys)
8
+ var ip = ipFunction.address() || (isConsumerMode ? UNKNOWN : false);
9
+ var hostname = osFunction.hostname() || (isConsumerMode ? UNKNOWN : false);
10
+ if (!isIPAddressesEnabled) { // If IPAddresses setting is not enabled, set as false (for standalone) or "NA" (for consumer mode, to be used on Redis keys)
11
+ ip = hostname = isConsumerMode ? NA : false;
12
+ }
13
+ return {
14
+ ip: ip,
15
+ hostname: hostname
16
+ };
17
+ }
@@ -4,12 +4,6 @@ var STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
4
4
  export function validateStorage(settings) {
5
5
  var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
6
6
  var __originalType;
7
- if (prefix) {
8
- prefix += '.SPLITIO';
9
- }
10
- else {
11
- prefix = 'SPLITIO';
12
- }
13
7
  var fallbackToMemory = function () {
14
8
  __originalType = type;
15
9
  type = STORAGE_MEMORY;
@@ -1,12 +1,6 @@
1
1
  import { LOCALHOST_MODE, STORAGE_MEMORY, STORAGE_REDIS, CONSUMER_MODE, STANDALONE_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
2
2
  export function validateStorage(settings) {
3
3
  var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
4
- if (prefix) {
5
- prefix += '.SPLITIO';
6
- }
7
- else {
8
- prefix = 'SPLITIO';
9
- }
10
4
  // We can have MEMORY, REDIS or an invalid storage type
11
5
  switch (type) {
12
6
  case STORAGE_REDIS: {
@@ -15,6 +15,7 @@ var storageCS_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsVali
15
15
  var sdkFactory_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory");
16
16
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
17
17
  var utils_1 = require("@splitsoftware/splitio-commons/cjs/trackers/impressionObserver/utils");
18
+ var userConsentProps_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory/userConsentProps");
18
19
  var browser_2 = require("../settings/browser");
19
20
  var platform_1 = require("../platform");
20
21
  var syncManagerOnlineCSFactory = (0, syncManagerOnline_1.syncManagerOnlineFactory)(pollingManagerCS_1.pollingManagerCSFactory, pushManager_1.pushManagerFactory);
@@ -39,9 +40,9 @@ function getModules(settings) {
39
40
  sdkManagerFactory: sdkManager_1.sdkManagerFactory,
40
41
  sdkClientMethodFactory: sdkClientMethodCSWithTT_1.sdkClientMethodCSFactory,
41
42
  SignalListener: platform_1.SignalListener,
42
- impressionListener: settings.impressionListener,
43
43
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? browser_1.integrationsManagerFactory.bind(null, settings.integrations) : undefined,
44
44
  impressionsObserverFactory: (0, utils_1.shouldAddPt)(settings) ? impressionObserverCS_1.impressionObserverCSFactory : undefined,
45
+ extraProps: userConsentProps_1.userConsentProps
45
46
  };
46
47
  switch (settings.mode) {
47
48
  case constants_1.LOCALHOST_MODE:
@@ -35,7 +35,6 @@ function getModules(settings) {
35
35
  sdkManagerFactory: sdkManager_1.sdkManagerFactory,
36
36
  sdkClientMethodFactory: sdkClientMethod_1.sdkClientMethodFactory,
37
37
  SignalListener: platform_1.SignalListener,
38
- impressionListener: settings.impressionListener,
39
38
  impressionsObserverFactory: (0, utils_1.shouldAddPt)(settings) ? impressionObserverSS_1.impressionObserverSSFactory : undefined,
40
39
  };
41
40
  switch (settings.mode) {
@@ -3,18 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.settingsFactory = void 0;
4
4
  var settingsValidation_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
5
5
  var browser_1 = require("./defaults/browser");
6
- var browser_2 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime/browser");
7
- var browser_3 = require("./storage/browser");
8
- var browser_4 = require("./integrations/browser");
6
+ var runtime_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime");
7
+ var browser_2 = require("./storage/browser");
8
+ var browser_3 = require("./integrations/browser");
9
9
  var builtinLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
10
10
  var LocalhostFromObject_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromObject");
11
+ var consent_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/consent");
11
12
  var params = {
12
13
  defaults: browser_1.defaults,
13
- runtime: browser_2.validateRuntime,
14
- storage: browser_3.validateStorage,
15
- integrations: browser_4.validateIntegrations,
14
+ runtime: runtime_1.validateRuntime,
15
+ storage: browser_2.validateStorage,
16
+ integrations: browser_3.validateIntegrations,
16
17
  logger: builtinLogger_1.validateLogger,
17
18
  localhost: function () { return (0, LocalhostFromObject_1.LocalhostFromObject)(); },
19
+ consent: consent_1.validateConsent,
18
20
  };
19
21
  function settingsFactory(config) {
20
22
  return (0, settingsValidation_1.settingsValidation)(config, params);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaults = void 0;
4
4
  var version_1 = require("./version");
5
+ var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
5
6
  exports.defaults = {
6
7
  startup: {
7
8
  // Stress the request time used while starting up the SDK.
@@ -13,6 +14,8 @@ exports.defaults = {
13
14
  // Amount of time we will wait before the first push of events.
14
15
  eventsFirstPushWindow: 10
15
16
  },
17
+ // Consent is considered granted by default
18
+ userConsent: constants_1.CONSENT_GRANTED,
16
19
  // Instance version.
17
20
  version: "javascript-" + version_1.packageVersion,
18
21
  };
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.packageVersion = void 0;
4
- exports.packageVersion = '10.17.3-rc.3';
4
+ exports.packageVersion = '10.17.4-rc.0';
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.settingsFactory = void 0;
4
4
  var settingsValidation_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation");
5
5
  var node_1 = require("./defaults/node");
6
- var node_2 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime/node");
6
+ var node_2 = require("./runtime/node");
7
7
  var node_3 = require("./storage/node");
8
8
  var builtinLogger_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/logger/builtinLogger");
9
9
  var LocalhostFromFile_1 = require("@splitsoftware/splitio-commons/cjs/sync/offline/LocalhostFromFile");
@@ -13,7 +13,8 @@ var params = {
13
13
  storage: node_3.validateStorage,
14
14
  logger: builtinLogger_1.validateLogger,
15
15
  localhost: function () { return (0, LocalhostFromFile_1.LocalhostFromFile)(); },
16
- // For now, Node SDK ignores settings.integrations, so no integration validator is passed
16
+ consent: function () { return undefined; }, // resets settings.userConsent to the default
17
+ // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
17
18
  };
18
19
  function settingsFactory(config) {
19
20
  return (0, settingsValidation_1.settingsValidation)(config, params);
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateRuntime = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var os_1 = (0, tslib_1.__importDefault)(require("os"));
6
+ var ip_1 = (0, tslib_1.__importDefault)(require("ip"));
7
+ var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
8
+ function validateRuntime(settings) {
9
+ var isIPAddressesEnabled = settings.core.IPAddressesEnabled === true;
10
+ var isConsumerMode = settings.mode === constants_1.CONSUMER_MODE;
11
+ // If the values are not available, default to false (for standalone) or "unknown" (for consumer mode, to be used on Redis keys)
12
+ var ip = ip_1.default.address() || (isConsumerMode ? constants_1.UNKNOWN : false);
13
+ var hostname = os_1.default.hostname() || (isConsumerMode ? constants_1.UNKNOWN : false);
14
+ if (!isIPAddressesEnabled) { // If IPAddresses setting is not enabled, set as false (for standalone) or "NA" (for consumer mode, to be used on Redis keys)
15
+ ip = hostname = isConsumerMode ? constants_1.NA : false;
16
+ }
17
+ return {
18
+ ip: ip,
19
+ hostname: hostname
20
+ };
21
+ }
22
+ exports.validateRuntime = validateRuntime;
@@ -7,12 +7,6 @@ var STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
7
7
  function validateStorage(settings) {
8
8
  var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: constants_1.STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
9
9
  var __originalType;
10
- if (prefix) {
11
- prefix += '.SPLITIO';
12
- }
13
- else {
14
- prefix = 'SPLITIO';
15
- }
16
10
  var fallbackToMemory = function () {
17
11
  __originalType = type;
18
12
  type = constants_1.STORAGE_MEMORY;
@@ -4,12 +4,6 @@ exports.validateStorage = void 0;
4
4
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
5
5
  function validateStorage(settings) {
6
6
  var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: constants_1.STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
7
- if (prefix) {
8
- prefix += '.SPLITIO';
9
- }
10
- else {
11
- prefix = 'SPLITIO';
12
- }
13
7
  // We can have MEMORY, REDIS or an invalid storage type
14
8
  switch (type) {
15
9
  case constants_1.STORAGE_REDIS: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.17.3-rc.3",
3
+ "version": "10.17.4-rc.0",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -10,9 +10,7 @@
10
10
  "lib",
11
11
  "types",
12
12
  "es",
13
- "src",
14
- "client",
15
- "server"
13
+ "src"
16
14
  ],
17
15
  "repository": "splitio/javascript-client",
18
16
  "homepage": "https://github.com/splitio/javascript-client#readme",
@@ -34,7 +32,7 @@
34
32
  "node": ">=6"
35
33
  },
36
34
  "dependencies": {
37
- "@splitsoftware/splitio-commons": "1.2.1-rc.2",
35
+ "@splitsoftware/splitio-commons": "1.2.1-rc.8",
38
36
  "@types/google.analytics": "0.0.40",
39
37
  "ioredis": "^4.28.0",
40
38
  "ip": "1.1.5",
@@ -47,7 +45,6 @@
47
45
  },
48
46
  "devDependencies": {
49
47
  "@types/ioredis": "^4.28.0",
50
- "@types/ip": "^1.1.0",
51
48
  "@types/node-fetch": "^2.5.12",
52
49
  "copyfiles": "^2.4.1",
53
50
  "cross-env": "^7.0.3",
@@ -107,7 +104,7 @@
107
104
  "test-node-destroy": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/destroy/node.spec.js | tap-min",
108
105
  "test-node-errors": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/errorCatching/node.spec.js | tap-min",
109
106
  "test-node-offline": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/offline/node.spec.js | tap-min",
110
- "test-node-redis": "cross-env NODE_ENV=test tape -r ./ts-node.register \"src/__tests__/node_redis.spec.js\" | tap-min",
107
+ "test-node-redis": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/node_redis.spec.js | tap-min",
111
108
  "test-node-push": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/push/node.spec.js | tap-min",
112
109
  "pretest-ts-decls": "npm run build-esm && npm run build-cjs && npm link",
113
110
  "test-ts-decls": "./scripts/ts-tests.sh",
@@ -12,6 +12,7 @@ import { __InLocalStorageMockFactory } from '@splitsoftware/splitio-commons/src/
12
12
  import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory';
13
13
  import { LOCALHOST_MODE, STORAGE_LOCALSTORAGE } from '@splitsoftware/splitio-commons/src/utils/constants';
14
14
  import { shouldAddPt } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/utils';
15
+ import { userConsentProps } from '@splitsoftware/splitio-commons/src/sdkFactory/userConsentProps';
15
16
 
16
17
  import { settingsFactory } from '../settings/browser';
17
18
  import { platform, SignalListener } from '../platform';
@@ -49,11 +50,11 @@ function getModules(settings) {
49
50
 
50
51
  SignalListener,
51
52
 
52
- impressionListener: settings.impressionListener,
53
-
54
53
  integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? integrationsManagerFactory.bind(null, settings.integrations) : undefined,
55
54
 
56
55
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
56
+
57
+ extraProps: userConsentProps
57
58
  };
58
59
 
59
60
  switch (settings.mode) {
@@ -45,8 +45,6 @@ function getModules(settings) {
45
45
 
46
46
  SignalListener,
47
47
 
48
- impressionListener: settings.impressionListener,
49
-
50
48
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverSSFactory : undefined,
51
49
  };
52
50
 
@@ -1,10 +1,11 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation';
2
2
  import { defaults } from './defaults/browser';
3
- import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime/browser';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime';
4
4
  import { validateStorage } from './storage/browser';
5
5
  import { validateIntegrations } from './integrations/browser';
6
6
  import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/builtinLogger';
7
7
  import { LocalhostFromObject } from '@splitsoftware/splitio-commons/src/sync/offline/LocalhostFromObject';
8
+ import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/consent';
8
9
 
9
10
  const params = {
10
11
  defaults,
@@ -13,6 +14,7 @@ const params = {
13
14
  integrations: validateIntegrations,
14
15
  logger: validateLogger,
15
16
  localhost: () => LocalhostFromObject(),
17
+ consent: validateConsent,
16
18
  };
17
19
 
18
20
  export function settingsFactory(config) {
@@ -1,4 +1,5 @@
1
1
  import { packageVersion } from './version';
2
+ import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants';
2
3
 
3
4
  export const defaults = {
4
5
  startup: {
@@ -12,6 +13,9 @@ export const defaults = {
12
13
  eventsFirstPushWindow: 10
13
14
  },
14
15
 
16
+ // Consent is considered granted by default
17
+ userConsent: CONSENT_GRANTED,
18
+
15
19
  // Instance version.
16
20
  version: `javascript-${packageVersion}`,
17
21
  };
@@ -1 +1 @@
1
- export const packageVersion = '10.17.3-rc.3';
1
+ export const packageVersion = '10.17.4-rc.0';
@@ -1,6 +1,6 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/src/utils/settingsValidation';
2
2
  import { defaults } from './defaults/node';
3
- import { validateRuntime } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/runtime/node';
3
+ import { validateRuntime } from './runtime/node';
4
4
  import { validateStorage } from './storage/node';
5
5
  import { validateLogger } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/logger/builtinLogger';
6
6
  import { LocalhostFromFile } from '@splitsoftware/splitio-commons/src/sync/offline/LocalhostFromFile';
@@ -11,7 +11,8 @@ const params = {
11
11
  storage: validateStorage,
12
12
  logger: validateLogger,
13
13
  localhost: () => LocalhostFromFile(),
14
- // For now, Node SDK ignores settings.integrations, so no integration validator is passed
14
+ consent: () => undefined, // resets settings.userConsent to the default
15
+ // In Node.js the SDK ignores `config.integrations`, so a validator for integrations is not required
15
16
  };
16
17
 
17
18
  export function settingsFactory(config) {
@@ -0,0 +1,21 @@
1
+ import osFunction from 'os';
2
+ import ipFunction from 'ip';
3
+
4
+ import { UNKNOWN, NA, CONSUMER_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
5
+
6
+ export function validateRuntime(settings) {
7
+ const isIPAddressesEnabled = settings.core.IPAddressesEnabled === true;
8
+ const isConsumerMode = settings.mode === CONSUMER_MODE;
9
+
10
+ // If the values are not available, default to false (for standalone) or "unknown" (for consumer mode, to be used on Redis keys)
11
+ let ip = ipFunction.address() || (isConsumerMode ? UNKNOWN : false);
12
+ let hostname = osFunction.hostname() || (isConsumerMode ? UNKNOWN : false);
13
+
14
+ if (!isIPAddressesEnabled) { // If IPAddresses setting is not enabled, set as false (for standalone) or "NA" (for consumer mode, to be used on Redis keys)
15
+ ip = hostname = isConsumerMode ? NA : false;
16
+ }
17
+
18
+ return {
19
+ ip, hostname
20
+ };
21
+ }
@@ -15,12 +15,6 @@ export function validateStorage(settings) {
15
15
  } = settings;
16
16
  let __originalType;
17
17
 
18
- if (prefix) {
19
- prefix += '.SPLITIO';
20
- } else {
21
- prefix = 'SPLITIO';
22
- }
23
-
24
18
  const fallbackToMemory = () => {
25
19
  __originalType = type;
26
20
  type = STORAGE_MEMORY;
@@ -11,12 +11,6 @@ export function validateStorage(settings) {
11
11
  } = { type: STORAGE_MEMORY }
12
12
  } = settings;
13
13
 
14
- if (prefix) {
15
- prefix += '.SPLITIO';
16
- } else {
17
- prefix = 'SPLITIO';
18
- }
19
-
20
14
  // We can have MEMORY, REDIS or an invalid storage type
21
15
  switch (type) {
22
16
  case STORAGE_REDIS: {
@@ -69,6 +69,7 @@ interface ISettings {
69
69
  readonly scheduler: {
70
70
  featuresRefreshRate: number,
71
71
  impressionsRefreshRate: number,
72
+ impressionsQueueSize: number,
72
73
  metricsRefreshRate: number,
73
74
  segmentsRefreshRate: number,
74
75
  offlineRefreshRate: number,
@@ -104,6 +105,10 @@ interface ISettings {
104
105
  splitFilters: SplitIO.SplitFilter[],
105
106
  impressionsMode: SplitIO.ImpressionsMode,
106
107
  }
108
+ /**
109
+ * User consent status if using in browser. Undefined if using in Node.
110
+ */
111
+ readonly userConsent?: SplitIO.ConsentStatus
107
112
  }
108
113
  /**
109
114
  * Log levels.
@@ -249,6 +254,13 @@ interface INodeBasicSettings extends ISharedSettings {
249
254
  * @default 300
250
255
  */
251
256
  impressionsRefreshRate?: number,
257
+ /**
258
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
259
+ * If you use a 0 here, the queue will have no maximum size.
260
+ * @property {number} impressionsQueueSize
261
+ * @default 30000
262
+ */
263
+ impressionsQueueSize?: number,
252
264
  /**
253
265
  * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
254
266
  * @property {number} metricsRefreshRate
@@ -831,6 +843,11 @@ declare namespace SplitIO {
831
843
  * @typedef {string} ImpressionsMode
832
844
  */
833
845
  type ImpressionsMode = 'OPTIMIZED' | 'DEBUG';
846
+ /**
847
+ * User consent status.
848
+ * @typedef {string} ConsentStatus
849
+ */
850
+ type ConsentStatus = 'GRANTED' | 'DECLINED' | 'UNKNOWN';
834
851
  /**
835
852
  * Settings interface for SDK instances created on the browser
836
853
  * @interface IBrowserSettings
@@ -887,6 +904,13 @@ declare namespace SplitIO {
887
904
  * @default 60
888
905
  */
889
906
  impressionsRefreshRate?: number,
907
+ /**
908
+ * The maximum number of impression items we want to queue. If we queue more values, it will trigger a flush and reset the timer.
909
+ * If you use a 0 here, the queue will have no maximum size.
910
+ * @property {number} impressionsQueueSize
911
+ * @default 30000
912
+ */
913
+ impressionsQueueSize?: number,
890
914
  /**
891
915
  * The SDK sends diagnostic metrics to Split servers. This parameters controls this metric flush period in seconds.
892
916
  * @property {number} metricsRefreshRate
@@ -989,6 +1013,17 @@ declare namespace SplitIO {
989
1013
  * @property {Object} integrations
990
1014
  */
991
1015
  integrations?: BrowserIntegration[],
1016
+ /**
1017
+ * User consent status. Possible values are `'GRANTED'`, which is the default, `'DECLINED'` or `'UNKNOWN'`.
1018
+ * - `'GRANTED'`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
1019
+ * - `'DECLINED'`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
1020
+ * - `'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
1021
+ * 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.
1022
+ *
1023
+ * @typedef {string} userConsent
1024
+ * @default 'GRANTED'
1025
+ */
1026
+ userConsent?: ConsentStatus
992
1027
  }
993
1028
  /**
994
1029
  * Settings interface for SDK instances created on NodeJS.
@@ -1113,6 +1148,25 @@ declare namespace SplitIO {
1113
1148
  * @returns {IBrowserClient} The client instance.
1114
1149
  */
1115
1150
  client(key: SplitKey, trafficType?: string): IBrowserClient
1151
+ /**
1152
+ * Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
1153
+ * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
1154
+ * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
1155
+ *
1156
+ * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
1157
+ *
1158
+ * @function setUserConsent
1159
+ * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
1160
+ * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
1161
+ */
1162
+ setUserConsent(userConsent: boolean): boolean;
1163
+ /**
1164
+ * Get the user consent status.
1165
+ *
1166
+ * @function getUserConsent
1167
+ * @returns {ConsentStatus} The user consent status.
1168
+ */
1169
+ getUserConsent(): ConsentStatus;
1116
1170
  }
1117
1171
  /**
1118
1172
  * This represents the interface for the SDK instance with asynchronous storage.
@@ -1262,7 +1316,7 @@ declare namespace SplitIO {
1262
1316
  /**
1263
1317
  * Add an attribute to client's in memory attributes storage.
1264
1318
  *
1265
- * @param {string} attributeName Attrinute name
1319
+ * @param {string} attributeName Attribute name
1266
1320
  * @param {AttributeType} attributeValue Attribute value
1267
1321
  * @returns {boolean} true if the attribute was stored and false otherwise
1268
1322
  */
@@ -1,5 +0,0 @@
1
- {
2
- "main": "../lib/factory/browser.js",
3
- "module": "../es/factory/browser.js",
4
- "types": "../types/client/index.d.ts"
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "main": "../lib/factory/node.js",
3
- "module": "../es/factory/node.js",
4
- "types": "../types/server/index.d.ts"
5
- }
@@ -1,14 +0,0 @@
1
- // Declaration file for Javascript Split Software SDK
2
- // Project: http://www.split.io/
3
-
4
- /// <reference path="../splitio.d.ts" />
5
- export = JsSdk;
6
-
7
- declare module JsSdk {
8
- /**
9
- * Split.io sdk factory function.
10
- * The settings parameter should be an object that complies with the SplitIO.IBrowserSettings.
11
- * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
12
- */
13
- export function SplitFactory(settings: SplitIO.IBrowserSettings): SplitIO.IBrowserSDK;
14
- }
@@ -1,20 +0,0 @@
1
- // Declaration file for Javascript Split Software SDK
2
- // Project: http://www.split.io/
3
-
4
- /// <reference path="../splitio.d.ts" />
5
- export = JsSdk;
6
-
7
- declare module JsSdk {
8
- /**
9
- * Split.io sdk factory function.
10
- * The settings parameter should be an object that complies with the SplitIO.INodeAsyncSettings.
11
- * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
12
- */
13
- export function SplitFactory(settings: SplitIO.INodeAsyncSettings): SplitIO.IAsyncSDK;
14
- /**
15
- * Split.io sdk factory function.
16
- * The settings parameter should be an object that complies with the SplitIO.INodeSettings.
17
- * For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
18
- */
19
- export function SplitFactory(settings: SplitIO.INodeSettings): SplitIO.ISDK;
20
- }