From c7ea03cad39e0efa05fb9d160e9f3fe5381d61e7 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 17 Aug 2026 09:03:50 +0000 Subject: [PATCH] fix: align README with env-var setup and restore missing client-side ID guard Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- README.md | 15 +++++++-------- index.js | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 11e6a7f..f5aec52 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,15 @@ For a sample application demonstrating how to use LaunchDarkly in *server-side* ## Build instructions -1. Install the LaunchDarkly Client-Side Node.js SDK by running `npm install` +1. Set the environment variable `LAUNCHDARKLY_CLIENT_SIDE_ID` to your LaunchDarkly client-side ID. If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, set `LAUNCHDARKLY_FLAG_KEY` to the flag key; otherwise, a boolean flag of `sample-feature` will be assumed. -2. Edit `index.js` and set the value of `environmentId` to your LaunchDarkly client-side ID. If there is an existing boolean feature flag in your LaunchDarkly project that you want to evaluate, set `featureFlagKey` to the flag key. + ```bash + export LAUNCHDARKLY_CLIENT_SIDE_ID="1234567890abcdef" + export LAUNCHDARKLY_FLAG_KEY="my-boolean-flag" + ``` -```js - const environmentId = "1234567890abcdef"; - - const featureFlagKey = "my-flag"; -``` +2. Install the LaunchDarkly Client-Side Node.js SDK by running `npm install` 3. Run `node index.js` -You should see the message `"Feature flag '' is for this user"`. +You should receive the message "The '' feature flag evaluates to .". The application will run continuously and react to the flag changes in LaunchDarkly. diff --git a/index.js b/index.js index 70069da..d5de2e8 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ const LaunchDarkly = require('launchdarkly-node-client-sdk'); // Set clientSideId to your LaunchDarkly client-side ID. -const clientSideId = process.env.LAUNCHDARKLY_CLIENT_SIDE_ID ?? 'your-client-side-id'; +const clientSideId = process.env.LAUNCHDARKLY_CLIENT_SIDE_ID ?? ''; // Set featureFlagKey to the feature flag key you want to evaluate. const featureFlagKey = process.env.LAUNCHDARKLY_FLAG_KEY ?? 'sample-feature';