@splitsoftware/splitio 10.23.1-rc.2 → 10.23.1-rc.3

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
@@ -2,7 +2,7 @@
2
2
  - Updated @splitsoftware/splitio-commons package to version 1.9.1. This update removes the handler for 'unload' DOM events, that can prevent browsers from being able to put pages in the back/forward cache for faster back and forward loads (Related to issue https://github.com/splitio/javascript-client/issues/759).
3
3
 
4
4
  10.23.0 (July 18, 2023)
5
- - Updated @splitsoftware/splitio-commons package to version 1.8.4 that includes minor improvements:
5
+ - Updated @splitsoftware/splitio-commons package to version 1.9.0 that includes minor improvements:
6
6
  - Updated streaming architecture implementation to apply feature flag updates from the notification received which is now enhanced, improving efficiency and reliability of the whole update system.
7
7
 
8
8
  10.22.6 (July 6, 2023)
@@ -0,0 +1,67 @@
1
+ import { objectAssign } from '@splitsoftware/splitio-commons/esm/utils/lang/objectAssign';
2
+ import { _Set, setToArray } from '@splitsoftware/splitio-commons/esm/utils/lang/sets';
3
+ import { STANDALONE_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
4
+ // @TODO import RumAgent automatically or users should import it?
5
+ import { SplitRumAgent } from '@splitsoftware/browser-rum-agent';
6
+ import { SplitFactory } from './browser';
7
+ var DEFAULT_TRAFFIC_TYPE = 'user';
8
+ /**
9
+ * SplitFactory for client-side with RUM Agent.
10
+ *
11
+ * @param {import('../../types/splitio').IBrowserSuiteSettings} config configuration object used to instantiate the Suite
12
+ * @param {Function=} __updateModules optional function that lets redefine internal SDK modules. Use with
13
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
14
+ * @throws Will throw an error if the provided config is invalid.
15
+ */
16
+ export function SplitSuite(config, __updateModules) {
17
+ var sdk = SplitFactory(config, __updateModules);
18
+ /** @type {import('../../types/splitio').IBrowserSuiteSettings} */
19
+ var settings = sdk.settings;
20
+ // Do not setup RUM Agent if not in standalone mode
21
+ if (settings.mode !== STANDALONE_MODE)
22
+ return sdk;
23
+ // Setup RUM Agent
24
+ var agentConfig = SplitRumAgent.__getConfig();
25
+ if (agentConfig.a) {
26
+ settings.log.warn('RUM Agent already setup. The new Suite instance will reset the RUM Agent configuration.');
27
+ }
28
+ agentConfig.log = settings.log;
29
+ SplitRumAgent.removeIdentities(); // reset identities for new Suite
30
+ SplitRumAgent.setup(settings.core.authorizationKey, objectAssign({
31
+ url: settings.urls.events,
32
+ userConsent: settings.userConsent
33
+ }, settings.rumAgent));
34
+ var clients = new _Set();
35
+ // Override UserConsent.setStatus to update RUM Agent consent
36
+ var originalSetStatus = sdk.UserConsent.setStatus;
37
+ sdk.UserConsent.setStatus = function (newStatus) {
38
+ SplitRumAgent.setUserConsent(newStatus);
39
+ return originalSetStatus.apply(this, arguments);
40
+ };
41
+ // Create Suite instance extending SDK
42
+ return objectAssign({}, sdk, {
43
+ client: function () {
44
+ var client = sdk.client.apply(sdk, arguments);
45
+ if (!clients.has(client)) {
46
+ clients.add(client);
47
+ SplitRumAgent.addIdentity({
48
+ key: client.key,
49
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
50
+ });
51
+ // override client.destroy to remove identity from RUM Agent
52
+ var originalDestroy_1 = client.destroy;
53
+ client.destroy = function () {
54
+ SplitRumAgent.removeIdentity({
55
+ key: client.key,
56
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
57
+ });
58
+ return originalDestroy_1.apply(client, arguments);
59
+ };
60
+ }
61
+ return client;
62
+ },
63
+ destroy: function () {
64
+ return Promise.all(setToArray(clients).map(function (client) { return client.destroy(); }));
65
+ }
66
+ });
67
+ }
@@ -1 +1 @@
1
- export var packageVersion = '10.23.1-rc.2';
1
+ export var packageVersion = '10.23.1-rc.3';
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SplitSuite = void 0;
4
+ var objectAssign_1 = require("@splitsoftware/splitio-commons/cjs/utils/lang/objectAssign");
5
+ var sets_1 = require("@splitsoftware/splitio-commons/cjs/utils/lang/sets");
6
+ var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
7
+ // @TODO import RumAgent automatically or users should import it?
8
+ var browser_rum_agent_1 = require("@splitsoftware/browser-rum-agent");
9
+ var browser_1 = require("./browser");
10
+ var DEFAULT_TRAFFIC_TYPE = 'user';
11
+ /**
12
+ * SplitFactory for client-side with RUM Agent.
13
+ *
14
+ * @param {import('../../types/splitio').IBrowserSuiteSettings} config configuration object used to instantiate the Suite
15
+ * @param {Function=} __updateModules optional function that lets redefine internal SDK modules. Use with
16
+ * caution since, unlike `config`, this param is not validated neither considered part of the public API.
17
+ * @throws Will throw an error if the provided config is invalid.
18
+ */
19
+ function SplitSuite(config, __updateModules) {
20
+ var sdk = (0, browser_1.SplitFactory)(config, __updateModules);
21
+ /** @type {import('../../types/splitio').IBrowserSuiteSettings} */
22
+ var settings = sdk.settings;
23
+ // Do not setup RUM Agent if not in standalone mode
24
+ if (settings.mode !== constants_1.STANDALONE_MODE)
25
+ return sdk;
26
+ // Setup RUM Agent
27
+ var agentConfig = browser_rum_agent_1.SplitRumAgent.__getConfig();
28
+ if (agentConfig.a) {
29
+ settings.log.warn('RUM Agent already setup. The new Suite instance will reset the RUM Agent configuration.');
30
+ }
31
+ agentConfig.log = settings.log;
32
+ browser_rum_agent_1.SplitRumAgent.removeIdentities(); // reset identities for new Suite
33
+ browser_rum_agent_1.SplitRumAgent.setup(settings.core.authorizationKey, (0, objectAssign_1.objectAssign)({
34
+ url: settings.urls.events,
35
+ userConsent: settings.userConsent
36
+ }, settings.rumAgent));
37
+ var clients = new sets_1._Set();
38
+ // Override UserConsent.setStatus to update RUM Agent consent
39
+ var originalSetStatus = sdk.UserConsent.setStatus;
40
+ sdk.UserConsent.setStatus = function (newStatus) {
41
+ browser_rum_agent_1.SplitRumAgent.setUserConsent(newStatus);
42
+ return originalSetStatus.apply(this, arguments);
43
+ };
44
+ // Create Suite instance extending SDK
45
+ return (0, objectAssign_1.objectAssign)({}, sdk, {
46
+ client: function () {
47
+ var client = sdk.client.apply(sdk, arguments);
48
+ if (!clients.has(client)) {
49
+ clients.add(client);
50
+ browser_rum_agent_1.SplitRumAgent.addIdentity({
51
+ key: client.key,
52
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
53
+ });
54
+ // override client.destroy to remove identity from RUM Agent
55
+ var originalDestroy_1 = client.destroy;
56
+ client.destroy = function () {
57
+ browser_rum_agent_1.SplitRumAgent.removeIdentity({
58
+ key: client.key,
59
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
60
+ });
61
+ return originalDestroy_1.apply(client, arguments);
62
+ };
63
+ }
64
+ return client;
65
+ },
66
+ destroy: function () {
67
+ return Promise.all((0, sets_1.setToArray)(clients).map(function (client) { return client.destroy(); }));
68
+ }
69
+ });
70
+ }
71
+ exports.SplitSuite = SplitSuite;
@@ -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.23.1-rc.2';
4
+ exports.packageVersion = '10.23.1-rc.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.23.1-rc.2",
3
+ "version": "10.23.1-rc.3",
4
4
  "description": "Split SDK",
5
5
  "files": [
6
6
  "README.md",
@@ -12,6 +12,7 @@
12
12
  "es",
13
13
  "src",
14
14
  "scripts/ga-to-split-autorequire.js",
15
+ "suite",
15
16
  "client",
16
17
  "server"
17
18
  ],
@@ -40,7 +41,8 @@
40
41
  "node": ">=6"
41
42
  },
42
43
  "dependencies": {
43
- "@splitsoftware/splitio-commons": "1.9.1",
44
+ "@splitsoftware/browser-rum-agent": "0.3.2-rc.0",
45
+ "@splitsoftware/splitio-commons": "1.9.2-rc.2",
44
46
  "@types/google.analytics": "0.0.40",
45
47
  "@types/ioredis": "^4.28.0",
46
48
  "bloom-filters": "^3.0.0",
@@ -100,13 +102,14 @@
100
102
  "check:version": "cross-env NODE_ENV=test tape -r ./ts-node.register src/settings/__tests__/defaults.spec.js",
101
103
  "test-browser": "npm run test-browser-unit && npm run test-browser-e2e",
102
104
  "test-browser-unit": "cross-env NODE_ENV=test karma start karma/unit.karma.conf.js",
103
- "test-browser-e2e": "npm run test-browser-e2e-online && npm run test-browser-e2e-offline && npm run test-browser-e2e-destroy && npm run test-browser-e2e-errorCatching && npm run test-browser-e2e-push && npm run test-browser-e2e-gaIntegration",
105
+ "test-browser-e2e": "npm run test-browser-e2e-online && npm run test-browser-e2e-offline && npm run test-browser-e2e-destroy && npm run test-browser-e2e-errorCatching && npm run test-browser-e2e-push && npm run test-browser-e2e-gaIntegration && npm run test-browser-e2e-suite",
104
106
  "test-browser-e2e-online": "cross-env NODE_ENV=test karma start karma/e2e.online.karma.conf.js",
105
107
  "test-browser-e2e-offline": "cross-env NODE_ENV=test karma start karma/e2e.offline.karma.conf.js",
106
108
  "test-browser-e2e-destroy": "cross-env NODE_ENV=test karma start karma/e2e.destroy.karma.conf.js",
107
109
  "test-browser-e2e-errorCatching": "cross-env NODE_ENV=test karma start karma/e2e.errorCatching.karma.conf.js",
108
110
  "test-browser-e2e-push": "cross-env NODE_ENV=test karma start karma/e2e.push.karma.conf.js",
109
111
  "test-browser-e2e-gaIntegration": "cross-env NODE_ENV=test karma start karma/e2e.gaIntegration.karma.conf.js",
112
+ "test-browser-e2e-suite": "cross-env NODE_ENV=test karma start karma/e2e.suite.karma.conf.js",
110
113
  "test-node": "npm run test-node-unit && npm run test-node-e2e",
111
114
  "test-node-unit": "cross-env NODE_ENV=test tape -r ./ts-node.register \"src/*/**/__tests__/**/!(browser).spec.js\" | tap-min",
112
115
  "test-node-e2e": "npm run test-node-e2e-online && npm run test-node-e2e-offline && npm run test-node-e2e-destroy && npm run test-node-e2e-errorCatching && npm run test-node-e2e-push && npm run test-node-e2e-redis",
@@ -0,0 +1,79 @@
1
+ import { objectAssign } from '@splitsoftware/splitio-commons/src/utils/lang/objectAssign';
2
+ import { _Set, setToArray } from '@splitsoftware/splitio-commons/src/utils/lang/sets';
3
+ import { STANDALONE_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
4
+ // @TODO import RumAgent automatically or users should import it?
5
+ import { SplitRumAgent } from '@splitsoftware/browser-rum-agent';
6
+ import { SplitFactory } from './browser';
7
+
8
+ const DEFAULT_TRAFFIC_TYPE = 'user';
9
+
10
+ /**
11
+ * SplitFactory for client-side with RUM Agent.
12
+ *
13
+ * @param {import('../../types/splitio').IBrowserSuiteSettings} config configuration object used to instantiate the Suite
14
+ * @param {Function=} __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.
16
+ * @throws Will throw an error if the provided config is invalid.
17
+ */
18
+ export function SplitSuite(config, __updateModules) {
19
+ const sdk = SplitFactory(config, __updateModules);
20
+
21
+ /** @type {import('../../types/splitio').IBrowserSuiteSettings} */
22
+ const settings = sdk.settings;
23
+
24
+ // Do not setup RUM Agent if not in standalone mode
25
+ if (settings.mode !== STANDALONE_MODE) return sdk;
26
+
27
+ // Setup RUM Agent
28
+ const agentConfig = SplitRumAgent.__getConfig();
29
+ if (agentConfig.a) {
30
+ settings.log.warn('RUM Agent already setup. The new Suite instance will reset the RUM Agent configuration.');
31
+ }
32
+ agentConfig.log = settings.log;
33
+ SplitRumAgent.removeIdentities(); // reset identities for new Suite
34
+ SplitRumAgent.setup(settings.core.authorizationKey, objectAssign({
35
+ url: settings.urls.events,
36
+ userConsent: settings.userConsent
37
+ }, settings.rumAgent));
38
+
39
+ const clients = new _Set();
40
+
41
+ // Override UserConsent.setStatus to update RUM Agent consent
42
+ const originalSetStatus = sdk.UserConsent.setStatus;
43
+ sdk.UserConsent.setStatus = function (newStatus) {
44
+ SplitRumAgent.setUserConsent(newStatus);
45
+ return originalSetStatus.apply(this, arguments);
46
+ };
47
+
48
+ // Create Suite instance extending SDK
49
+ return objectAssign({}, sdk, {
50
+ client() {
51
+ const client = sdk.client.apply(sdk, arguments);
52
+
53
+ if (!clients.has(client)) {
54
+ clients.add(client);
55
+
56
+ SplitRumAgent.addIdentity({
57
+ key: client.key,
58
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
59
+ });
60
+
61
+ // override client.destroy to remove identity from RUM Agent
62
+ const originalDestroy = client.destroy;
63
+ client.destroy = function () {
64
+ SplitRumAgent.removeIdentity({
65
+ key: client.key,
66
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
67
+ });
68
+ return originalDestroy.apply(client, arguments);
69
+ };
70
+ }
71
+
72
+ return client;
73
+ },
74
+
75
+ destroy() {
76
+ return Promise.all(setToArray(clients).map(client => client.destroy()));
77
+ }
78
+ });
79
+ }
@@ -1 +1 @@
1
- export const packageVersion = '10.23.1-rc.2';
1
+ export const packageVersion = '10.23.1-rc.3';
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../lib/factory/browserSuite.js",
3
+ "module": "../es/factory/browserSuite.js",
4
+ "types": "../types/suite/index.d.ts"
5
+ }
@@ -4,6 +4,7 @@
4
4
 
5
5
  /// <reference types="google.analytics" />
6
6
  import { RedisOptions } from "ioredis";
7
+ import { SplitRumAgentConfig, EventCollector } from '@splitsoftware/browser-rum-agent';
7
8
 
8
9
  export as namespace SplitIO;
9
10
  export = SplitIO;
@@ -189,8 +190,14 @@ interface IUserConsentAPI {
189
190
  */
190
191
  interface ISharedSettings {
191
192
  /**
192
- * Whether the logger should be enabled or disabled by default.
193
- * @property {Boolean} debug
193
+ * Boolean value to indicate whether the logger should be enabled or disabled, or a log level string.
194
+ *
195
+ * Examples:
196
+ * ```javascript
197
+ * config.debug = true
198
+ * config.debug = 'WARN'
199
+ * ```
200
+ * @property {boolean | LogLevel} debug
194
201
  * @default false
195
202
  */
196
203
  debug?: boolean | LogLevel,
@@ -1113,6 +1120,19 @@ declare namespace SplitIO {
1113
1120
  */
1114
1121
  userConsent?: ConsentStatus
1115
1122
  }
1123
+ /**
1124
+ * Settings interface for Suite instances created on the browser.
1125
+ * @interface IBrowserSuiteSettings
1126
+ * @extends IBrowserSettings
1127
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
1128
+ */
1129
+ interface IBrowserSuiteSettings extends IBrowserSettings {
1130
+ /**
1131
+ * Optional configuration object for the RUM agent.
1132
+ * @see {@link https://help.split.io/hc/en-us/articles/360030898431-Browser-RUM-agent#configuration}
1133
+ */
1134
+ rumAgent?: SplitRumAgentConfig
1135
+ }
1116
1136
  /**
1117
1137
  * Settings interface for SDK instances created on NodeJS.
1118
1138
  * If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
@@ -1282,8 +1302,8 @@ declare namespace SplitIO {
1282
1302
  }
1283
1303
  /**
1284
1304
  * This represents the interface for the SDK instance with synchronous storage.
1285
- * @interface ISDK
1286
- * @extends IBasicSDK
1305
+ * @interface IBrowserSDK
1306
+ * @extends ISDK
1287
1307
  */
1288
1308
  interface IBrowserSDK extends ISDK {
1289
1309
  /**
@@ -1306,6 +1326,41 @@ declare namespace SplitIO {
1306
1326
  */
1307
1327
  UserConsent: IUserConsentAPI
1308
1328
  }
1329
+ /**
1330
+ * This represents the interface for the Suite instance, that is an extension of the SDK interface.
1331
+ * @interface IBrowserSuiteSDK
1332
+ * @extends IBrowserSDK
1333
+ */
1334
+ interface IBrowserSuiteSDK extends IBrowserSDK {
1335
+ /**
1336
+ * Returns the default client instance of the SDK, and adds its identity (i.e., user key and traffic type pair) to the RUM agent to track events for it.
1337
+ *
1338
+ * NOTE: if no traffic type was provided to the config, 'user' will be used as default for the RUM Agent.
1339
+ *
1340
+ * @function client
1341
+ * @returns {IBrowserClient} The client instance.
1342
+ */
1343
+ client(): IBrowserClient,
1344
+ /**
1345
+ * Returns a shared client of the SDK, and adds its identity (i.e., user key and traffic type pair) to the RUM agent to track events for it.
1346
+ *
1347
+ * NOTE: if no traffic type is provided as second argument, 'user' will be used as default for the RUM Agent.
1348
+ *
1349
+ * @function client
1350
+ * @param {SplitKey} key The key for the new client instance.
1351
+ * @param {string=} trafficType The traffic type of the provided key.
1352
+ * @returns {IBrowserClient} The client instance.
1353
+ */
1354
+ client(key: SplitKey, trafficType?: string): IBrowserClient
1355
+ /**
1356
+ * Destroys all client instances and remove identities from the RUM agent to stop tracking events for them.
1357
+ * This method will flush any pending impressions and events, and stop the synchronization of feature flag definitions with the backend.
1358
+ *
1359
+ * @function destroy
1360
+ * @returns {Promise<void>} A promise that resolves once the client is destroyed.
1361
+ */
1362
+ destroy(): Promise<void>
1363
+ }
1309
1364
  /**
1310
1365
  * This represents the interface for the SDK instance with asynchronous storage.
1311
1366
  * @interface IAsyncSDK
@@ -0,0 +1,12 @@
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
+ * @TODO
10
+ */
11
+ export function SplitSuite(settings: SplitIO.IBrowserSuiteSettings): SplitIO.IBrowserSuiteSDK;
12
+ }