@splitsoftware/splitio-browserjs 0.10.1 → 0.10.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 +3 -0
- package/cjs/settings/defaults.js +1 -1
- package/cjs/suite/browserSuite.js +70 -0
- package/cjs/suite/index.js +15 -0
- package/esm/settings/defaults.js +1 -1
- package/esm/suite/browserSuite.js +66 -0
- package/esm/suite/index.js +6 -0
- package/package.json +7 -4
- package/src/settings/defaults.ts +1 -1
- package/src/suite/browserSuite.ts +80 -0
- package/src/suite/index.ts +6 -0
- package/suite/package.json +5 -0
- package/types/full/index.d.ts +0 -1
- package/types/index.d.ts +0 -1
- package/types/splitio.d.ts +59 -0
- package/types/suite/index.d.ts +50 -0
package/CHANGES.txt
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
0.10.2 (October 20, 2023)
|
|
2
|
+
- Added Split Suite module for browser. The Split Suite is an extension of the SDK that sets up the Browser RUM Agent automatically. It can be imported via `import { SplitSuite } from '@splitsoftware/splitio-browserjs/suite';` or `const { SplitSuite } = require('@splitsoftware/splitio-browserjs/suite');`. See https://help.split.io/hc/en-us/articles/360030898431-Browser-RUM-agent#sdk-integration for more information.
|
|
3
|
+
|
|
1
4
|
0.10.1 (September 22, 2023)
|
|
2
5
|
- 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
6
|
|
package/cjs/settings/defaults.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.defaults = void 0;
|
|
4
4
|
var index_1 = require("@splitsoftware/splitio-commons/cjs/logger/index");
|
|
5
5
|
var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
|
|
6
|
-
var packageVersion = '0.10.
|
|
6
|
+
var packageVersion = '0.10.2-rc.0';
|
|
7
7
|
/**
|
|
8
8
|
* In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
|
|
9
9
|
* Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
var browser_rum_agent_1 = require("@splitsoftware/browser-rum-agent");
|
|
8
|
+
var splitFactory_1 = require("../full/splitFactory");
|
|
9
|
+
var DEFAULT_TRAFFIC_TYPE = 'user';
|
|
10
|
+
/**
|
|
11
|
+
* SplitFactory for client-side with RUM Agent.
|
|
12
|
+
*
|
|
13
|
+
* @param config configuration object used to instantiate the Suite
|
|
14
|
+
* @param __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
|
+
function SplitSuite(config, __updateModules) {
|
|
19
|
+
var sdk = (0, splitFactory_1.SplitFactory)(config, __updateModules);
|
|
20
|
+
var settings = sdk.settings;
|
|
21
|
+
// Do not setup RUM Agent if not in standalone mode
|
|
22
|
+
if (settings.mode !== constants_1.STANDALONE_MODE)
|
|
23
|
+
return sdk;
|
|
24
|
+
// Setup RUM Agent
|
|
25
|
+
var agentConfig = browser_rum_agent_1.SplitRumAgent.__getConfig();
|
|
26
|
+
if (agentConfig.a) {
|
|
27
|
+
settings.log.warn('RUM Agent already setup. The new Suite instance will reset the RUM Agent configuration.');
|
|
28
|
+
}
|
|
29
|
+
agentConfig.log = settings.log;
|
|
30
|
+
browser_rum_agent_1.SplitRumAgent.removeIdentities(); // reset identities for new Suite
|
|
31
|
+
browser_rum_agent_1.SplitRumAgent.setup(settings.core.authorizationKey, (0, objectAssign_1.objectAssign)({
|
|
32
|
+
url: settings.urls.events,
|
|
33
|
+
userConsent: settings.userConsent
|
|
34
|
+
}, settings.rumAgent));
|
|
35
|
+
var clients = new sets_1._Set();
|
|
36
|
+
// Override UserConsent.setStatus to update RUM Agent consent
|
|
37
|
+
var originalSetStatus = sdk.UserConsent.setStatus;
|
|
38
|
+
sdk.UserConsent.setStatus = function (newStatus) {
|
|
39
|
+
browser_rum_agent_1.SplitRumAgent.setUserConsent(newStatus);
|
|
40
|
+
return originalSetStatus.apply(this, arguments);
|
|
41
|
+
};
|
|
42
|
+
// Create Suite instance extending SDK
|
|
43
|
+
return (0, objectAssign_1.objectAssign)({}, sdk, {
|
|
44
|
+
client: function () {
|
|
45
|
+
var client = sdk.client.apply(sdk, arguments);
|
|
46
|
+
if (!clients.has(client)) {
|
|
47
|
+
clients.add(client);
|
|
48
|
+
browser_rum_agent_1.SplitRumAgent.addIdentity({
|
|
49
|
+
key: client.key,
|
|
50
|
+
// For main client, use trafficType from settings. For shared clients, use second argument. If not provided, use default.
|
|
51
|
+
trafficType: (arguments[0] ? arguments[1] : settings.core.trafficType) || DEFAULT_TRAFFIC_TYPE
|
|
52
|
+
});
|
|
53
|
+
// override client.destroy to remove identity from RUM Agent
|
|
54
|
+
var originalDestroy_1 = client.destroy;
|
|
55
|
+
client.destroy = function () {
|
|
56
|
+
browser_rum_agent_1.SplitRumAgent.removeIdentity({
|
|
57
|
+
key: client.key,
|
|
58
|
+
trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
|
|
59
|
+
});
|
|
60
|
+
return originalDestroy_1.apply(client, arguments);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return client;
|
|
64
|
+
},
|
|
65
|
+
destroy: function () {
|
|
66
|
+
return Promise.all((0, sets_1.setToArray)(clients).map(function (client) { return client.destroy(); }));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
exports.SplitSuite = SplitSuite;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebugLogger = exports.InfoLogger = exports.WarnLogger = exports.ErrorLogger = exports.InLocalStorage = exports.SplitSuite = void 0;
|
|
4
|
+
var browserSuite_1 = require("./browserSuite");
|
|
5
|
+
Object.defineProperty(exports, "SplitSuite", { enumerable: true, get: function () { return browserSuite_1.SplitSuite; } });
|
|
6
|
+
var index_1 = require("@splitsoftware/splitio-commons/cjs/storages/inLocalStorage/index");
|
|
7
|
+
Object.defineProperty(exports, "InLocalStorage", { enumerable: true, get: function () { return index_1.InLocalStorage; } });
|
|
8
|
+
var ErrorLogger_1 = require("@splitsoftware/splitio-commons/cjs/logger/browser/ErrorLogger");
|
|
9
|
+
Object.defineProperty(exports, "ErrorLogger", { enumerable: true, get: function () { return ErrorLogger_1.ErrorLogger; } });
|
|
10
|
+
var WarnLogger_1 = require("@splitsoftware/splitio-commons/cjs/logger/browser/WarnLogger");
|
|
11
|
+
Object.defineProperty(exports, "WarnLogger", { enumerable: true, get: function () { return WarnLogger_1.WarnLogger; } });
|
|
12
|
+
var InfoLogger_1 = require("@splitsoftware/splitio-commons/cjs/logger/browser/InfoLogger");
|
|
13
|
+
Object.defineProperty(exports, "InfoLogger", { enumerable: true, get: function () { return InfoLogger_1.InfoLogger; } });
|
|
14
|
+
var DebugLogger_1 = require("@splitsoftware/splitio-commons/cjs/logger/browser/DebugLogger");
|
|
15
|
+
Object.defineProperty(exports, "DebugLogger", { enumerable: true, get: function () { return DebugLogger_1.DebugLogger; } });
|
package/esm/settings/defaults.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/esm/logger/index';
|
|
2
2
|
import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/esm/utils/constants';
|
|
3
|
-
var packageVersion = '0.10.
|
|
3
|
+
var packageVersion = '0.10.2-rc.0';
|
|
4
4
|
/**
|
|
5
5
|
* In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
|
|
6
6
|
* Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
import { SplitRumAgent } from '@splitsoftware/browser-rum-agent';
|
|
5
|
+
import { SplitFactory } from '../full/splitFactory';
|
|
6
|
+
var DEFAULT_TRAFFIC_TYPE = 'user';
|
|
7
|
+
/**
|
|
8
|
+
* SplitFactory for client-side with RUM Agent.
|
|
9
|
+
*
|
|
10
|
+
* @param config configuration object used to instantiate the Suite
|
|
11
|
+
* @param __updateModules optional function that lets redefine internal SDK modules. Use with
|
|
12
|
+
* caution since, unlike `config`, this param is not validated neither considered part of the public API.
|
|
13
|
+
* @throws Will throw an error if the provided config is invalid.
|
|
14
|
+
*/
|
|
15
|
+
export function SplitSuite(config, __updateModules) {
|
|
16
|
+
var sdk = SplitFactory(config, __updateModules);
|
|
17
|
+
var settings = sdk.settings;
|
|
18
|
+
// Do not setup RUM Agent if not in standalone mode
|
|
19
|
+
if (settings.mode !== STANDALONE_MODE)
|
|
20
|
+
return sdk;
|
|
21
|
+
// Setup RUM Agent
|
|
22
|
+
var agentConfig = SplitRumAgent.__getConfig();
|
|
23
|
+
if (agentConfig.a) {
|
|
24
|
+
settings.log.warn('RUM Agent already setup. The new Suite instance will reset the RUM Agent configuration.');
|
|
25
|
+
}
|
|
26
|
+
agentConfig.log = settings.log;
|
|
27
|
+
SplitRumAgent.removeIdentities(); // reset identities for new Suite
|
|
28
|
+
SplitRumAgent.setup(settings.core.authorizationKey, objectAssign({
|
|
29
|
+
url: settings.urls.events,
|
|
30
|
+
userConsent: settings.userConsent
|
|
31
|
+
}, settings.rumAgent));
|
|
32
|
+
var clients = new _Set();
|
|
33
|
+
// Override UserConsent.setStatus to update RUM Agent consent
|
|
34
|
+
var originalSetStatus = sdk.UserConsent.setStatus;
|
|
35
|
+
sdk.UserConsent.setStatus = function (newStatus) {
|
|
36
|
+
SplitRumAgent.setUserConsent(newStatus);
|
|
37
|
+
return originalSetStatus.apply(this, arguments);
|
|
38
|
+
};
|
|
39
|
+
// Create Suite instance extending SDK
|
|
40
|
+
return objectAssign({}, sdk, {
|
|
41
|
+
client: function () {
|
|
42
|
+
var client = sdk.client.apply(sdk, arguments);
|
|
43
|
+
if (!clients.has(client)) {
|
|
44
|
+
clients.add(client);
|
|
45
|
+
SplitRumAgent.addIdentity({
|
|
46
|
+
key: client.key,
|
|
47
|
+
// For main client, use trafficType from settings. For shared clients, use second argument. If not provided, use default.
|
|
48
|
+
trafficType: (arguments[0] ? arguments[1] : settings.core.trafficType) || DEFAULT_TRAFFIC_TYPE
|
|
49
|
+
});
|
|
50
|
+
// override client.destroy to remove identity from RUM Agent
|
|
51
|
+
var originalDestroy_1 = client.destroy;
|
|
52
|
+
client.destroy = function () {
|
|
53
|
+
SplitRumAgent.removeIdentity({
|
|
54
|
+
key: client.key,
|
|
55
|
+
trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
|
|
56
|
+
});
|
|
57
|
+
return originalDestroy_1.apply(client, arguments);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return client;
|
|
61
|
+
},
|
|
62
|
+
destroy: function () {
|
|
63
|
+
return Promise.all(setToArray(clients).map(function (client) { return client.destroy(); }));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { SplitSuite } from './browserSuite';
|
|
2
|
+
export { InLocalStorage } from '@splitsoftware/splitio-commons/esm/storages/inLocalStorage/index';
|
|
3
|
+
export { ErrorLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/ErrorLogger';
|
|
4
|
+
export { WarnLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/WarnLogger';
|
|
5
|
+
export { InfoLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/InfoLogger';
|
|
6
|
+
export { DebugLogger } from '@splitsoftware/splitio-commons/esm/logger/browser/DebugLogger';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-browserjs",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2-rc.0",
|
|
4
4
|
"description": "Split SDK for JavaScript on Browser",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"src",
|
|
16
16
|
"types",
|
|
17
17
|
"full",
|
|
18
|
-
"scripts/ga-to-split-autorequire.js"
|
|
18
|
+
"scripts/ga-to-split-autorequire.js",
|
|
19
|
+
"suite"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
22
|
"check": "npm run check:lint && npm run check:types && npm run check:version",
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
"build:ga-to-split-autorequire": "terser ./node_modules/@splitsoftware/splitio-commons/src/integrations/ga/autoRequire.js --mangle --output ./scripts/ga-to-split-autorequire.js",
|
|
31
32
|
"test": "npm run test:unit && npm run test:e2e",
|
|
32
33
|
"test:unit": "jest",
|
|
33
|
-
"test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errorCatching && npm run test:e2e-push && npm run test:e2e-gaIntegration && npm run test:e2e-consumer",
|
|
34
|
+
"test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errorCatching && npm run test:e2e-push && npm run test:e2e-gaIntegration && npm run test:e2e-consumer && npm run test:e2e-suite",
|
|
34
35
|
"test:e2e-logger": "karma start karma/e2e.logger.karma.conf.js",
|
|
35
36
|
"test:e2e-offline": "karma start karma/e2e.offline.karma.conf.js",
|
|
36
37
|
"test:e2e-online": "karma start karma/e2e.online.karma.conf.js",
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"test:e2e-push": "karma start karma/e2e.push.karma.conf.js",
|
|
40
41
|
"test:e2e-gaIntegration": "karma start karma/e2e.gaIntegration.karma.conf.js",
|
|
41
42
|
"test:e2e-consumer": "karma start karma/e2e.consumer.karma.conf.js",
|
|
43
|
+
"test:e2e-suite": "karma start karma/e2e.suite.karma.conf.js",
|
|
42
44
|
"pretest-ts-decls": "npm run build:esm && npm run build:cjs && npm link",
|
|
43
45
|
"test-ts-decls": "./scripts/ts-tests.sh",
|
|
44
46
|
"posttest-ts-decls": "npm rm --location=global @splitsoftware/splitio-browserjs && npm install",
|
|
@@ -64,7 +66,8 @@
|
|
|
64
66
|
"bugs": "https://github.com/splitio/javascript-browser-client/issues",
|
|
65
67
|
"homepage": "https://github.com/splitio/javascript-browser-client#readme",
|
|
66
68
|
"dependencies": {
|
|
67
|
-
"@splitsoftware/
|
|
69
|
+
"@splitsoftware/browser-rum-agent": "0.3.2-rc.1",
|
|
70
|
+
"@splitsoftware/splitio-commons": "1.9.2-rc.2",
|
|
68
71
|
"@types/google.analytics": "0.0.40",
|
|
69
72
|
"unfetch": "^4.2.0"
|
|
70
73
|
},
|
package/src/settings/defaults.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/
|
|
|
2
2
|
import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types';
|
|
3
3
|
import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants';
|
|
4
4
|
|
|
5
|
-
const packageVersion = '0.10.
|
|
5
|
+
const packageVersion = '0.10.2-rc.0';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
|
|
5
|
+
import { SplitRumAgent } from '@splitsoftware/browser-rum-agent';
|
|
6
|
+
import { SplitFactory } from '../full/splitFactory';
|
|
7
|
+
import { IBrowserSuiteSettings } from '../../types/splitio';
|
|
8
|
+
|
|
9
|
+
const DEFAULT_TRAFFIC_TYPE = 'user';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SplitFactory for client-side with RUM Agent.
|
|
13
|
+
*
|
|
14
|
+
* @param config configuration object used to instantiate the Suite
|
|
15
|
+
* @param __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
|
+
export function SplitSuite(config: IBrowserSuiteSettings, __updateModules?: (modules: ISdkFactoryParams) => void) {
|
|
20
|
+
const sdk = SplitFactory(config, __updateModules) as any;
|
|
21
|
+
|
|
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: boolean) {
|
|
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
|
+
// For main client, use trafficType from settings. For shared clients, use second argument. If not provided, use default.
|
|
59
|
+
trafficType: (arguments[0] ? arguments[1] : settings.core.trafficType) || DEFAULT_TRAFFIC_TYPE
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// override client.destroy to remove identity from RUM Agent
|
|
63
|
+
const originalDestroy = client.destroy;
|
|
64
|
+
client.destroy = function () {
|
|
65
|
+
SplitRumAgent.removeIdentity({
|
|
66
|
+
key: client.key,
|
|
67
|
+
trafficType: client.trafficType || DEFAULT_TRAFFIC_TYPE
|
|
68
|
+
});
|
|
69
|
+
return originalDestroy.apply(client, arguments);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return client;
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
destroy() {
|
|
77
|
+
return Promise.all(setToArray(clients).map(client => client.destroy()));
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { SplitSuite } from './browserSuite';
|
|
2
|
+
export { InLocalStorage } from '@splitsoftware/splitio-commons/src/storages/inLocalStorage/index';
|
|
3
|
+
export { ErrorLogger } from '@splitsoftware/splitio-commons/src/logger/browser/ErrorLogger';
|
|
4
|
+
export { WarnLogger } from '@splitsoftware/splitio-commons/src/logger/browser/WarnLogger';
|
|
5
|
+
export { InfoLogger } from '@splitsoftware/splitio-commons/src/logger/browser/InfoLogger';
|
|
6
|
+
export { DebugLogger } from '@splitsoftware/splitio-commons/src/logger/browser/DebugLogger';
|
package/types/full/index.d.ts
CHANGED
package/types/index.d.ts
CHANGED
package/types/splitio.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
|
|
4
4
|
|
|
5
5
|
/// <reference types="google.analytics" />
|
|
6
|
+
import { SplitRumAgentConfig } from '@splitsoftware/browser-rum-agent';
|
|
6
7
|
|
|
7
8
|
export as namespace SplitIO;
|
|
8
9
|
export = SplitIO;
|
|
@@ -1021,6 +1022,29 @@ declare namespace SplitIO {
|
|
|
1021
1022
|
pushRetryBackoffBase?: number,
|
|
1022
1023
|
}
|
|
1023
1024
|
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Settings interface for Suite instances created on the browser.
|
|
1027
|
+
* @interface IBrowserSuiteSettings
|
|
1028
|
+
* @extends IBrowserSettings
|
|
1029
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#configuration}
|
|
1030
|
+
*/
|
|
1031
|
+
interface IBrowserSuiteSettings extends IBrowserSettings {
|
|
1032
|
+
core: IBrowserBasicSettings['core'] & {
|
|
1033
|
+
/**
|
|
1034
|
+
* Traffic type of the identity provided to the RUM Agent for event tracking. @see {@link https://help.split.io/hc/en-us/articles/360019916311-Traffic-type}
|
|
1035
|
+
* If no provided, 'user' is used as default.
|
|
1036
|
+
* This does not affect the behavior of the SDK client: even if provided, you still need to specify the traffic type in `client.track()` calls.
|
|
1037
|
+
*
|
|
1038
|
+
* @property {string=} trafficType
|
|
1039
|
+
*/
|
|
1040
|
+
trafficType?: string,
|
|
1041
|
+
},
|
|
1042
|
+
/**
|
|
1043
|
+
* Optional configuration object for the RUM agent.
|
|
1044
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360030898431-Browser-RUM-agent#configuration}
|
|
1045
|
+
*/
|
|
1046
|
+
rumAgent?: SplitRumAgentConfig
|
|
1047
|
+
}
|
|
1024
1048
|
/**
|
|
1025
1049
|
* Settings interface with async storage for SDK instances created on the browser.
|
|
1026
1050
|
* If your storage is synchronous (by defaut we use memory, which is sync) use SplitIO.IBrowserSettings instead.
|
|
@@ -1143,6 +1167,41 @@ declare namespace SplitIO {
|
|
|
1143
1167
|
*/
|
|
1144
1168
|
manager(): IManager
|
|
1145
1169
|
}
|
|
1170
|
+
/**
|
|
1171
|
+
* This represents the interface for the Suite instance, that is an extension of the ISDK interface.
|
|
1172
|
+
* @interface ISuiteSDK
|
|
1173
|
+
* @extends ISDK
|
|
1174
|
+
*/
|
|
1175
|
+
interface ISuiteSDK extends ISDK {
|
|
1176
|
+
/**
|
|
1177
|
+
* Returns the default client instance of the SDK and adds its identity (i.e., user key and traffic type pair) to the RUM agent for event tracking.
|
|
1178
|
+
*
|
|
1179
|
+
* NOTE: if no traffic type is provided in the SDK config, 'user' will be used as default for the RUM Agent.
|
|
1180
|
+
*
|
|
1181
|
+
* @function client
|
|
1182
|
+
* @returns {IClient} The client instance.
|
|
1183
|
+
*/
|
|
1184
|
+
client(): IClient,
|
|
1185
|
+
/**
|
|
1186
|
+
* Returns a shared client of the SDK and adds its identity (i.e., user key and traffic type pair) to the RUM agent for event tracking.
|
|
1187
|
+
*
|
|
1188
|
+
* NOTE: if no traffic type is provided as second argument, 'user' will be used as default for the RUM Agent.
|
|
1189
|
+
*
|
|
1190
|
+
* @function client
|
|
1191
|
+
* @param {SplitKey} key The key for the new client instance.
|
|
1192
|
+
* @param {string=} trafficType The traffic type of the provided key, used to pass an identity to the RUM agent. If not provided, 'user' will be used as default.
|
|
1193
|
+
* @returns {IClient} The client instance.
|
|
1194
|
+
*/
|
|
1195
|
+
client(key: SplitKey, trafficType?: string): IClient
|
|
1196
|
+
/**
|
|
1197
|
+
* Destroys all client instances and remove identities from the RUM agent to stop tracking events for them.
|
|
1198
|
+
* This method will flush any pending impressions and events, and stop the synchronization of feature flag definitions with the backend.
|
|
1199
|
+
*
|
|
1200
|
+
* @function destroy
|
|
1201
|
+
* @returns {Promise<void>} A promise that resolves once the client is destroyed.
|
|
1202
|
+
*/
|
|
1203
|
+
destroy(): Promise<void>
|
|
1204
|
+
}
|
|
1146
1205
|
/**
|
|
1147
1206
|
* This represents the interface for the SDK instance with asynchronous storage and client-side API,
|
|
1148
1207
|
* i.e., where client instances have a bound user key.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Declaration file for JavaScript Browser 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 Suite factory function.
|
|
10
|
+
*
|
|
11
|
+
* The settings parameter should be an object that complies with the SplitIO.IBrowserSuiteSettings.
|
|
12
|
+
* For more information read the corresponding article: @see {@link https://help.split.io/hc/en-us/articles/360030898431-Browser-RUM-agent#sdk-integration}
|
|
13
|
+
*/
|
|
14
|
+
export function SplitSuite(settings: SplitIO.IBrowserSuiteSettings): SplitIO.ISuiteSDK;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Persistent storage based on the LocalStorage Web API for browsers.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#storage}
|
|
20
|
+
*/
|
|
21
|
+
export function InLocalStorage(options?: SplitIO.InLocalStorageOptions): SplitIO.StorageSyncFactory;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Creates a logger instance that enables descriptive log messages with DEBUG log level when passed in the factory settings.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}
|
|
27
|
+
*/
|
|
28
|
+
export function DebugLogger(): SplitIO.ILogger;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Creates a logger instance that enables descriptive log messages with INFO log level when passed in the factory settings.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}
|
|
34
|
+
*/
|
|
35
|
+
export function InfoLogger(): SplitIO.ILogger;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a logger instance that enables descriptive log messages with WARN log level when passed in the factory settings.
|
|
39
|
+
*
|
|
40
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}
|
|
41
|
+
*/
|
|
42
|
+
export function WarnLogger(): SplitIO.ILogger;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates a logger instance that enables descriptive log messages with ERROR log level when passed in the factory settings.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#logging}
|
|
48
|
+
*/
|
|
49
|
+
export function ErrorLogger(): SplitIO.ILogger;
|
|
50
|
+
}
|