Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@launchdarkly/js-server-sdk-common

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@launchdarkly/js-server-sdk-common

LaunchDarkly Server SDK for JavaScript - common code

  • 2.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
642K
decreased by-3.79%
Maintainers
1
Weekly downloads
 
Created

What is @launchdarkly/js-server-sdk-common?

@launchdarkly/js-server-sdk-common is a common library for LaunchDarkly's JavaScript server-side SDKs. It provides core functionality for feature flag evaluation, user targeting, and other feature management capabilities.

What are @launchdarkly/js-server-sdk-common's main functionalities?

Feature Flag Evaluation

This feature allows you to evaluate feature flags for a given user. The code sample demonstrates how to initialize the client, wait for it to be ready, and then evaluate a feature flag for a specific user.

const { LDClient } = require('@launchdarkly/js-server-sdk-common');
const client = new LDClient('YOUR_SDK_KEY');

client.on('ready', () => {
  const user = { key: 'user123' };
  const showFeature = client.variation('your-feature-flag-key', user, false);
  console.log(`Feature flag value: ${showFeature}`);
});

User Targeting

This feature allows you to target specific users based on their attributes. The code sample shows how to include user attributes like email in the evaluation process.

const { LDClient } = require('@launchdarkly/js-server-sdk-common');
const client = new LDClient('YOUR_SDK_KEY');

client.on('ready', () => {
  const user = { key: 'user123', email: 'user@example.com' };
  const showFeature = client.variation('your-feature-flag-key', user, false);
  console.log(`Feature flag value for user: ${showFeature}`);
});

Event Tracking

This feature allows you to track custom events for analytics and reporting. The code sample demonstrates how to track a custom event for a specific user.

const { LDClient } = require('@launchdarkly/js-server-sdk-common');
const client = new LDClient('YOUR_SDK_KEY');

client.on('ready', () => {
  const user = { key: 'user123' };
  client.track('custom-event', user, { key: 'value' });
  console.log('Custom event tracked');
});

Other packages similar to @launchdarkly/js-server-sdk-common

Keywords

FAQs

Package last updated on 16 Apr 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc