Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This file exists only so that we can run the TypeScript compiler in the CI build
// to validate our typings.d.ts file. The code will not actually be run.
import * as ld from 'launchdarkly-js-sdk-common';
const ver: string = ld.version;
const logger: ld.LDLogger = ld.createConsoleLogger("info");
const loggerWithPrefix: ld.LDLogger = ld.createConsoleLogger("info", "prefix");
const userWithKeyOnly: ld.LDUser = { key: 'user' };
const anonUserWithNoKey: ld.LDUser = { anonymous: true };
const user: ld.LDUser = {
key: 'user',
secondary: 'otherkey',
name: 'name',
firstName: 'first',
lastName: 'last',
email: 'test@example.com',
avatar: 'http://avatar.url',
ip: '1.1.1.1',
country: 'us',
anonymous: true,
custom: {
'a': 's',
'b': true,
// This file exists only so that we can run the TypeScript compiler in the CI build
// to validate our typings.d.ts file. The code will not actually be run.
import * as ld from 'launchdarkly-js-sdk-common';
const ver: string = ld.version;
const logger: ld.LDLogger = ld.createConsoleLogger("info");
const loggerWithPrefix: ld.LDLogger = ld.createConsoleLogger("info", "prefix");
const userWithKeyOnly: ld.LDUser = { key: 'user' };
const anonUserWithNoKey: ld.LDUser = { anonymous: true };
const user: ld.LDUser = {
key: 'user',
secondary: 'otherkey',
name: 'name',
firstName: 'first',
lastName: 'last',
email: 'test@example.com',
avatar: 'http://avatar.url',
ip: '1.1.1.1',
country: 'us',
anonymous: true,
custom: {
'a': 's',
// This file exists only so that we can run the TypeScript compiler in the CI build
// to validate our typings.d.ts file. The code will not actually be run.
import * as ld from 'launchdarkly-js-sdk-common';
const ver: string = ld.version;
const logger: ld.LDLogger = ld.createConsoleLogger("info");
const loggerWithPrefix: ld.LDLogger = ld.createConsoleLogger("info", "prefix");
const userWithKeyOnly: ld.LDUser = { key: 'user' };
const anonUserWithNoKey: ld.LDUser = { anonymous: true };
const user: ld.LDUser = {
key: 'user',
secondary: 'otherkey',
name: 'name',
firstName: 'first',
lastName: 'last',
email: 'test@example.com',
avatar: 'http://avatar.url',
ip: '1.1.1.1',
country: 'us',
anonymous: true,
export function initialize(env, user, options = {}) {
const platform = browserPlatform(options);
const clientVars = common.initialize(env, user, options, platform, extraOptionDefs);
const client = clientVars.client;
const validatedOptions = clientVars.options;
const emitter = clientVars.emitter;
const goalsPromise = new Promise(resolve => {
const onGoals = emitter.on(goalsEvent, () => {
emitter.off(goalsEvent, onGoals);
resolve();
});
});
client.waitUntilGoalsReady = () => goalsPromise;
if (validatedOptions.fetchGoals) {
const goalManager = GoalManager(clientVars, () => emitter.emit(goalsEvent));
platform.customEventFilter = goalManager.goalKeyExists;
function deprecatedInitialize(env, user, options = {}) {
console && console.warn && console.warn(common.messages.deprecated('default export', 'named LDClient export'));
return initialize(env, user, options);
}
.catch(err => {
clientVars.emitter.maybeReportError(
new common.errors.LDUnexpectedResponseError('Error fetching goals: ' + (err && err.message) ? err.message : err)
);
readyCallback();
});