The Sentry integration is available to customers on select plansThe Sentry integration is only available to customers on select plans. To learn more, read about our pricing. To upgrade your plan, contact Sales.

An installed Sentry integration.
You can also forward Sentry errors from your own codeIf this integration is not available on your plan or in your LaunchDarkly instance, or if you want control over the data attached to each error event, you can forward errors to LaunchDarkly yourself from Sentry’s
beforeSend hook. To learn how, read Sending error events from observability tools.- Install Sentry
- Configure the integration
- Create a LaunchDarkly metric
- Attach LaunchDarkly contexts to Sentry error events
launchdarklyContext custom context. To learn more, read Use Sentry monitors with adaptive triggers.
Install Sentry
To install the Sentry integration:- In LaunchDarkly, navigate to the Integrations page and find “Sentry.”
- Open the Sentry integration panel and click Install in Sentry. Sentry opens the LaunchDarkly app.
- In Sentry, click Install within 15 minutes.
Configure the integration
There are two pieces of configuration required for the Sentry integration to work:- setting the event key, and
- mapping the environments.
Set the event key
Sentry uses the event key to aggregate events. We recommend using a Metric event key ofsentry-errors or similar, but you can use any event key you like.

The "Metric event key" section of the integration panel.
Map environments
Events are specific to one LaunchDarkly environment. The Sentry integration requires you to map Sentry environments to LaunchDarkly environments. This lets you send Sentry errors to different LaunchDarkly environments. For example, you can send errors from your production Sentry environment to your production LaunchDarkly environment, and errors from your staging Sentry environment to your staging LaunchDarkly environment. To map Sentry environments to LaunchDarkly environments:- Navigate to the Integrations page in LaunchDarkly.
- Open the Sentry integration panel.
- In the “Environment mappings” section, choose a LaunchDarkly project and environment from the Project - Environment menu.
- Choose a Sentry project and environment from the Sentry Project - Environment menu.
- Click Create.

Sentry environment mappings.
Create a LaunchDarkly metric
To create a LaunchDarkly metric, follow the procedure at Custom conversion binary metrics or Custom conversion count metrics, depending on your needs. Here are two example metrics we recommend.Percentage of end users that experienced an error
To track the percentage of end users that experienced an error, create a custom conversion binary metric by selecting the following options:- Event kind: Custom
- Event key:
sentry-errors - Metric definition: Occurrence (Percent) of User units that sent the event where lower is better

The metric creation dialog.
Average number of errors per request
To track the average number of errors per request, create a custom conversion count metric by selecting the following options:- Event kind: Custom
- Event key:
sentry-errors - Metric definition: Count events per Request, then compute the Average of those values where lower is better

The metric creation dialog.
Filter Sentry errors by event property
Each event that LaunchDarkly creates from a Sentry error includes details from the error in itsdata object. You can use these properties in metric filters to build narrower metrics from the same event key, instead of counting every error in the environment. To learn how, read Filtering metric events.
Here are the properties LaunchDarkly copies from each Sentry error. LaunchDarkly omits a property when Sentry does not send it.
| Property | Description |
|---|---|
sentryProjectId | The numeric ID of the Sentry project the error belongs to. |
level | The error’s level, such as fatal, error, or warning. |
release | The release, or version, of your application that reported the error. |
environment | The Sentry environment that reported the error. |
transaction | The transaction that caused the error, such as the route in a web application. Sentry sends this only when your Sentry SDK sets it. |
culprit | The code location that Sentry reports as the source of the error. |
location | The file or code location where the error occurred. |
title | The title of the error, as it appears in Sentry. |
issue_id | The ID of the Sentry issue the error belongs to. |
platform | The platform that reported the error, such as javascript or python. |
tag | An object that contains the error’s Sentry tags, with one property for each tag. For example, a Sentry tag named handled appears as tag.handled. You cannot use tags in metric filters. |
data object. The tag object is nested, and LaunchDarkly ignores it when it applies a filter. The tags are still stored with each event.
Here are some examples of filters you can build on the sentry-errors event key:
- Fatal errors only:
levelisfatal. - Errors from one endpoint:
transactionis/api/checkout. - Errors in one release:
releaseis2.4.0. - Errors from one Sentry project:
sentryProjectIdis the ID of that project.
Attach LaunchDarkly contexts to Sentry error events
Sentry custom contexts are not the same as LaunchDarkly custom contextsSentry provides functionality called “custom contexts.” These are distinct from LaunchDarkly custom contexts. In this section, “custom contexts” refers to the Sentry functionality.
launchdarklyContext and then attach LaunchDarkly contexts to error events. To learn how, read Sentry’s Context docs.
Supported JSON structures for the custom context
LaunchDarkly reads thelaunchdarklyContext custom context to find the context kinds and keys that the error belongs to. It accepts the custom context in structures such as the following. In every structure, the value for a context kind is either the context key as a string, or an object with a key property. The kind property is optional. If you omit kind and include a top-level key, LaunchDarkly reads the object as a user context.
name or anonymous. In the single-context structures it also ignores other top-level properties.
In multi-context and kind-to-key map structures, LaunchDarkly reads every top-level property other than kind as a context kind. Put attributes inside each context object.
LaunchDarkly rejects an event if:
- It finds user attributes such as
nameoranonymousat the top level of a multi-context or kind-to-key map structure. - A context kind contains characters other than letters, numbers,
.,_, and-. - A context key is empty.
Using the integration
After you create the environment mappings, set the metric event key, create metrics for your desired projects, and add LaunchDarkly contexts to the Sentry SDK, you can use the metric in LaunchDarkly the same way as any other metric. When you configure a metric to use Sentry errors, error events will flow from Sentry into that metric.Use Sentry monitors with adaptive triggers
A Sentry monitor watches a signal in Sentry, such as errors, spans, logs, or metrics, and breaches when that signal crosses a threshold you set in Sentry. You can choose a Sentry monitor as the source of an adaptive trigger. When the monitor breaches, the trigger switches the flag to the variation you choose. You do not need to rebuild the monitor’s threshold in LaunchDarkly. To use Sentry monitors with adaptive triggers, you need:- The Sentry integration installed, with read access to alerts. To learn more, read Install Sentry.
- At least one Sentry project mapped to the LaunchDarkly environment where you create the trigger. To learn how, read Map environments.
- At least one metric monitor in a mapped Sentry project.