Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Feature Flags
description: "Learn how to attach custom feature flag data to Sentry error events."
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
---

<PlatformContent includePath="feature-flags/prerelease-alert" />

<Alert level="info">

This integration only works inside a browser environment.

</Alert>

The Feature Flags integration allows you to manually track feature flag evaluations through an API. 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.**

_Import names: `Sentry.featureFlagsIntegration` and `type Sentry.FeatureFlagsIntegration`_

## Install

Install your platform's Sentry SDK from npm.

## Configure

```JavaScript
import * as Sentry from '@sentry/<your browser platform, e.g. react>';

Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.featureFlagsIntegration()]
});
```

## Verify

The integration is tested by calling the `addFeatureFlag` method before capturing an exception.

```JavaScript
import * as Sentry from '@sentry/browser';

const flagsIntegration = Sentry.getClient()?.getIntegrationByName<Sentry.FeatureFlagsIntegration>('FeatureFlags');
if (flagsIntegration) {
flagsIntegration.addFeatureFlag('hello', false);
} else {
// check your configure step
}
Sentry.captureException(Exception('broke'));
```

Visit the Sentry website and confirm that your error event has recorded the feature flag "hello" and its value "false".

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