Skip to content

Commit a2fcb6d

Browse files
committed
Add Install, Configure, Verify, and Support Notes section for js integration docs
1 parent 63e2ba6 commit a2fcb6d

File tree

3 files changed

+555
-463
lines changed

3 files changed

+555
-463
lines changed

docs/platforms/javascript/common/configuration/integrations/launchdarkly.mdx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ This integration only works inside a browser environment.
2929

3030
</Alert>
3131

32-
The [LaunchDarkly](https://launchdarkly.com/) integration tracks feature flag evaluations produced by the LaunchDarkly SDK. These evaluations are held in memory and sent to Sentry for review and analysis if an error occurs. **At the moment, we only support boolean flag evaluations.**
32+
The [LaunchDarkly](https://launchdarkly.com/) integration tracks feature flag evaluations produced by the LaunchDarkly SDK. These evaluations are held in memory, and in the event an error occurs, sent to Sentry for review and analysis.
3333

34-
_Import name: `Sentry.launchDarklyIntegration` and `Sentry.buildLaunchDarklyFlagUsedHandler`_
34+
_Import names: `Sentry.launchDarklyIntegration` and `Sentry.buildLaunchDarklyFlagUsedHandler`_
35+
36+
## Install
37+
38+
Install [`@sentry/browser`](https://www.npmjs.com/package/@sentry/browser) and [`launchdarkly-js-client-sdk`](https://www.npmjs.com/package/launchdarkly-js-client-sdk) from npm.
39+
40+
## Configure
3541

3642
```JavaScript
3743
import * as Sentry from '@sentry/browser';
@@ -47,11 +53,29 @@ const ldClient = LaunchDarkly.initialize(
4753
{kind: 'user', key: 'my-user-context-key'},
4854
{inspectors: [Sentry.buildLaunchDarklyFlagUsedHandler()]}
4955
);
50-
const flagVal = ldClient.variation('my-flag', false); // evaluates a flag
5156
```
5257

53-
Learn more about the LaunchDarkly SDK at https://docs.launchdarkly.com/sdk/client-side/javascript.
54-
At the moment, **we do not officially support framework-specific LaunchDarkly
55-
SDKs.** However, you may reuse this setup code for React and client-side Node.js.
58+
## Verify
59+
60+
The integration is tested by evaluating a feature flag with your LaunchDarkly SDK before capturing an exception.
61+
62+
```JavaScript
63+
import * as Sentry from '@sentry/browser';
64+
import * as LaunchDarkly from 'launchdarkly-js-client-sdk';
65+
66+
// Evaluate a flag with a default value, with the ldClient from the Configure step.
67+
// You may have to wait for your client to initialize before doing this.
68+
ldClient?.variation("hello", false);
69+
70+
Sentry.captureException(Exception("Something went wrong!"))
71+
```
72+
73+
Visit the Sentry website and confirm that your error event has recorded the feature flag "hello" and its value "false". For a full end-to-end test, you must create the flag and a targeting rule in LaunchDarkly.
74+
Learn more about the LaunchDarkly SDK [here](https://docs.launchdarkly.com/sdk/client-side/javascript).
75+
76+
## Support Notes
77+
**At the moment, we only support boolean flag evaluations.**
78+
79+
We do not officially support framework-specific LaunchDarkly SDKs. However, you may reuse the setup code for [React](https://www.npmjs.com/package/launchdarkly-react-client-sdk) and [client-side Node.js](https://www.npmjs.com/package/launchdarkly-node-client-sdk).
5680
5781
<PlatformContent includePath="feature-flags/next-steps" />

docs/platforms/javascript/common/configuration/integrations/openfeature.mdx

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ This integration only works inside a browser environment.
2929

3030
</Alert>
3131

32+
The [OpenFeature](https://openfeature.dev/) integration tracks feature flag evaluations produced by the OpenFeature SDK. These evaluations are held in memory, and in the event an error occurs, sent to Sentry for review and analysis.
33+
3234
_Import name: `Sentry.openFeatureIntegration` and `Sentry.OpenFeatureIntegrationHook`_
3335

34-
The [OpenFeature](https://openfeature.dev/) integration tracks feature flag evaluations produced by the OpenFeature SDK. These evaluations are held in memory and sent to Sentry for review and analysis if an error occurs. **At the moment, we only support boolean flag evaluations.**
36+
## Install
37+
38+
Install [`@sentry/browser`](https://www.npmjs.com/package/@sentry/browser) and [`@openfeature/web-sdk`](https://www.npmjs.com/package/@openfeature/web-sdk) from npm.
39+
40+
## Configure
3541

3642
```JavaScript
3743
import * as Sentry from '@sentry/browser';
@@ -42,13 +48,37 @@ Sentry.init({
4248
integrations: [Sentry.openFeatureIntegration()]
4349
});
4450

51+
OpenFeature.setProvider(new MyProviderOfChoice());
52+
53+
// Option 1: track all OpenFeature evaluations.
54+
OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook());
55+
56+
// Option 2: only track evaluations by a specific client.
4557
const client = OpenFeature.getClient();
4658
client.addHooks(new Sentry.OpenFeatureIntegrationHook());
59+
```
60+
61+
Learn more about OpenFeature providers [here](https://openfeature.dev/docs/reference/concepts/provider). You can use the InMemoryProvider to quickly verify the integration.
62+
63+
## Verify
4764

48-
// Evaluating flags will record the result on the Sentry client.
49-
const result = client.getBooleanValue('my-flag', false);
65+
The integration is tested by evaluating a feature flag with your OpenFeature SDK before capturing an exception.
66+
67+
```JavaScript
68+
import * as Sentry from '@sentry/browser';
69+
import { OpenFeature } from '@openfeature/web-sdk';
70+
71+
// Evaluate a flag with a default value. If you added the hook to a client in
72+
// the Configure step, make sure to use the same client here.
73+
const client = OpenFeature.getClient();
74+
const result = client.getBooleanValue('hello', false);
75+
76+
Sentry.captureException(Exception("Something went wrong!"))
5077
```
5178

52-
Learn more about the [OpenFeature SDK](https://github.com/open-feature/js-sdk/tree/main).
79+
Visit the Sentry website and confirm that your error event has recorded the feature flag "hello" and its value "false". Learn more about the OpenFeature SDK at https://github.com/open-feature/js-sdk/tree/main.
80+
81+
## Support Notes
82+
**At the moment, we only support boolean flag evaluations.**
5383

5484
<PlatformContent includePath="feature-flags/next-steps" />

0 commit comments

Comments
 (0)