-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Changes from 2 commits
a34d813
8d2b60d
723e5bb
97868b5
3bacab0
dd8de37
9993b98
87c881e
156b6f4
8ad04c0
6e58632
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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**. | ||
|  | ||
| - 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. | ||
|
aliu39 marked this conversation as resolved.
Outdated
|
||
| 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"). | ||
|
aliu39 marked this conversation as resolved.
|
||
| - 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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For platform docs, I believe it's not our convention to add pages under
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whipping up a draft of what I think could work.. I'll link it here when done
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend using this to update the eval tracking section for the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry if this way of suggesting changes was a little janky 😬 I needed a way to see things on my local dev mode, so I checked out sentry's master branch. Thanks again for adding these docs!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the patch! I've applied it with a few edits:
Also reverted all changes from
Ideally, we'd love to see Sentry shipping with Flagsmith integrations and proper documentation. I'm not sure adding a Flagsmith section to the OpenFeature documentation is the right architecture but I'm good with it as a first iteration. We'll coordinate that. 😉
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup edits look good!
Sounds good - if Sentry integrates directly with flagsmith SDKs in the future, we can add to platform docs. Before that I think it's best to link to Openfeature from flagsmith, with the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't find the best place in Sentry docs under |
| 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" /> |
| 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" /> |
| 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!')); | ||
| ``` |
| 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!')); | ||
| ``` |
| 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!')); | ||
| ``` |
| 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!')); | ||
| ``` |
Uh oh!
There was an error while loading. Please reload this page.