@splitsoftware/splitio 10.17.4-rc.2 → 10.18.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,14 +1,19 @@
1
- 10.18.0 (March XXX, 2022)
2
- - Updated internal dependencies to use @splitsoftware/splitio-commons dependency, which includes:
3
- - Added support for user consent in client-side
4
- - Added impressionsQueueSize config parameter
5
- - Update SplitToGa integration ...
6
- - Update modules to simplify the usage with bundling tools ...
7
- - Updated dependencies for vulnerability fixes
8
- - Bugfixing - Logger settings is configurable per factory instance instead of globally.
9
- - Bugfixing - Wrongly logging warning 'No listeners for SDK Readiness detected' in consumer mode.
10
- - Added TLS support for Redis
11
- -
1
+ 10.18.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
+ - Added support to accept TLS configuration options to the Redis storage in NodeJS. Read more in our docs.
5
+ - Updated type definitions to specialize the type of the `storage.options` object for Redis storage in NodeJS.
6
+ - Updated some dependencies for vulnerability fixes.
7
+ - Bugfixing - Updated internal isObject utility function, to avoid unexpected behaviors on frameworks and libraries that uses multiple VM contexts, like NuxtJS dev server.
8
+ - Bugfixing - Logging settings (i.e., the `debug` SDK configuration param and factory logger methods) are configurable per factory instance, instead of affecting all factories globally.
9
+ - Bugfixing - Fixed an issue with `connectionTimeout` options params of Redis storage, that was being ignored and not passed down to the underlying ioredis client.
10
+ - Bugfixing - Updated the validation of some SDK configuration params to log errors and throw exceptions with clear descriptions of the invalid setup:
11
+ - If passing a non-string value to `sync.impressionsMode`, the SDK logs the error: "you passed an invalid impressionsMode config param. It should be one of the following values: 'OPTIMIZED', 'DEBUG'. Defaulting to 'OPTIMIZED'.".
12
+ - If passing 'REDIS' storage type without setting `mode` to 'consumer', the SDK logs the error: "The provided REDIS storage is invalid for this mode. It requires 'consumer' mode. Fallbacking into default MEMORY storage.".
13
+ - If passing 'consumer' mode without setting `storage.type` to 'REDIS', the SDK throws an exception with message: "A REDIS storage is required on consumer mode.".
14
+
15
+ - NOTABLE CHANGE: since version 10.18.0, the SDK has been refactored to use @splitsoftware/splitio-commons package in order to reuse core modules shared across all JavaScript-based SDKs. Most internal modules have been moved and renamed,
16
+ but it does not imply a breaking change as long as the library is imported via its main entrypoint (e.g., `const { SplitFactory } = require('@splitsoftware/splitio')` or `import { SplitFactory } from '@splitsoftware/splitio'`).
12
17
 
13
18
  10.17.3 (February 25, 2022)
14
19
  - Updated format for MySegments keys in LocalStorage, keeping backwards compatibility (issue https://github.com/splitio/javascript-client/issues/638).
@@ -12,7 +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
+ import { createUserConsentAPI } from '@splitsoftware/splitio-commons/esm/consent/sdkUserConsent';
16
16
  import { settingsFactory } from '../settings/browser';
17
17
  import { platform, SignalListener } from '../platform';
18
18
  var syncManagerOnlineCSFactory = syncManagerOnlineFactory(pollingManagerCSFactory, pushManagerFactory);
@@ -39,7 +39,11 @@ function getModules(settings) {
39
39
  SignalListener: SignalListener,
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
+ extraProps: function (params) {
43
+ return {
44
+ UserConsent: createUserConsentAPI(params)
45
+ };
46
+ }
43
47
  };
44
48
  switch (settings.mode) {
45
49
  case LOCALHOST_MODE:
@@ -8,7 +8,7 @@ import { LocalhostFromObject } from '@splitsoftware/splitio-commons/esm/sync/off
8
8
  import { validateConsent } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/consent';
9
9
  var params = {
10
10
  defaults: defaults,
11
- isClientSide: true,
11
+ acceptKey: true, acceptTT: true,
12
12
  runtime: validateRuntime,
13
13
  storage: validateStorage,
14
14
  integrations: validateIntegrations,
@@ -1 +1 @@
1
- export var packageVersion = '10.17.4-rc.2';
1
+ export var packageVersion = '10.18.0';
@@ -15,7 +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
+ var sdkUserConsent_1 = require("@splitsoftware/splitio-commons/cjs/consent/sdkUserConsent");
19
19
  var browser_2 = require("../settings/browser");
20
20
  var platform_1 = require("../platform");
21
21
  var syncManagerOnlineCSFactory = (0, syncManagerOnline_1.syncManagerOnlineFactory)(pollingManagerCS_1.pollingManagerCSFactory, pushManager_1.pushManagerFactory);
@@ -42,7 +42,11 @@ function getModules(settings) {
42
42
  SignalListener: platform_1.SignalListener,
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
+ extraProps: function (params) {
46
+ return {
47
+ UserConsent: (0, sdkUserConsent_1.createUserConsentAPI)(params)
48
+ };
49
+ }
46
50
  };
47
51
  switch (settings.mode) {
48
52
  case constants_1.LOCALHOST_MODE:
@@ -11,7 +11,7 @@ var LocalhostFromObject_1 = require("@splitsoftware/splitio-commons/cjs/sync/off
11
11
  var consent_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/consent");
12
12
  var params = {
13
13
  defaults: browser_1.defaults,
14
- isClientSide: true,
14
+ acceptKey: true, acceptTT: true,
15
15
  runtime: runtime_1.validateRuntime,
16
16
  storage: browser_2.validateStorage,
17
17
  integrations: browser_3.validateIntegrations,
@@ -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.4-rc.2';
4
+ exports.packageVersion = '10.18.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.17.4-rc.2",
3
+ "version": "10.18.0",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -32,7 +32,7 @@
32
32
  "node": ">=6"
33
33
  },
34
34
  "dependencies": {
35
- "@splitsoftware/splitio-commons": "1.2.1-rc.9",
35
+ "@splitsoftware/splitio-commons": "1.3.0",
36
36
  "@types/google.analytics": "0.0.40",
37
37
  "@types/ioredis": "^4.28.0",
38
38
  "ioredis": "^4.28.0",
@@ -12,7 +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
+ import { createUserConsentAPI } from '@splitsoftware/splitio-commons/src/consent/sdkUserConsent';
16
16
 
17
17
  import { settingsFactory } from '../settings/browser';
18
18
  import { platform, SignalListener } from '../platform';
@@ -54,7 +54,11 @@ function getModules(settings) {
54
54
 
55
55
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
56
56
 
57
- extraProps: userConsentProps
57
+ extraProps: (params) => {
58
+ return {
59
+ UserConsent: createUserConsentAPI(params)
60
+ };
61
+ }
58
62
  };
59
63
 
60
64
  switch (settings.mode) {
@@ -9,7 +9,7 @@ import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settin
9
9
 
10
10
  const params = {
11
11
  defaults,
12
- isClientSide: true,
12
+ acceptKey: true, acceptTT: true, // Client with bound key and optional TT
13
13
  runtime: validateRuntime,
14
14
  storage: validateStorage,
15
15
  integrations: validateIntegrations,
@@ -1 +1 @@
1
- export const packageVersion = '10.17.4-rc.2';
1
+ export const packageVersion = '10.18.0';
@@ -1,4 +1,4 @@
1
- // Type definitions for Javascript and Node Split Software SDK
1
+ // Type definitions for Javascript and NodeJS Split Software SDK
2
2
  // Project: http://www.split.io/
3
3
  // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
4
4
 
@@ -98,7 +98,7 @@ interface ISettings {
98
98
  readonly debug: boolean | LogLevel,
99
99
  readonly version: string,
100
100
  /**
101
- * Mocked features map if using in browser, or mocked features file path string if using in Node.
101
+ * Mocked features map if using in browser, or mocked features file path string if using in NodeJS.
102
102
  */
103
103
  features: SplitIO.MockedFeaturesMap | SplitIO.MockedFeaturesFilePath,
104
104
  readonly streamingEnabled: boolean,
@@ -107,7 +107,7 @@ interface ISettings {
107
107
  impressionsMode: SplitIO.ImpressionsMode,
108
108
  }
109
109
  /**
110
- * User consent status if using in browser. Undefined if using in Node.
110
+ * User consent status if using in browser. Undefined if using in NodeJS.
111
111
  */
112
112
  readonly userConsent?: SplitIO.ConsentStatus
113
113
  }
@@ -143,7 +143,38 @@ interface ILoggerAPI {
143
143
  * Log level constants. Use this to pass them to setLogLevel function.
144
144
  */
145
145
  LogLevel: {
146
- [level: string]: LogLevel
146
+ [level in LogLevel]: LogLevel
147
+ }
148
+ }
149
+ /**
150
+ * User consent API
151
+ * @interface IUserConsentAPI
152
+ */
153
+ interface IUserConsentAPI {
154
+ /**
155
+ * Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
156
+ * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
157
+ * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
158
+ *
159
+ * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
160
+ *
161
+ * @function setStatus
162
+ * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
163
+ * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
164
+ */
165
+ setStatus(userConsent: boolean): boolean;
166
+ /**
167
+ * Get the user consent status.
168
+ *
169
+ * @function getStatus
170
+ * @returns {ConsentStatus} The user consent status.
171
+ */
172
+ getStatus(): SplitIO.ConsentStatus;
173
+ /**
174
+ * Consent status constants. Use this to compare with the getStatus function result.
175
+ */
176
+ Status: {
177
+ [status in SplitIO.ConsentStatus]: SplitIO.ConsentStatus
147
178
  }
148
179
  }
149
180
  /**
@@ -326,7 +357,7 @@ interface INodeBasicSettings extends ISharedSettings {
326
357
  IPAddressesEnabled?: boolean
327
358
  },
328
359
  /**
329
- * Defines which kind of storage we should instanciate.
360
+ * Defines which kind of storage we should instantiate.
330
361
  * @property {Object} storage
331
362
  */
332
363
  storage?: {
@@ -337,10 +368,10 @@ interface INodeBasicSettings extends ISharedSettings {
337
368
  */
338
369
  type?: StorageType,
339
370
  /**
340
- * Options to be passed to the selected storage. Use it with type: 'REDIS'
341
- * @property {SplitIO.RedisStorageOptions} options
371
+ * Options to be passed to the selected storage.
372
+ * @property {Object} options
342
373
  */
343
- options?: SplitIO.RedisStorageOptions,
374
+ options?: Object,
344
375
  /**
345
376
  * Optional prefix to prevent any kind of data collision between SDK versions.
346
377
  * @property {string} prefix
@@ -639,69 +670,6 @@ declare namespace SplitIO {
639
670
  * @typedef {string} BrowserStorage
640
671
  */
641
672
  type BrowserStorage = 'MEMORY' | 'LOCALSTORAGE';
642
- /**
643
- * Options to be passed to the Redis storage. Use it with storage type: 'REDIS'.
644
- * @typedef {Object} RedisStorageOptions
645
- */
646
- type RedisStorageOptions = {
647
- /**
648
- * Redis URL. If set, `host`, `port`, `db` and `pass` params will be ignored.
649
- *
650
- * Examples:
651
- * ```
652
- * url: 'localhost'
653
- * url: '127.0.0.1:6379'
654
- * url: 'redis://:authpassword@127.0.0.1:6379/0'
655
- * ```
656
- * @property {string=} url
657
- */
658
- url?: string,
659
- /**
660
- * Redis host.
661
- * @property {string=} host
662
- * @default 'localhost'
663
- */
664
- host?: string,
665
- /**
666
- * Redis port.
667
- * @property {number=} port
668
- * @default 6379
669
- */
670
- port?: number,
671
- /**
672
- * Redis database to be used.
673
- * @property {number=} db
674
- * @default 0
675
- */
676
- db?: number,
677
- /**
678
- * Redis password. Don't define if no password is used.
679
- * @property {string=} pass
680
- * @default undefined
681
- */
682
- pass?: string,
683
- /**
684
- * The milliseconds before a timeout occurs during the initial connection to the Redis server.
685
- * @property {number=} connectionTimeout
686
- * @default 10000
687
- */
688
- connectionTimeout?: number,
689
- /**
690
- * The milliseconds before Redis commands are timeout by the SDK.
691
- * Method calls that involve Redis commands, like `client.getTreatment` or `client.track` calls, are resolved when the commands success or timeout.
692
- * @property {number=} operationTimeout
693
- * @default 5000
694
- */
695
- operationTimeout?: number,
696
- /**
697
- * TLS configuration for Redis connection.
698
- * @see {@link https://www.npmjs.com/package/ioredis#tls-options }
699
- *
700
- * @property {Object=} tls
701
- * @default undefined
702
- */
703
- tls?: RedisOptions['tls'],
704
- }
705
673
  /**
706
674
  * Impression listener interface. This is the interface that needs to be implemented
707
675
  * by the element you provide to the SDK as impression listener.
@@ -1049,7 +1017,8 @@ declare namespace SplitIO {
1049
1017
  */
1050
1018
  features?: MockedFeaturesMap,
1051
1019
  /**
1052
- * Defines which kind of storage we should instanciate.
1020
+ * Defines which kind of storage we can instantiate on the browser.
1021
+ * Possible storage types are 'MEMORY', which is the default, and 'LOCALSTORAGE'.
1053
1022
  * @property {Object} storage
1054
1023
  */
1055
1024
  storage?: {
@@ -1104,7 +1073,8 @@ declare namespace SplitIO {
1104
1073
  */
1105
1074
  urls?: UrlSettings,
1106
1075
  /**
1107
- * Defines which kind of storage we should instanciate.
1076
+ * Defines which kind of storage we can instantiate on NodeJS for 'standalone' mode.
1077
+ * The only possible storage type is 'MEMORY', which is the default.
1108
1078
  * @property {Object} storage
1109
1079
  */
1110
1080
  storage?: {
@@ -1138,6 +1108,11 @@ declare namespace SplitIO {
1138
1108
  * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1139
1109
  */
1140
1110
  interface INodeAsyncSettings extends INodeBasicSettings {
1111
+ /**
1112
+ * Defines which kind of async storage we can instantiate on NodeJS for 'consumer' mode.
1113
+ * The only possible storage type is 'REDIS'.
1114
+ * @property {Object} storage
1115
+ */
1141
1116
  storage: {
1142
1117
  /**
1143
1118
  * 'REDIS' storage type to be instantiated by the SDK.
@@ -1145,10 +1120,68 @@ declare namespace SplitIO {
1145
1120
  */
1146
1121
  type: NodeAsyncStorage,
1147
1122
  /**
1148
- * Options to be passed to the selected storage. Use it with type: 'REDIS'
1149
- * @property {SplitIO.RedisStorageOptions} options
1123
+ * Options to be passed to the Redis storage. Use it with storage type: 'REDIS'.
1124
+ * @property {Object} options
1150
1125
  */
1151
- options?: RedisStorageOptions,
1126
+ options?: {
1127
+ /**
1128
+ * Redis URL. If set, `host`, `port`, `db` and `pass` params will be ignored.
1129
+ *
1130
+ * Examples:
1131
+ * ```
1132
+ * url: 'localhost'
1133
+ * url: '127.0.0.1:6379'
1134
+ * url: 'redis://:authpassword@127.0.0.1:6379/0'
1135
+ * ```
1136
+ * @property {string=} url
1137
+ */
1138
+ url?: string,
1139
+ /**
1140
+ * Redis host.
1141
+ * @property {string=} host
1142
+ * @default 'localhost'
1143
+ */
1144
+ host?: string,
1145
+ /**
1146
+ * Redis port.
1147
+ * @property {number=} port
1148
+ * @default 6379
1149
+ */
1150
+ port?: number,
1151
+ /**
1152
+ * Redis database to be used.
1153
+ * @property {number=} db
1154
+ * @default 0
1155
+ */
1156
+ db?: number,
1157
+ /**
1158
+ * Redis password. Don't define if no password is used.
1159
+ * @property {string=} pass
1160
+ * @default undefined
1161
+ */
1162
+ pass?: string,
1163
+ /**
1164
+ * The milliseconds before a timeout occurs during the initial connection to the Redis server.
1165
+ * @property {number=} connectionTimeout
1166
+ * @default 10000
1167
+ */
1168
+ connectionTimeout?: number,
1169
+ /**
1170
+ * The milliseconds before Redis commands are timeout by the SDK.
1171
+ * Method calls that involve Redis commands, like `client.getTreatment` or `client.track` calls, are resolved when the commands success or timeout.
1172
+ * @property {number=} operationTimeout
1173
+ * @default 5000
1174
+ */
1175
+ operationTimeout?: number,
1176
+ /**
1177
+ * TLS configuration for Redis connection.
1178
+ * @see {@link https://www.npmjs.com/package/ioredis#tls-options }
1179
+ *
1180
+ * @property {Object=} tls
1181
+ * @default undefined
1182
+ */
1183
+ tls?: RedisOptions['tls'],
1184
+ },
1152
1185
  /**
1153
1186
  * Optional prefix to prevent any kind of data collision between SDK versions.
1154
1187
  * @property {string} prefix
@@ -1213,24 +1246,10 @@ declare namespace SplitIO {
1213
1246
  */
1214
1247
  client(key: SplitKey, trafficType?: string): IBrowserClient
1215
1248
  /**
1216
- * Set or update the user consent status. Possible values are `true` and `false`, which represent user consent `'GRANTED'` and `'DECLINED'` respectively.
1217
- * - `true ('GRANTED')`: the user has granted consent for tracking events and impressions. The SDK will send them to Split cloud.
1218
- * - `false ('DECLINED')`: the user has declined consent for tracking events and impressions. The SDK will not send them to Split cloud.
1219
- *
1220
- * NOTE: calling this method updates the user consent at a factory level, affecting all clients of the same factory.
1221
- *
1222
- * @function setUserConsent
1223
- * @param {boolean} userConsent The user consent status, true for 'GRANTED' and false for 'DECLINED'.
1224
- * @returns {boolean} Whether the provided param is a valid value (i.e., a boolean value) or not.
1225
- */
1226
- setUserConsent(userConsent: boolean): boolean;
1227
- /**
1228
- * Get the user consent status.
1229
- *
1230
- * @function getUserConsent
1231
- * @returns {ConsentStatus} The user consent status.
1249
+ * User consent API.
1250
+ * @property UserConsent
1232
1251
  */
1233
- getUserConsent(): ConsentStatus;
1252
+ UserConsent: IUserConsentAPI
1234
1253
  }
1235
1254
  /**
1236
1255
  * This represents the interface for the SDK instance with asynchronous storage.