@splitsoftware/splitio 10.23.1-rc.3 → 10.23.2-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.
- package/CHANGES.txt +1 -1
- package/es/settings/defaults/version.js +1 -1
- package/lib/settings/defaults/version.js +1 -1
- package/package.json +3 -6
- package/src/settings/defaults/version.js +1 -1
- package/types/splitio.d.ts +71 -52
- package/es/factory/browserSuite.js +0 -67
- package/lib/factory/browserSuite.js +0 -71
- package/src/factory/browserSuite.js +0 -79
- package/suite/package.json +0 -5
- package/types/suite/index.d.ts +0 -12
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.
|
|
5
|
+
- Updated @splitsoftware/splitio-commons package to version 1.8.4 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)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export var packageVersion = '10.23.
|
|
1
|
+
export var packageVersion = '10.23.2-rc.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio",
|
|
3
|
-
"version": "10.23.
|
|
3
|
+
"version": "10.23.2-rc.0",
|
|
4
4
|
"description": "Split SDK",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
"es",
|
|
13
13
|
"src",
|
|
14
14
|
"scripts/ga-to-split-autorequire.js",
|
|
15
|
-
"suite",
|
|
16
15
|
"client",
|
|
17
16
|
"server"
|
|
18
17
|
],
|
|
@@ -41,8 +40,7 @@
|
|
|
41
40
|
"node": ">=6"
|
|
42
41
|
},
|
|
43
42
|
"dependencies": {
|
|
44
|
-
"@splitsoftware/
|
|
45
|
-
"@splitsoftware/splitio-commons": "1.9.2-rc.2",
|
|
43
|
+
"@splitsoftware/splitio-commons": "1.9.2-rc.1",
|
|
46
44
|
"@types/google.analytics": "0.0.40",
|
|
47
45
|
"@types/ioredis": "^4.28.0",
|
|
48
46
|
"bloom-filters": "^3.0.0",
|
|
@@ -102,14 +100,13 @@
|
|
|
102
100
|
"check:version": "cross-env NODE_ENV=test tape -r ./ts-node.register src/settings/__tests__/defaults.spec.js",
|
|
103
101
|
"test-browser": "npm run test-browser-unit && npm run test-browser-e2e",
|
|
104
102
|
"test-browser-unit": "cross-env NODE_ENV=test karma start karma/unit.karma.conf.js",
|
|
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
|
|
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",
|
|
106
104
|
"test-browser-e2e-online": "cross-env NODE_ENV=test karma start karma/e2e.online.karma.conf.js",
|
|
107
105
|
"test-browser-e2e-offline": "cross-env NODE_ENV=test karma start karma/e2e.offline.karma.conf.js",
|
|
108
106
|
"test-browser-e2e-destroy": "cross-env NODE_ENV=test karma start karma/e2e.destroy.karma.conf.js",
|
|
109
107
|
"test-browser-e2e-errorCatching": "cross-env NODE_ENV=test karma start karma/e2e.errorCatching.karma.conf.js",
|
|
110
108
|
"test-browser-e2e-push": "cross-env NODE_ENV=test karma start karma/e2e.push.karma.conf.js",
|
|
111
109
|
"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",
|
|
113
110
|
"test-node": "npm run test-node-unit && npm run test-node-e2e",
|
|
114
111
|
"test-node-unit": "cross-env NODE_ENV=test tape -r ./ts-node.register \"src/*/**/__tests__/**/!(browser).spec.js\" | tap-min",
|
|
115
112
|
"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",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageVersion = '10.23.
|
|
1
|
+
export const packageVersion = '10.23.2-rc.0';
|
package/types/splitio.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
/// <reference types="google.analytics" />
|
|
6
6
|
import { RedisOptions } from "ioredis";
|
|
7
|
-
import { SplitRumAgentConfig, EventCollector } from '@splitsoftware/browser-rum-agent';
|
|
8
7
|
|
|
9
8
|
export as namespace SplitIO;
|
|
10
9
|
export = SplitIO;
|
|
@@ -1120,19 +1119,6 @@ declare namespace SplitIO {
|
|
|
1120
1119
|
*/
|
|
1121
1120
|
userConsent?: ConsentStatus
|
|
1122
1121
|
}
|
|
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
|
-
}
|
|
1136
1122
|
/**
|
|
1137
1123
|
* Settings interface for SDK instances created on NodeJS.
|
|
1138
1124
|
* If your storage is asynchronous (Redis for example) use SplitIO.INodeAsyncSettings instead.
|
|
@@ -1302,8 +1288,8 @@ declare namespace SplitIO {
|
|
|
1302
1288
|
}
|
|
1303
1289
|
/**
|
|
1304
1290
|
* This represents the interface for the SDK instance with synchronous storage.
|
|
1305
|
-
* @interface
|
|
1306
|
-
* @extends
|
|
1291
|
+
* @interface ISDK
|
|
1292
|
+
* @extends IBasicSDK
|
|
1307
1293
|
*/
|
|
1308
1294
|
interface IBrowserSDK extends ISDK {
|
|
1309
1295
|
/**
|
|
@@ -1326,41 +1312,6 @@ declare namespace SplitIO {
|
|
|
1326
1312
|
*/
|
|
1327
1313
|
UserConsent: IUserConsentAPI
|
|
1328
1314
|
}
|
|
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
|
-
}
|
|
1364
1315
|
/**
|
|
1365
1316
|
* This represents the interface for the SDK instance with asynchronous storage.
|
|
1366
1317
|
* @interface IAsyncSDK
|
|
@@ -1419,7 +1370,7 @@ declare namespace SplitIO {
|
|
|
1419
1370
|
/**
|
|
1420
1371
|
* Returns a TreatmentWithConfig value, which an object with both treatment and config string for the given feature.
|
|
1421
1372
|
* For usage on the Browser as we defined the key on the settings.
|
|
1422
|
-
* @function
|
|
1373
|
+
* @function getTreatmentWithConfig
|
|
1423
1374
|
* @param {string} featureFlagName - The string that represents the feature flag we want to get the treatment.
|
|
1424
1375
|
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1425
1376
|
* @returns {TreatmentWithConfig} The TreatmentWithConfig, the object containing the treatment string and the
|
|
@@ -1466,6 +1417,74 @@ declare namespace SplitIO {
|
|
|
1466
1417
|
* @returns {TreatmentsWithConfig} The map with all the TreatmentWithConfig objects
|
|
1467
1418
|
*/
|
|
1468
1419
|
getTreatmentsWithConfig(featureFlagNames: string[], attributes?: Attributes): TreatmentsWithConfig,
|
|
1420
|
+
/**
|
|
1421
|
+
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1422
|
+
* @function getTreatmentsByFlagSet
|
|
1423
|
+
* @param {string} key - The string key representing the consumer.
|
|
1424
|
+
* @param {string} flagSet - The flag set name we want to get the treatments.
|
|
1425
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1426
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1427
|
+
*/
|
|
1428
|
+
getTreatmentsByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): Treatments,
|
|
1429
|
+
/**
|
|
1430
|
+
* Returns a Treatments value, which is an object map with the treatments for the feature flags related to the given flag set.
|
|
1431
|
+
* @function getTreatmentsByFlagSet
|
|
1432
|
+
* @param {string} flagSet - The flag set name we want to get the treatments.
|
|
1433
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1434
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1435
|
+
*/
|
|
1436
|
+
getTreatmentsByFlagSet(flagSet: string, attributes?: Attributes): Treatments,
|
|
1437
|
+
/**
|
|
1438
|
+
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1439
|
+
* @function getTreatmentsWithConfigByFlagSet
|
|
1440
|
+
* @param {string} key - The string key representing the consumer.
|
|
1441
|
+
* @param {string} flagSet - The flag set name we want to get the treatments.
|
|
1442
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1443
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1444
|
+
*/
|
|
1445
|
+
getTreatmentsWithConfigByFlagSet(key: SplitKey, flagSet: string, attributes?: Attributes): TreatmentsWithConfig,
|
|
1446
|
+
/**
|
|
1447
|
+
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag set.
|
|
1448
|
+
* @function getTreatmentsWithConfigByFlagSet
|
|
1449
|
+
* @param {string} flagSet - The flag set name we want to get the treatments.
|
|
1450
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1451
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1452
|
+
*/
|
|
1453
|
+
getTreatmentsWithConfigByFlagSet(flagSet: string, attributes?: Attributes): TreatmentsWithConfig,
|
|
1454
|
+
/**
|
|
1455
|
+
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1456
|
+
* @function getTreatmentsByFlagSets
|
|
1457
|
+
* @param {string} key - The string key representing the consumer.
|
|
1458
|
+
* @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
|
|
1459
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1460
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1461
|
+
*/
|
|
1462
|
+
getTreatmentsByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): Treatments,
|
|
1463
|
+
/**
|
|
1464
|
+
* Returns a Returns a Treatments value, which is an object with both treatment and config string for to the feature flags related to the given flag sets.
|
|
1465
|
+
* @function getTreatmentsByFlagSets
|
|
1466
|
+
* @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
|
|
1467
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1468
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1469
|
+
*/
|
|
1470
|
+
getTreatmentsByFlagSets(flagSets: string[], attributes?: Attributes): Treatments,
|
|
1471
|
+
/**
|
|
1472
|
+
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1473
|
+
* @function getTreatmentsWithConfigByFlagSets
|
|
1474
|
+
* @param {string} key - The string key representing the consumer.
|
|
1475
|
+
* @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
|
|
1476
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1477
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1478
|
+
*/
|
|
1479
|
+
getTreatmentsWithConfigByFlagSets(key: SplitKey, flagSets: string[], attributes?: Attributes): TreatmentsWithConfig,
|
|
1480
|
+
/**
|
|
1481
|
+
* Returns a TreatmentsWithConfig value, which is an object map with the TreatmentWithConfig (an object with both treatment and config string) for the feature flags related to the given flag sets.
|
|
1482
|
+
* @function getTreatmentsWithConfigByFlagSets
|
|
1483
|
+
* @param {Array<string>} flagSets - An array of the flag set names we want to get the treatments.
|
|
1484
|
+
* @param {Attributes=} attributes - An object of type Attributes defining the attributes for the given key.
|
|
1485
|
+
* @returns {Treatments} The map with all the TreatmentWithConfig objects
|
|
1486
|
+
*/
|
|
1487
|
+
getTreatmentsWithConfigByFlagSets(flagSets: string[], attributes?: Attributes): TreatmentsWithConfig,
|
|
1469
1488
|
/**
|
|
1470
1489
|
* Tracks an event to be fed to the results product on Split user interface.
|
|
1471
1490
|
* For usage on NodeJS as we don't have only one key.
|
|
@@ -1,67 +0,0 @@
|
|
|
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,71 +0,0 @@
|
|
|
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,79 +0,0 @@
|
|
|
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
|
-
}
|
package/suite/package.json
DELETED
package/types/suite/index.d.ts
DELETED
|
@@ -1,12 +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
|
-
* @TODO
|
|
10
|
-
*/
|
|
11
|
-
export function SplitSuite(settings: SplitIO.IBrowserSuiteSettings): SplitIO.IBrowserSuiteSDK;
|
|
12
|
-
}
|