🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

launchdarkly-js-client-sdk

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

launchdarkly-js-client-sdk

LaunchDarkly SDK for JavaScript

2.12.1
Source
npm
Version published
Weekly downloads
1.2M
3.17%
Maintainers
1
Weekly downloads
 
Created

What is launchdarkly-js-client-sdk?

The launchdarkly-js-client-sdk is a JavaScript SDK for LaunchDarkly, a feature management platform that allows developers to control the release of features to users. This SDK enables you to manage feature flags, perform A/B testing, and roll out new features gradually.

What are launchdarkly-js-client-sdk's main functionalities?

Initialize the client

This code initializes the LaunchDarkly client with your environment key and a user object. The client is ready to be used once the 'ready' event is fired.

const LDClient = require('launchdarkly-js-client-sdk');
const client = LDClient.initialize('YOUR_ENVIRONMENT_KEY', { key: 'user_key' });
client.on('ready', () => {
  console.log('LaunchDarkly client is ready');
});

Evaluate feature flags

This code evaluates a feature flag and returns its value. If the feature flag is enabled, it will log 'Feature is enabled'; otherwise, it will log 'Feature is disabled'.

client.on('ready', () => {
  const showFeature = client.variation('your-feature-flag-key', false);
  if (showFeature) {
    console.log('Feature is enabled');
  } else {
    console.log('Feature is disabled');
  }
});

Track custom events

This code tracks a custom event with a specified key and optional data. This can be useful for analytics and monitoring user interactions.

client.track('custom-event-key', { customData: 'value' });

Identify users

This code identifies a new user with a unique key and optional attributes. This is useful for targeting specific users with feature flags.

client.identify({ key: 'new_user_key', name: 'New User' }).then(() => {
  console.log('User identified');
});

Other packages similar to launchdarkly-js-client-sdk

Keywords

launchdarkly

FAQs

Package last updated on 28 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts