# @adobe/spacecat-shared-launchdarkly-client

> Shared modules of the Spacecat Services - LaunchDarkly Client

Latest version **1.3.1** (published 2026-07-13) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @adobe/spacecat-shared-launchdarkly-client
pnpm add @adobe/spacecat-shared-launchdarkly-client
yarn add @adobe/spacecat-shared-launchdarkly-client
bun add @adobe/spacecat-shared-launchdarkly-client
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2026-07-13 |
| First published | 2026-02-04 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.0.0 <25.0.0 |
| Dependencies | 3 |
| Unpacked size | 74.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 4 |
| Maintainers | marbec, tripod, garthdb, lazd, adobe-admin, patrickfulton, trieloff, krisnye, dcpfsdk, natebaldwin, devongovett, aspro83, symanovi, dpfister, stefan-guggisberg, rofe, kptdobe, adobehalls, fullcolorcoder, djaeggi, dylandepass, mhaack, amol-anand, stopp-adobe, namarora, doten, duh_schmidt, asthabh23, zdahbi, tuicu, fmeschbe |

## Links

- npm: https://www.npmjs.com/package/@adobe/spacecat-shared-launchdarkly-client
- Repository: https://github.com/adobe/spacecat-shared
- Homepage: https://github.com/adobe/spacecat-shared#readme
- Issues: https://github.com/adobe/spacecat-shared/issues
- npm.io page: https://npm.io/package/@adobe/spacecat-shared-launchdarkly-client

## Dependencies (3)

- [@adobe/helix-universal](https://npm.io/package/@adobe/helix-universal.md) 5.4.2
- [@adobe/spacecat-shared-utils](https://npm.io/package/@adobe/spacecat-shared-utils.md) 1.81.1
- [@launchdarkly/node-server-sdk](https://npm.io/package/@launchdarkly/node-server-sdk.md) ^9.11.2

## Recent versions

- 1.3.1 (latest) — 2026-07-13
- 1.3.0 — 2026-06-15
- 1.2.2 — 2026-05-30
- 1.2.1 — 2026-05-29
- 1.2.0 — 2026-05-21
- 1.1.2 — 2026-05-14
- 1.1.1 — 2026-04-09
- 1.1.0 — 2026-04-08
- 1.0.6 — 2026-04-06
- 1.0.5 — 2026-04-06
- 1.0.4 — 2026-03-21
- 1.0.3 — 2026-03-07
- 1.0.2 — 2026-03-02
- 1.0.1 — 2026-02-05
- 1.0.0 — 2026-02-04

## README

# Spacecat Shared - LaunchDarkly Client

A lightweight LaunchDarkly client wrapper for checking feature flags in SpaceCat services.

## Installation

```bash
npm install @adobe/spacecat-shared-launchdarkly-client
```

## Usage

### Basic Example

```javascript
import { LaunchDarklyClient } from '@adobe/spacecat-shared-launchdarkly-client';

// Create client from Universal context
const ldClient = LaunchDarklyClient.createFrom(context);

// Check if flag is enabled for an IMS organization
const imsOrgId = '855422996904EB9F0A495F9B@AdobeOrg';
const isEnabled = await ldClient.isFlagEnabledForIMSOrg('FT_LLMO-2817', imsOrgId);

if (isEnabled) {
  // Feature is enabled for this organization
  console.log('Feature enabled');
} else {
  // Feature is disabled
  console.log('Feature disabled');
}
```

### In a Request Handler

```javascript
import { LaunchDarklyClient } from '@adobe/spacecat-shared-launchdarkly-client';

export default async function handler(request, context) {
  // Initialize client once (reuse across requests)
  const ldClient = LaunchDarklyClient.createFrom(context);
  
  // Get IMS org from request
  const imsOrgId = request.headers.get('x-ims-org-id');
  
  // Check feature flag
  const isEnabled = await ldClient.isFlagEnabledForIMSOrg(
    'FT_LLMO-2817',
    imsOrgId
  );
  
  if (isEnabled) {
    // New feature logic
    return executeNewFeature(request);
  }
  
  // Default/legacy logic
  return executeLegacyFeature(request);
}
```

### With Custom User Key (Optional)

```javascript
const ldClient = LaunchDarklyClient.createFrom(context);

// Provide a user key for tracking (defaults to 'anonymous')
const isEnabled = await ldClient.isFlagEnabledForIMSOrg(
  'FT_LLMO-2817',
  imsOrgId,
  'user-123' // optional user key for analytics
);
```

## API

### `isFlagEnabledForIMSOrg(flagKey, imsOrgId, userKey?)`

Checks if a feature flag is enabled for a specific IMS organization.

**Parameters:**
- `flagKey` (string, required) - The LaunchDarkly feature flag key
- `imsOrgId` (string, required) - The IMS organization ID (e.g., `"855422996904EB9F0A495F9A@AdobeOrg"`)
- `userKey` (string, optional) - User identifier for tracking (defaults to `"anonymous"`)

**Returns:** `Promise<boolean>` - `true` if flag is enabled, `false` otherwise

## Environment Variables

Set the following environment variable:

```bash
export LAUNCHDARKLY_SDK_KEY="sdk-your-server-side-key-here"
```

**Note:** Use a **server-side SDK key** (starts with `sdk-`), not a client-side ID.

## LaunchDarkly Configuration

In your LaunchDarkly dashboard, configure targeting rules using:
- **Attribute:** `organization identityProviderId`
- **Operator:** `is one of`
- **Values:** List of IMS org IDs

## Testing

```bash
npm test
```

## License

Apache-2.0

## Additional Information

- **Repository**: [GitHub](https://github.com/adobe/spacecat-shared)
- **Issues**: [GitHub Issues](https://github.com/adobe/spacecat-shared/issues)
- **LaunchDarkly Docs**: [Node.js SDK](https://docs.launchdarkly.com/sdk/server-side/node-js)

---
_Source: https://npm.io/package/@adobe/spacecat-shared-launchdarkly-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
