-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(flags): add browser JS integration docs for Launchdarkly #11827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
docs/platforms/javascript/common/configuration/integrations/launchdarkly.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: LaunchDarkly | ||
description: "Attaches recent LaunchDarkly feature flag evaluations to error event context." | ||
notSupported: | ||
- javascript.aws-lambda | ||
- javascript.azure-functions | ||
- javascript.bun | ||
- javascript.capacitor | ||
- javascript.cloudflare | ||
- javascript.connect | ||
- javascript.cordova | ||
- javascript.deno | ||
- javascript.electron | ||
- javascript.express | ||
- javascript.fastify | ||
- javascript.gcp-functions | ||
- javascript.hapi | ||
- javascript.koa | ||
- javascript.nestjs | ||
- javascript.nodejs | ||
- javascript.wasm | ||
--- | ||
|
||
<Alert level="info"> | ||
|
||
This integration only works inside a browser environment. | ||
|
||
</Alert> | ||
|
||
_Import name: `Sentry.launchDarklyIntegration` and `Sentry.buildLaunchDarklyFlagUsedHandler`_ | ||
|
||
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. **At the moment, we only support boolean flag evaluations.** | ||
|
||
```JavaScript | ||
import * as Sentry from '@sentry/browser'; | ||
import * as LaunchDarkly from 'launchdarkly-js-client-sdk'; | ||
|
||
Sentry.init({integrations: [Sentry.launchDarklyIntegration()]}); | ||
|
||
const ldClient = LaunchDarkly.initialize( | ||
'my-client-ID', | ||
{kind: 'user', key: 'my-user-context-key'}, | ||
{inspectors: [Sentry.buildLaunchDarklyFlagUsedHandler()]} | ||
); | ||
const flagVal = ldClient.variation('my-flag', false); // evaluates a flag | ||
aliu39 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
Learn more about the LaunchDarkly SDK at https://docs.launchdarkly.com/sdk/client-side/javascript. | ||
At the moment, **we do not officially support framework-specific LaunchDarkly | ||
SDKs.** However, you may reuse this setup code for React and client-side Node.js. | ||
|
||
## Options | ||
|
||
There are no setup options for this integration. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the non-frontend frameworks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feature flags can be used on BE too. Does LD for example have a packge for browser and another for node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LD has server-side node, yes, but the implementation + installation will look different, so we focus on client-side for now. See getsentry/sentry-javascript#14207 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tldr; the hook used to listen for evaluations doesn't exist for node. If it does, it works differently. This is also the reason we can't support specific frontend frameworks, only the generic launchdarkly-js-client-sdk