Skip to content

Commit fd22a8d

Browse files
committed
feat(flags): document featureFlagsIntegration for custom flag tracking
1 parent 37cab66 commit fd22a8d

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
title: Feature Flags
3+
description: "Learn how to attach custom feature flag data to Sentry error events."
4+
notSupported:
5+
- javascript.aws-lambda
6+
- javascript.azure-functions
7+
- javascript.bun
8+
- javascript.capacitor
9+
- javascript.cloudflare
10+
- javascript.connect
11+
- javascript.cordova
12+
- javascript.deno
13+
- javascript.electron
14+
- javascript.express
15+
- javascript.fastify
16+
- javascript.gcp-functions
17+
- javascript.hapi
18+
- javascript.koa
19+
- javascript.nestjs
20+
- javascript.nodejs
21+
- javascript.wasm
22+
---
23+
24+
<PlatformContent includePath="feature-flags/prerelease-alert" />
25+
26+
<Alert level="info">
27+
28+
This integration only works inside a browser environment.
29+
30+
</Alert>
31+
32+
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.
33+
**At the moment, we only support boolean flag evaluations.**
34+
35+
_Import names: `Sentry.featureFlagsIntegration` and `type Sentry.FeatureFlagsIntegration`_
36+
37+
## Install
38+
39+
Install your platform's Sentry SDK from npm.
40+
41+
## Configure
42+
43+
```JavaScript
44+
import * as Sentry from '@sentry/<your browser platform, e.g. react>';
45+
46+
Sentry.init({
47+
dsn: "___PUBLIC_DSN___",
48+
integrations: [Sentry.featureFlagsIntegration()]
49+
});
50+
```
51+
52+
## Verify
53+
54+
The integration is tested by calling the `addFeatureFlag` method before capturing an exception.
55+
56+
```JavaScript
57+
import * as Sentry from '@sentry/browser';
58+
59+
const flagsIntegration = Sentry.getClient()?.getIntegrationByName<Sentry.FeatureFlagsIntegration>('FeatureFlags');
60+
if (flagsIntegration) {
61+
flagsIntegration.addFeatureFlag('hello', false);
62+
} else {
63+
// check your configure step
64+
}
65+
Sentry.captureException(Exception('broke'));
66+
```
67+
68+
Visit the Sentry website and confirm that your error event has recorded the feature flag "hello" and its value "false".
69+
70+
<PlatformContent includePath="feature-flags/next-steps" />

0 commit comments

Comments
 (0)