|
| 1 | +# LaunchDarkly OpenFeature provider for the Server-Side SDK for Node.js |
| 2 | + |
| 3 | +This provider allows for using LaunchDarkly with the OpenFeature Node SDK. |
| 4 | + |
| 5 | +This provider is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications. |
| 6 | + |
| 7 | +# LaunchDarkly overview |
| 8 | + |
| 9 | +[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today! |
| 10 | + |
| 11 | +[](https://twitter.com/intent/follow?screen_name=launchdarkly) |
| 12 | + |
| 13 | +## Supported Node versions |
| 14 | + |
| 15 | +This version of the LaunchDarkly OpenFeature provider is compatible with Node.js versions 16 and above. |
| 16 | + |
| 17 | +## Getting started |
| 18 | + |
| 19 | +### Installation |
| 20 | + |
| 21 | +``` |
| 22 | +npm install @openfeature/nodejs-sdk |
| 23 | +npm install launchdarkly-node-server-sdk |
| 24 | +npm install @launchdarkly/open-feature-node |
| 25 | +``` |
| 26 | + |
| 27 | +### Usage |
| 28 | +``` |
| 29 | +import { OpenFeature } from '@openfeature/nodejs-sdk'; |
| 30 | +import { init } from 'launchdarkly-node-server-sdk'; |
| 31 | +import { LaunchDarklyProvider } from 'open-feature-node'; |
| 32 | +
|
| 33 | +
|
| 34 | +const ldClient = init('<your-sdk-key>'); |
| 35 | +await ldClient.waitForInitialization(); |
| 36 | +OpenFeature.setProvider(new LaunchDarklyProvider(ldClient)); |
| 37 | +const client = OpenFeature.getClient(); |
| 38 | +const value = await client.getBooleanValue('app-enabled', false, {targetingKey: 'my-key'}); |
| 39 | +``` |
| 40 | + |
| 41 | +Refer to the [SDK reference guide](https://docs.launchdarkly.com/sdk/server-side/node-js) for instructions on getting started with using the SDK. |
| 42 | + |
| 43 | +## OpenFeature Specific Considerations |
| 44 | + |
| 45 | +When evaluating an `LDUser` with the LaunchDarkly Node SDK a string `key` attribute would normally be required. When using OpenFeature the `targetingKey` attribute should be used instead of `key`. If a `key` attribute is provided in the `EvaluationContext`, then it will be discarded in favor of `targetingKey`. If a `targetingKey` is not provided, or if the `EvaluationContext` is omitted entirely, then the `defaultValue` will be returned from OpenFeature evaluation methods. |
| 46 | + |
| 47 | +Other fields normally included in an `LDUser` may be added to the `EvaluationContext`. Any `custom` attributes can |
| 48 | +be added to the top level of the evaluation context, and they will operate as if they were `custom` attributes on an `LDUser`. Attributes which are typically top level on an `LDUser` should be of the same types that are specified for |
| 49 | +an `LDUser` or they will not operate as intended. |
| 50 | + |
| 51 | +If a top level `custom` attribute is defined on the `EvaluationContext`, then that will be a `custom` attribute inside `custom` for an `LDUser`. |
| 52 | + |
| 53 | +If a custom attribute is provided, whose value is an object, then that attribute will be discarded. |
| 54 | + |
| 55 | +## Learn more |
| 56 | + |
| 57 | +Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/node-js). |
| 58 | + |
| 59 | +The authoritative description of all properties and methods is in the [TypeScript documentation](https://launchdarkly.github.io/node-server-sdk/). |
| 60 | + |
| 61 | +## Contributing |
| 62 | + |
| 63 | +We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK. |
| 64 | + |
| 65 | +## About LaunchDarkly |
| 66 | + |
| 67 | +* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can: |
| 68 | + * Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases. |
| 69 | + * Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?). |
| 70 | + * Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file. |
| 71 | + * Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline. |
| 72 | +* LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list. |
| 73 | +* Explore LaunchDarkly |
| 74 | + * [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information |
| 75 | + * [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides |
| 76 | + * [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation |
| 77 | + * [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates |
0 commit comments