@splitsoftware/splitio 10.23.0 → 10.23.1-rc.1

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,5 +1,5 @@
1
1
  10.23.0 (July 18, 2023)
2
- - Updated @splitsoftware/splitio-commons package to version 1.8.4 that includes minor improvements:
2
+ - Updated @splitsoftware/splitio-commons package to version 1.9.0 that includes minor improvements:
3
3
  - 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.
4
4
 
5
5
  10.22.6 (July 6, 2023)
@@ -0,0 +1,57 @@
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
+ SplitRumAgent.__getConfig().log = settings.log;
25
+ SplitRumAgent.setup(settings.core.authorizationKey, objectAssign({
26
+ url: settings.urls.events,
27
+ pushRate: settings.scheduler.eventsPushRate,
28
+ queueSize: settings.scheduler.eventsQueueSize
29
+ }, settings.rumAgent));
30
+ var clients = new _Set();
31
+ // Create Suite instance extending SDK
32
+ return objectAssign({}, sdk, {
33
+ client: function () {
34
+ var client = sdk.client.apply(sdk, arguments);
35
+ if (!clients.has(client)) {
36
+ clients.add(client);
37
+ SplitRumAgent.addIdentity({
38
+ key: client.key,
39
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
40
+ });
41
+ // override client.destroy to remove identity from RUM Agent
42
+ var originalDestroy_1 = client.destroy;
43
+ client.destroy = function () {
44
+ SplitRumAgent.removeIdentity({
45
+ key: client.key,
46
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
47
+ });
48
+ return originalDestroy_1.apply(client, arguments);
49
+ };
50
+ }
51
+ return client;
52
+ },
53
+ destroy: function () {
54
+ return Promise.all(setToArray(clients).map(function (client) { return client.destroy(); }));
55
+ }
56
+ });
57
+ }
@@ -1 +1 @@
1
- export var packageVersion = '10.23.0';
1
+ export var packageVersion = '10.23.1-rc.1';
@@ -0,0 +1,61 @@
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
+ browser_rum_agent_1.SplitRumAgent.__getConfig().log = settings.log;
28
+ browser_rum_agent_1.SplitRumAgent.setup(settings.core.authorizationKey, (0, objectAssign_1.objectAssign)({
29
+ url: settings.urls.events,
30
+ pushRate: settings.scheduler.eventsPushRate,
31
+ queueSize: settings.scheduler.eventsQueueSize
32
+ }, settings.rumAgent));
33
+ var clients = new sets_1._Set();
34
+ // Create Suite instance extending SDK
35
+ return (0, objectAssign_1.objectAssign)({}, sdk, {
36
+ client: function () {
37
+ var client = sdk.client.apply(sdk, arguments);
38
+ if (!clients.has(client)) {
39
+ clients.add(client);
40
+ browser_rum_agent_1.SplitRumAgent.addIdentity({
41
+ key: client.key,
42
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
43
+ });
44
+ // override client.destroy to remove identity from RUM Agent
45
+ var originalDestroy_1 = client.destroy;
46
+ client.destroy = function () {
47
+ browser_rum_agent_1.SplitRumAgent.removeIdentity({
48
+ key: client.key,
49
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
50
+ });
51
+ return originalDestroy_1.apply(client, arguments);
52
+ };
53
+ }
54
+ return client;
55
+ },
56
+ destroy: function () {
57
+ return Promise.all((0, sets_1.setToArray)(clients).map(function (client) { return client.destroy(); }));
58
+ }
59
+ });
60
+ }
61
+ 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.0';
4
+ exports.packageVersion = '10.23.1-rc.1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio",
3
- "version": "10.23.0",
3
+ "version": "10.23.1-rc.1",
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.0",
44
+ "@splitsoftware/browser-rum-agent": "0.3.0",
45
+ "@splitsoftware/splitio-commons": "1.9.1-rc.0",
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,68 @@
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
+ SplitRumAgent.__getConfig().log = settings.log;
29
+ SplitRumAgent.setup(settings.core.authorizationKey, objectAssign({
30
+ url: settings.urls.events,
31
+ pushRate: settings.scheduler.eventsPushRate,
32
+ queueSize: settings.scheduler.eventsQueueSize
33
+ }, settings.rumAgent));
34
+
35
+ const clients = new _Set();
36
+
37
+ // Create Suite instance extending SDK
38
+ return objectAssign({}, sdk, {
39
+ client() {
40
+ const client = sdk.client.apply(sdk, arguments);
41
+
42
+ if (!clients.has(client)) {
43
+ clients.add(client);
44
+
45
+ SplitRumAgent.addIdentity({
46
+ key: client.key,
47
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
48
+ });
49
+
50
+ // override client.destroy to remove identity from RUM Agent
51
+ const originalDestroy = client.destroy;
52
+ client.destroy = function () {
53
+ SplitRumAgent.removeIdentity({
54
+ key: client.key,
55
+ trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
56
+ });
57
+ return originalDestroy.apply(client, arguments);
58
+ };
59
+ }
60
+
61
+ return client;
62
+ },
63
+
64
+ destroy() {
65
+ return Promise.all(setToArray(clients).map(client => client.destroy()));
66
+ }
67
+ });
68
+ }
@@ -1 +1 @@
1
- export const packageVersion = '10.23.0';
1
+ export const packageVersion = '10.23.1-rc.1';
@@ -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;
@@ -1113,6 +1114,19 @@ declare namespace SplitIO {
1113
1114
  */
1114
1115
  userConsent?: ConsentStatus
1115
1116
  }
1117
+ /**
1118
+ * Settings interface for Suite instances created on the browser.
1119
+ * @interface IBrowserSuiteSettings
1120
+ * @extends IBrowserSettings
1121
+ * @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#configuration}
1122
+ */
1123
+ interface IBrowserSuiteSettings extends IBrowserSettings {
1124
+ /**
1125
+ * Optional configuration object for the RUM agent.
1126
+ * @see {@link https://help.split.io/hc/en-us/articles/360030898431-Browser-RUM-agent#configuration}
1127
+ */
1128
+ rumAgent?: SplitRumAgentConfig
1129
+ }
1116
1130
  /**
1117
1131
  * Settings interface for SDK instances created on NodeJS.
1118
1132
  * If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
@@ -1282,8 +1296,8 @@ declare namespace SplitIO {
1282
1296
  }
1283
1297
  /**
1284
1298
  * This represents the interface for the SDK instance with synchronous storage.
1285
- * @interface ISDK
1286
- * @extends IBasicSDK
1299
+ * @interface IBrowserSDK
1300
+ * @extends ISDK
1287
1301
  */
1288
1302
  interface IBrowserSDK extends ISDK {
1289
1303
  /**
@@ -1306,6 +1320,41 @@ declare namespace SplitIO {
1306
1320
  */
1307
1321
  UserConsent: IUserConsentAPI
1308
1322
  }
1323
+ /**
1324
+ * This represents the interface for the Suite instance, that is an extension of the SDK interface.
1325
+ * @interface IBrowserSuiteSDK
1326
+ * @extends IBrowserSDK
1327
+ */
1328
+ interface IBrowserSuiteSDK extends IBrowserSDK {
1329
+ /**
1330
+ * 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.
1331
+ *
1332
+ * NOTE: if no traffic type was provided to the config, 'user' will be used as default for the RUM Agent.
1333
+ *
1334
+ * @function client
1335
+ * @returns {IBrowserClient} The client instance.
1336
+ */
1337
+ client(): IBrowserClient,
1338
+ /**
1339
+ * 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.
1340
+ *
1341
+ * NOTE: if no traffic type is provided as second argument, 'user' will be used as default for the RUM Agent.
1342
+ *
1343
+ * @function client
1344
+ * @param {SplitKey} key The key for the new client instance.
1345
+ * @param {string=} trafficType The traffic type of the provided key.
1346
+ * @returns {IBrowserClient} The client instance.
1347
+ */
1348
+ client(key: SplitKey, trafficType?: string): IBrowserClient
1349
+ /**
1350
+ * Destroys all client instances and remove identities from the RUM agent to stop tracking events for them.
1351
+ * This method will flush any pending impressions and events, and stop the synchronization of feature flag definitions with the backend.
1352
+ *
1353
+ * @function destroy
1354
+ * @returns {Promise<void>} A promise that resolves once the client is destroyed.
1355
+ */
1356
+ destroy(): Promise<void>
1357
+ }
1309
1358
  /**
1310
1359
  * This represents the interface for the SDK instance with asynchronous storage.
1311
1360
  * @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
+ }