How to use the launchdarkly-node-server-sdk.init function in launchdarkly-node-server-sdk

To help you get started, we’ve selected a few launchdarkly-node-server-sdk 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 / node-server-sdk / test-types.ts View on Github external
email: 'test@example.com',
  avatar: 'http://avatar.url',
  ip: '1.1.1.1',
  country: 'us',
  anonymous: true,
  custom: {
    'a': 's',
    'b': true,
    'c': 3,
    'd': [ 'x', 'y' ],
    'e': [ true, false ],
    'f': [ 1, 2 ]
  },
  privateAttributeNames: [ 'name', 'email' ]
};
var client: ld.LDClient = ld.init('sdk-key', allOptions);

client.identify(user);
client.track('key', user);
client.track('key', user, { ok: 1 });
client.track('key', user, null, 1.5);

// evaluation methods with callbacks
client.variation('key', user, false, (value: ld.LDFlagValue) => { });
client.variation('key', user, 2, (value: ld.LDFlagValue) => { });
client.variation('key', user, 'default', (value: ld.LDFlagValue) => { });
client.variationDetail('key', user, 'default', (detail: ld.LDEvaluationDetail) => {
  var detailValue: ld.LDFlagValue = detail.value;
  var detailIndex: number | undefined = detail.variationIndex;
  var detailReason: ld.LDEvaluationReason = detail.reason;  
});
client.allFlags(user, (flagSet: ld.LDFlagSet) =>  {
github meetup / meetup-web-platform / packages / mwp-app-route-plugin / src / index.js View on Github external
export function register(
	server: HapiServer,
	options: {
		languageRenderers: { [string]: LanguageRenderer },
		ldkey?: string,
	}
): Promise {
	server.route(getRoute(options.languageRenderers));

	const ldClient = LaunchDarkly.init(options.ldkey || LAUNCH_DARKLY_SDK_KEY, {
		offline: process.env.NODE_ENV === 'test',
	});
	server.expose('getFlags', (user: LaunchDarklyUser) => {
		return ldClient.allFlagsState(user).then(
			state => state.allValues(),
			err => {
				server.app.logger.error({
					err,
					member: user,
				});
				return {}; // return empty flags on error
			}
		);
	});
	// set up launchdarkly instance before continuing
	server.events.on('stop', ldClient.close);

launchdarkly-node-server-sdk

LaunchDarkly Server-Side SDK for Node.js

Apache-2.0
Latest version published 8 months ago

Package Health Score

58 / 100
Full package analysis