Skip to content

Add Flagsmith as feature flag provider #14126

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions docs/organization/integrations/feature-flag/flagsmith/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Flagsmith
sidebar_order: 2
description: Learn about Sentry's Flagsmith integrations.
---

## Evaluation Tracking

Sentry can track flag evaluations as they happen within your application. Flag evaluations will appear in the "Feature Flag" section of the Issue Details page as a table, with "suspect" flag predictions highlighted in yellow. Learn more about how to interact with feature flag insights within the Sentry UI by reading the [Issue Details page documentation](/product/issues/issue-details/#feature-flags).

### Set Up Evaluation Tracking

To set up evaluation tracking, visit one of our supported languages pages:
* [JavaScript](/platforms/javascript/configuration/integrations/flagsmith/)
* [Python](/platforms/python/integrations/feature-flags/flagsmith/)

## Change Tracking

Sentry can track changes to feature flag definitions and report suspicious feature flag edits.

### Set Up Change Tracking

Enabling Change Tracking is a three-step process. To get started, visit the [feature flags settings page](https://sentry.io/orgredirect/organizations/:orgslug/settings/feature-flags/change-tracking/) in a new tab. Then follow the steps listed below.

1. **Click the "Add New Provider" button.**
- One webhook secret can be registered per provider type.
- Select Generic in the dropdown that says "Select a provider".
2. **Register the webhook URL**.
![Flagsmith Sentry Webhook Modal](./img/flagsmith-sentry-webhook-modal.png)
- Go to your Flagsmith project dashboard and navigate to the `/project/:projectid/integrations` page, which can be found by clicking "Integrations" on the top navigation bar.
- Find the Sentry option, and click "Add Integration", which will open a modal.
- Select the Environment from which flag change events will trigger.
- Copy the provided Sentry webhook URL and paste it into "Webhook URL" in the Flagsmith "Sentry Integration" modal.
3. **Set the Signing Secret**.
- Still in the Flagsmith "Sentry Integration" modal, type in any string between 10 and 60 characters to use as your authorization token ("secret").
- Copy the authorization token from the previous step and paste it into the input box next to "Secret" in Sentry settings.

Once saved, Sentry will now accept and authenticate all inbound hooks to your organization's feature flag webhook endpoint.
1 change: 1 addition & 0 deletions docs/organization/integrations/feature-flag/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description: "Learn more about Sentry's feature flag integrations."
---

- [Generic](/organization/integrations/feature-flag/generic/)
- [Flagsmith](/organization/integrations/feature-flag/flagsmith/)
- [LaunchDarkly](/organization/integrations/feature-flag/launchdarkly/)
- [Statsig](/organization/integrations/feature-flag/statsig/)
- [Split](/organization/integrations/feature-flag/split/)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: LaunchDarkly
sidebar_order: 2
sidebar_order: 3
description: Learn about Sentry's LaunchDarkly integrations.
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Split
sidebar_order: 4
sidebar_order: 5
description: "Learn more about Sentry's Split integration, which allows you to use Sentry data in your Split analyses."
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Statsig
sidebar_order: 3
sidebar_order: 4
description: Learn about Sentry's Statsig integrations.
---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Unleash
sidebar_order: 5
sidebar_order: 6
description: Learn about Sentry's Unleash integrations.
---

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Flagsmith
description: "Learn how to use Sentry with Flagsmith."
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.hono
- javascript.koa
- javascript.nestjs
- javascript.node
- javascript.wasm
- javascript.tanstackstart-react
---

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

<Alert>

This integration only works inside a browser environment. It is only available from a package-based install (e.g. `npm` or `yarn`).

</Alert>

[Flagsmith](https://flagsmith.com/) relies on the [OpenFeature](https://openfeature.dev/) integration to track feature flag evaluations produced by the OpenFeature 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.** This integration is available in Sentry SDK **versions 8.43.0 or higher.**

_Import name: `Sentry.openFeatureIntegration` and `Sentry.OpenFeatureIntegrationHook`_

<PlatformContent includePath="/configuration/flagsmith" />

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

<PlatformContent includePath="feature-flags/next-steps" />
1 change: 1 addition & 0 deletions docs/platforms/python/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your

If you use a third-party SDK to evaluate feature flags, you can enable a Sentry SDK integration to track those evaluations. Integrations are provider specific. Documentation for supported SDKs is listed below.

- [Flagsmith](/platforms/python/integrations/flagsmith/)
- [LaunchDarkly](/platforms/python/integrations/launchdarkly/)
- [OpenFeature](/platforms/python/integrations/openfeature/)
- [Statsig](/platforms/python/integrations/statsig/)
Expand Down
75 changes: 75 additions & 0 deletions docs/platforms/python/integrations/flagsmith/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Flagsmith
description: "Learn how to use Sentry with Flagsmith."
---

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

[Flagsmith](https://flagsmith.com/) relies on the [OpenFeature](https://openfeature.dev/) integration to track feature flag evaluations produced by the OpenFeature SDK. These evaluations are held in memory and sent to Sentry for review and analysis if an error occurs. **At the moment, we only support boolean flag evaluations.**

## Install

Install `sentry-sdk` from PyPI with the `openfeature` extra.

```bash {tabTitle:pip}
pip install "sentry-sdk[openfeature]" openfeature-provider-flagsmith
```
```bash {tabTitle:uv}
uv add "sentry-sdk[openfeature]" openfeature-provider-flagsmith
```

## Configure

Set `FlagsmithProvider()` as the provider for the OpenFeature client, then add `OpenFeatureIntegration()` to your `integrations` list:

```python
import flagsmith
import sentry_sdk
from openfeature import api
from openfeature_flagsmith.provider import FlagsmithProvider
from sentry_sdk.integrations.openfeature import OpenFeatureIntegration

flagsmith_client = flagsmith.Flagsmith(
environment_key='<Flagsmith public environment key>',
)

flagsmith_provider = FlagsmithProvider(
client=flagsmith_client,
)

api.set_provider(flagsmith_provider)

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Add data like request headers and IP for users, if applicable;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
integrations=[
OpenFeatureIntegration(),
],
)
```

## Verify

The integration is tested by evaluating a feature flag using your OpenFeature SDK before capturing an exception.

```python
from openfeature import api
import sentry_sdk

client = api.get_client()
client.get_boolean_value("hello", default_value=False)

sentry_sdk.capture_exception(Exception("Something went wrong!"))
```

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

## Supported Versions

- openfeature-sdk >= 0.7.1
- sentry-sdk >= 2.19.2
- python >= 3.9

<PlatformContent includePath="feature-flags/next-steps" />
45 changes: 45 additions & 0 deletions platform-includes/configuration/flagsmith/javascript.angular.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Before using this integration, you need to install and instrument both the [OpenFeature SDK](https://www.npmjs.com/package/@openfeature/web-sdk) and the [OpenFeature Flagsmith provider](https://www.npmjs.com/package/@openfeature/flagsmith-client-provider) in your app. Learn more by reading OpenFeature's [SDK docs](https://openfeature.dev/docs/reference/technologies/client/web/) and [provider docs](https://openfeature.dev/docs/reference/concepts/provider).

```javascript {tabTitle: JavaScript (Track All Evals)}
import * as Sentry from '@sentry/angular';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook());

const client = OpenFeature.getClient();
const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```

```javascript {tabTitle: JavaScript (Track One Client)}
import * as Sentry from '@sentry/angular';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

const client = OpenFeature.getClient();
client.addHooks(new Sentry.OpenFeatureIntegrationHook());

const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```
45 changes: 45 additions & 0 deletions platform-includes/configuration/flagsmith/javascript.astro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Before using this integration, you need to install and instrument both the [OpenFeature SDK](https://www.npmjs.com/package/@openfeature/web-sdk) and the [OpenFeature Flagsmith provider](https://www.npmjs.com/package/@openfeature/flagsmith-client-provider) in your app. Learn more by reading OpenFeature's [SDK docs](https://openfeature.dev/docs/reference/technologies/client/web/) and [provider docs](https://openfeature.dev/docs/reference/concepts/provider).

```javascript {tabTitle: JavaScript (Track All Evals)}
import * as Sentry from '@sentry/astro';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook());

const client = OpenFeature.getClient();
const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```

```javascript {tabTitle: JavaScript (Track One Client)}
import * as Sentry from '@sentry/astro';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

const client = OpenFeature.getClient();
client.addHooks(new Sentry.OpenFeatureIntegrationHook());

const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```
45 changes: 45 additions & 0 deletions platform-includes/configuration/flagsmith/javascript.ember.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Before using this integration, you need to install and instrument both the [OpenFeature SDK](https://www.npmjs.com/package/@openfeature/web-sdk) and the [OpenFeature Flagsmith provider](https://www.npmjs.com/package/@openfeature/flagsmith-client-provider) in your app. Learn more by reading OpenFeature's [SDK docs](https://openfeature.dev/docs/reference/technologies/client/web/) and [provider docs](https://openfeature.dev/docs/reference/concepts/provider).

```javascript {tabTitle: JavaScript (Track All Evals)}
import * as Sentry from '@sentry/ember';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook());

const client = OpenFeature.getClient();
const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```

```javascript {tabTitle: JavaScript (Track One Client)}
import * as Sentry from '@sentry/ember';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

const client = OpenFeature.getClient();
client.addHooks(new Sentry.OpenFeatureIntegrationHook());

const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```
45 changes: 45 additions & 0 deletions platform-includes/configuration/flagsmith/javascript.gatsby.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Before using this integration, you need to install and instrument both the [OpenFeature SDK](https://www.npmjs.com/package/@openfeature/web-sdk) and the [OpenFeature Flagsmith provider](https://www.npmjs.com/package/@openfeature/flagsmith-client-provider) in your app. Learn more by reading OpenFeature's [SDK docs](https://openfeature.dev/docs/reference/technologies/client/web/) and [provider docs](https://openfeature.dev/docs/reference/concepts/provider).

```javascript {tabTitle: JavaScript (Track All Evals)}
import * as Sentry from '@sentry/gatsby';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

OpenFeature.addHooks(new Sentry.OpenFeatureIntegrationHook());

const client = OpenFeature.getClient();
const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```

```javascript {tabTitle: JavaScript (Track One Client)}
import * as Sentry from '@sentry/gatsby';
import { FlagsmithClientProvider } from '@openfeature/flagsmith-client-provider';
import { OpenFeature } from '@openfeature/web-sdk';

Sentry.init({
dsn: '___PUBLIC_DSN___',
integrations: [Sentry.openFeatureIntegration()]
});

const flagsmithClientProvider = new FlagsmithClientProvider({
environmentID: '<ENVIRONMENT_ID>'
});
OpenFeature.setProvider(flagsmithClientProvider);

const client = OpenFeature.getClient();
client.addHooks(new Sentry.OpenFeatureIntegrationHook());

const result = client.getBooleanValue('test-flag', false); // evaluate with a default value
Sentry.captureException(new Error('Something went wrong!'));
```
Loading
Loading