Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
},
storage: {
type: 'REDIS'
}
};
// For browser
browserSettings = {
core: {
authorizationKey: 'another-key',
key: 'customer-key'
}
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);
// The settings values the SDK expose.
const instantiatedSettingsCore: {
authorizationKey: string,
key: SplitIO.SplitKey,
trafficType: string,
labelsEnabled: boolean,
IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
prefix: string,
options: Object,
// It can have any of the storages.
authorizationKey: 'key'
},
storage: {
type: 'REDIS'
}
};
// For browser
browserSettings = {
core: {
authorizationKey: 'another-key',
key: 'customer-key'
}
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);
// The settings values the SDK expose.
const instantiatedSettingsCore: {
authorizationKey: string,
key: SplitIO.SplitKey,
trafficType: string,
labelsEnabled: boolean,
IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
prefix: string,
options: Object,
core: {
authorizationKey: 'key'
},
storage: {
type: 'REDIS'
}
};
// For browser
browserSettings = {
core: {
authorizationKey: 'another-key',
key: 'customer-key'
}
};
// With sync settings should return ISDK, if settings have async storage it should return IAsyncSDK
SDK = SplitFactory(browserSettings);
SDK = SplitFactory(nodeSettings);
AsyncSDK = SplitFactory(asyncSettings);
// The settings values the SDK expose.
const instantiatedSettingsCore: {
authorizationKey: string,
key: SplitIO.SplitKey,
trafficType: string,
labelsEnabled: boolean,
IPAddressesEnabled: boolean
} = SDK.settings.core;
const instantiatedSettingsMode: ('standalone' | 'consumer') = SDK.settings.mode;
const instantiatedSettingsScheduler: {[key: string]: number} = SDK.settings.scheduler;
const instantiatedSettingsStartup: {[key: string]: number} = SDK.settings.startup;
const instantiatedSettingsStorage: {
prefix: string,
const initializeClient = (): {
client: SplitIO.IClient;
manager: SplitIO.IManager;
} => {
if (!adapterState.splitioSettings) {
throw Error(
'cannot initialize SplitIo without configured settings, call configure() first'
);
}
const sdk = SplitFactory(adapterState.splitioSettings); // eslint-disable-line new-cap
return {
client: sdk.client(),
manager: sdk.manager(),
};
};
logger.info(`SDK_URL: ${process.env.SDK_URL}`);
logger.info(`EVENTS_URL: ${process.env.EVENTS_URL}`);
if (process.env.SPLITIO_IMPRESSION_LISTENER) {
settings = merge({}, settings, {
impressionListener: {
logImpression,
},
});
context.start();
logger.info(`IMPRESSION_LISTENER: ${process.env.SPLITIO_IMPRESSION_LISTENER}`);
}
let isClientReady = false;
// Our SDK factory instance.
const factory = SplitFactory(settings);
// Our client.
const client = factory.client();
// Our manager.
const manager = factory.manager();
// Returns true if the client is ready.
const isReady = () => isClientReady;
client.on(client.Event.SDK_READY, () => {
logger.info(`ON SDK_READY, IS CLIENT READY?: ${isClientReady}`);
return isClientReady === true;
});
module.exports = {
factory,
client,
manager,