Skip to content
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

feat(flags): document custom featureFlagsIntegration and refactor all JS integration docs #12151

Merged
merged 12 commits into from
Dec 18, 2024
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.
aliu39 marked this conversation as resolved.
Show resolved Hide resolved
**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>';
aliu39 marked this conversation as resolved.
Show resolved Hide resolved

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'));
aliu39 marked this conversation as resolved.
Show resolved Hide resolved
```

Visit the Sentry website and confirm that your error event has recorded the feature flag "hello" and its value "false".
aliu39 marked this conversation as resolved.
Show resolved Hide resolved

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