-
Notifications
You must be signed in to change notification settings - Fork 5
/
sdk.js
36 lines (31 loc) · 1 KB
/
sdk.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// SDK initialization and factory instanciation.
//
const SplitFactory = require('@splitsoftware/splitio').SplitFactory;
const utils = require('./utils/utils');
const getSplitFactory = (settings) => {
const logLevel = settings.logLevel;
delete settings.logLevel;
let impressionsMode;
let telemetry;
const factory = SplitFactory(settings, (modules) => {
// Do not try this at home.
modules.settings.sdkVersion = modules.settings.version;
modules.settings.version = `evaluator-${utils.getVersion()}`;
impressionsMode = modules.settings.sync.impressionsMode;
const originalStorageFactory = modules.storageFactory;
modules.storageFactory = (config) => {
const storage = originalStorageFactory(config);
telemetry = storage.telemetry;
return storage;
};
});
if (logLevel) {
console.log('Setting log level with', logLevel);
factory.Logger.setLogLevel(logLevel);
}
return { factory, telemetry, impressionsMode };
};
module.exports = {
getSplitFactory,
};