@splitsoftware/splitio 10.17.4-rc.1 → 10.17.4-rc.4

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,20 @@
1
+ 10.18.0 (April 4, 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
+ - Bugfixing - Updated internal `isObject` util that was returning false negatives on some environment, like Nuxt dev server or Miniflare.
11
+ - Added TLS support for Redis
12
+ -
13
+
14
+ 10.17.3 (February 25, 2022)
15
+ - Updated format for MySegments keys in LocalStorage, keeping backwards compatibility (issue https://github.com/splitio/javascript-client/issues/638).
16
+ - Updated some dependencies for vulnerability fixes.
17
+
1
18
  10.17.2 (January 31, 2022)
2
19
  - Updated some dependencies for vulnerability fixes.
3
20
  - Bugfixing - Fixed internal handling of Fetch API promise rejection, to avoid unhandled exceptions on some Web browsers (issue https://github.com/splitio/javascript-client/issues/621)
@@ -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,6 +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
+ acceptKey: true, acceptTT: true,
11
12
  runtime: validateRuntime,
12
13
  storage: validateStorage,
13
14
  integrations: validateIntegrations,
@@ -1 +1 @@
1
- export var packageVersion = '10.17.4-rc.1';
1
+ export var packageVersion = '10.17.4-rc.4';
@@ -12,7 +12,7 @@ export function validateStorage(settings) {
12
12
  prefix: prefix
13
13
  };
14
14
  }
15
- var host = options.host, port = options.port, db = options.db, pass = options.pass, url = options.url, connectionTimeout = options.connectionTimeout, operationTimeout = options.operationTimeout;
15
+ var host = options.host, port = options.port, db = options.db, pass = options.pass, url = options.url, tls = options.tls, connectionTimeout = options.connectionTimeout, operationTimeout = options.operationTimeout;
16
16
  if (process.env.REDIS_HOST)
17
17
  host = process.env.REDIS_HOST;
18
18
  if (process.env.REDIS_PORT)
@@ -36,6 +36,9 @@ export function validateStorage(settings) {
36
36
  newOpts.db = db;
37
37
  newOpts.pass = pass;
38
38
  }
39
+ if (tls) {
40
+ newOpts.tls = tls;
41
+ }
39
42
  return {
40
43
  type: type,
41
44
  prefix: prefix,
@@ -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,6 +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
+ acceptKey: true, acceptTT: true,
14
15
  runtime: runtime_1.validateRuntime,
15
16
  storage: browser_2.validateStorage,
16
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.1';
4
+ exports.packageVersion = '10.17.4-rc.4';
@@ -15,7 +15,7 @@ function validateStorage(settings) {
15
15
  prefix: prefix
16
16
  };
17
17
  }
18
- var host = options.host, port = options.port, db = options.db, pass = options.pass, url = options.url, connectionTimeout = options.connectionTimeout, operationTimeout = options.operationTimeout;
18
+ var host = options.host, port = options.port, db = options.db, pass = options.pass, url = options.url, tls = options.tls, connectionTimeout = options.connectionTimeout, operationTimeout = options.operationTimeout;
19
19
  if (process.env.REDIS_HOST)
20
20
  host = process.env.REDIS_HOST;
21
21
  if (process.env.REDIS_PORT)
@@ -39,6 +39,9 @@ function validateStorage(settings) {
39
39
  newOpts.db = db;
40
40
  newOpts.pass = pass;
41
41
  }
42
+ if (tls) {
43
+ newOpts.tls = tls;
44
+ }
42
45
  return {
43
46
  type: type,
44
47
  prefix: prefix,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.17.4-rc.1",
3
+ "version": "10.17.4-rc.4",
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,8 +32,9 @@
34
32
  "node": ">=6"
35
33
  },
36
34
  "dependencies": {
37
- "@splitsoftware/splitio-commons": "1.2.1-rc.8",
35
+ "@splitsoftware/splitio-commons": "1.2.1-rc.12",
38
36
  "@types/google.analytics": "0.0.40",
37
+ "@types/ioredis": "^4.28.0",
39
38
  "ioredis": "^4.28.0",
40
39
  "ip": "1.1.5",
41
40
  "js-yaml": "3.13.1",
@@ -46,7 +45,6 @@
46
45
  "eventsource": "^1.0.7"
47
46
  },
48
47
  "devDependencies": {
49
- "@types/ioredis": "^4.28.0",
50
48
  "@types/node-fetch": "^2.5.12",
51
49
  "copyfiles": "^2.4.1",
52
50
  "cross-env": "^7.0.3",
@@ -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,6 +9,7 @@ import { validateConsent } from '@splitsoftware/splitio-commons/src/utils/settin
9
9
 
10
10
  const params = {
11
11
  defaults,
12
+ acceptKey: true, acceptTT: true, // Client with bound key and optional TT
12
13
  runtime: validateRuntime,
13
14
  storage: validateStorage,
14
15
  integrations: validateIntegrations,
@@ -1 +1 @@
1
- export const packageVersion = '10.17.4-rc.1';
1
+ export const packageVersion = '10.17.4-rc.4';
@@ -28,6 +28,7 @@ export function validateStorage(settings) {
28
28
  db,
29
29
  pass,
30
30
  url,
31
+ tls,
31
32
  connectionTimeout,
32
33
  operationTimeout
33
34
  } = options;
@@ -56,6 +57,10 @@ export function validateStorage(settings) {
56
57
  newOpts.pass = pass;
57
58
  }
58
59
 
60
+ if (tls) {
61
+ newOpts.tls = tls;
62
+ }
63
+
59
64
  return {
60
65
  type,
61
66
  prefix,
@@ -1,8 +1,9 @@
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
 
5
5
  /// <reference types="google.analytics" />
6
+ import { RedisOptions } from "ioredis";
6
7
 
7
8
  export as namespace SplitIO;
8
9
  export = SplitIO;
@@ -97,7 +98,7 @@ interface ISettings {
97
98
  readonly debug: boolean | LogLevel,
98
99
  readonly version: string,
99
100
  /**
100
- * 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.
101
102
  */
102
103
  features: SplitIO.MockedFeaturesMap | SplitIO.MockedFeaturesFilePath,
103
104
  readonly streamingEnabled: boolean,
@@ -106,7 +107,7 @@ interface ISettings {
106
107
  impressionsMode: SplitIO.ImpressionsMode,
107
108
  }
108
109
  /**
109
- * 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.
110
111
  */
111
112
  readonly userConsent?: SplitIO.ConsentStatus
112
113
  }
@@ -142,7 +143,38 @@ interface ILoggerAPI {
142
143
  * Log level constants. Use this to pass them to setLogLevel function.
143
144
  */
144
145
  LogLevel: {
145
- [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
146
178
  }
147
179
  }
148
180
  /**
@@ -325,7 +357,7 @@ interface INodeBasicSettings extends ISharedSettings {
325
357
  IPAddressesEnabled?: boolean
326
358
  },
327
359
  /**
328
- * Defines which kind of storage we should instanciate.
360
+ * Defines which kind of storage we should instantiate.
329
361
  * @property {Object} storage
330
362
  */
331
363
  storage?: {
@@ -336,7 +368,7 @@ interface INodeBasicSettings extends ISharedSettings {
336
368
  */
337
369
  type?: StorageType,
338
370
  /**
339
- * Options to be passed to the selected storage. Use it with type: 'REDIS'
371
+ * Options to be passed to the selected storage.
340
372
  * @property {Object} options
341
373
  */
342
374
  options?: Object,
@@ -985,7 +1017,8 @@ declare namespace SplitIO {
985
1017
  */
986
1018
  features?: MockedFeaturesMap,
987
1019
  /**
988
- * 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'.
989
1022
  * @property {Object} storage
990
1023
  */
991
1024
  storage?: {
@@ -1040,7 +1073,8 @@ declare namespace SplitIO {
1040
1073
  */
1041
1074
  urls?: UrlSettings,
1042
1075
  /**
1043
- * 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.
1044
1078
  * @property {Object} storage
1045
1079
  */
1046
1080
  storage?: {
@@ -1074,6 +1108,11 @@ declare namespace SplitIO {
1074
1108
  * @see {@link https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK#configuration}
1075
1109
  */
1076
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
+ */
1077
1116
  storage: {
1078
1117
  /**
1079
1118
  * 'REDIS' storage type to be instantiated by the SDK.
@@ -1081,10 +1120,68 @@ declare namespace SplitIO {
1081
1120
  */
1082
1121
  type: NodeAsyncStorage,
1083
1122
  /**
1084
- * Options to be passed to the selected storage. Use it with type: 'REDIS'
1123
+ * Options to be passed to the Redis storage. Use it with storage type: 'REDIS'.
1085
1124
  * @property {Object} options
1086
1125
  */
1087
- options?: Object,
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
+ },
1088
1185
  /**
1089
1186
  * Optional prefix to prevent any kind of data collision between SDK versions.
1090
1187
  * @property {string} prefix
@@ -1149,24 +1246,10 @@ declare namespace SplitIO {
1149
1246
  */
1150
1247
  client(key: SplitKey, trafficType?: string): IBrowserClient
1151
1248
  /**
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.
1249
+ * User consent API.
1250
+ * @property UserConsent
1168
1251
  */
1169
- getUserConsent(): ConsentStatus;
1252
+ UserConsent: IUserConsentAPI
1170
1253
  }
1171
1254
  /**
1172
1255
  * This represents the interface for the SDK instance with asynchronous storage.
@@ -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
- }