Skip to content

Commit 11f76bf

Browse files
aliu39billyvg
andauthored
feat(flags): document statsig browser integration (#12718)
* feat(flags): document statsig browser integration * Add / * Specify sdk name * Statsig feature gates * Fix node name in notSupported list * Improve statsigClient comment Co-authored-by: Billy Vong <[email protected]> * Add platform config --------- Co-authored-by: Billy Vong <[email protected]>
1 parent c1832ad commit 11f76bf

File tree

17 files changed

+322
-0
lines changed

17 files changed

+322
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Statsig
3+
description: "Learn how to use Sentry with Statsig."
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.node
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. It is only available from a package-based install (e.g. `npm` or `yarn`).
29+
30+
</Alert>
31+
32+
The [Statsig](https://www.statsig.com/) integration tracks feature flag evaluations produced by the Statsig JavaScript Client 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 from Statsig's `checkGate` method**. Learn more about [Statsig feature gates](https://docs.statsig.com/feature-flags/working-with/).
33+
34+
This integration is available in Sentry SDK **versions 9.0.0 and higher**, or **versions 8.55.0 and higher for v8.**
35+
36+
_Import name: `Sentry.statsigIntegration`_
37+
38+
<PlatformContent includePath="/configuration/statsig" />
39+
40+
<PlatformContent includePath="feature-flags/next-steps" />

docs/platforms/javascript/common/feature-flags/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Evaluation tracking requires enabling an SDK integration. Integrations are provi
3535
- [Generic](/platforms/javascript/configuration/integrations/featureflags/)
3636
- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/)
3737
- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/)
38+
- [Statsig](/platforms/javascript/configuration/integrations/statsig/)
3839
- [Unleash](/platforms/javascript/configuration/integrations/unleash/)
3940

4041
## Enable Change Tracking

platform-includes/configuration/integrations/javascript.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@
2525
| [`replayIntegration`](./replay) | | | |||
2626
| [`replayCanvasIntegration`](./replaycanvas) | | | || |
2727
| [`reportingObserverIntegration`](./reportingobserver) | || | | |
28+
| [`statsigIntegration`](./statsig) | | | | ||
2829
| [`unleashIntegration`](./unleash) | | | | ||
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/angular';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/astro';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/ember';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/gatsby';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/browser';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/nextjs';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/nuxt';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/react';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/remix';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/solid';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/solidstart';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/svelte';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/sveltekit';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Before using this integration, you need to install and instrument Statsig in your app. Learn more by reading [Statsig's SDK reference](https://docs.statsig.com/client/javascript-sdk) and [quickstart guide](https://docs.statsig.com/guides/first-feature).
2+
3+
```javascript
4+
import * as Sentry from '@sentry/vue';
5+
import { StatsigClient } from '@statsig/js-client';
6+
7+
const statsigClient = new StatsigClient( YOUR_SDK_KEY, { userID: 'my-user-id' }, {} ); // see Statsig SDK reference.
8+
9+
Sentry.init({
10+
dsn: '___PUBLIC_DSN___',
11+
integrations: [Sentry.statsigIntegration({featureFlagClient: statsigClient})],
12+
});
13+
14+
await statsigClient.initializeAsync(); // or statsigClient.initializeSync();
15+
16+
const result = statsigClient.checkGate('my-feature-gate');
17+
Sentry.captureException(new Error('something went wrong'));
18+
```
19+
20+
Visit the Sentry website and confirm that your error event has recorded the feature flag "my-feature-gate" and its value "false".

0 commit comments

Comments
 (0)