How to use launchdarkly-js-sdk-common - 6 common examples

To help you get started, we’ve selected a few launchdarkly-js-sdk-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github launchdarkly / js-client-sdk / packages / launchdarkly-js-sdk-common / test-types.ts View on Github external
// 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,
github launchdarkly / js-client-sdk / packages / launchdarkly-js-sdk-common / test-types.ts View on Github external
// 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',
github launchdarkly / js-client-sdk / packages / launchdarkly-js-sdk-common / test-types.ts View on Github external
// 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,
github launchdarkly / js-client-sdk / src / index.js View on Github external
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;
github launchdarkly / js-client-sdk / src / index.js View on Github external
function deprecatedInitialize(env, user, options = {}) {
  console && console.warn && console.warn(common.messages.deprecated('default export', 'named LDClient export'));
  return initialize(env, user, options);
}
github launchdarkly / js-client-sdk / src / GoalManager.js View on Github external
.catch(err => {
      clientVars.emitter.maybeReportError(
        new common.errors.LDUnexpectedResponseError('Error fetching goals: ' + (err && err.message) ? err.message : err)
      );
      readyCallback();
    });

launchdarkly-js-sdk-common

LaunchDarkly SDK for JavaScript - common code

Apache-2.0
Latest version published 1 month ago

Package Health Score

85 / 100
Full package analysis