diff --git a/docs/organization/integrations/feature-flag/generic/index.mdx b/docs/organization/integrations/feature-flag/generic/index.mdx index d4311c5460c3b2..11a05ea86fcac2 100644 --- a/docs/organization/integrations/feature-flag/generic/index.mdx +++ b/docs/organization/integrations/feature-flag/generic/index.mdx @@ -14,6 +14,7 @@ To set up evaluation tracking, visit the [explore page](/product/explore/feature To set up generic evaluation tracking, visit one of our supported languages' pages: * [JavaScript](/platforms/javascript/configuration/integrations/generic/) +* [Python](/platforms/python/feature-flags/#generic-api) ## Change Tracking diff --git a/docs/organization/integrations/feature-flag/unleash/index.mdx b/docs/organization/integrations/feature-flag/unleash/index.mdx index 46e7da0fb69b7c..f0168cb9b52cb8 100644 --- a/docs/organization/integrations/feature-flag/unleash/index.mdx +++ b/docs/organization/integrations/feature-flag/unleash/index.mdx @@ -6,7 +6,12 @@ description: Learn about Sentry's Unleash integrations. ## Evaluation Tracking -Support for this is coming soon, starting with [Python sentry-sdk](https://pypi.org/project/sentry-sdk/). +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: +* [Python](/platforms/python/integrations/feature-flags/unleash/) ## Change Tracking @@ -20,7 +25,7 @@ Enabling Change Tracking is a three-step process. To get started visit the [feat - One webhook secret can be registered per provider type. - Select Unleash in the dropdown that says "Select a provider". 2. **Register the webhook URL**. - - Go to your Unleash homepage and navigate to the `/integrations/` page, which can be found by clicking Integrations on the left-hand sidebar navigation, under the Configure heading. + - Go to your Unleash homepage and navigate to the `/integrations/` page, which can be found by clicking Integrations on the left-hand sidebar navigation, under the Configure heading. - Select the Webhook option. You should be on the `/integrations/create/webhook/` page. - Copy the provided Sentry webhook URL in settings and paste it into Unleash within their webhook integration UI. - Make sure the integration is toggled to Enabled. diff --git a/docs/platforms/javascript/common/feature-flags/index.mdx b/docs/platforms/javascript/common/feature-flags/index.mdx index bcb0599d8503fc..5f91083b9ea913 100644 --- a/docs/platforms/javascript/common/feature-flags/index.mdx +++ b/docs/platforms/javascript/common/feature-flags/index.mdx @@ -31,8 +31,9 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your ## Enable Evaluation Tracking Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below. -- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/) -- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/) + - [Generic](/platforms/javascript/configuration/integrations/generic/) +- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/) +- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/) diff --git a/docs/platforms/python/feature-flags/index.mdx b/docs/platforms/python/feature-flags/index.mdx index 13b10a38359ba6..de5b5126d10d15 100644 --- a/docs/platforms/python/feature-flags/index.mdx +++ b/docs/platforms/python/feature-flags/index.mdx @@ -1,20 +1,42 @@ --- title: Set Up Feature Flags sidebar_order: 7000 -description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log feature flag changes, and reports any suspicious updates that may have caused an error. +description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log of feature flag changes, and reports any suspicious updates that may have caused an error. --- +A feature flagging integration allows you to manually track feature flag evaluations through an API. These evaluations are collected in memory, and in the event an error occurs, sent to Sentry for review and analysis. + + ## Prerequisites * You have the Python SDK installed. ## Enable Evaluation Tracking -Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below. +Evaluation tracking typically requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below. + +- [Generic (API)](/platforms/python/feature-flags/#generic-api) +- [LaunchDarkly](/platforms/python/integrations/launchdarkly/) +- [OpenFeature](/platforms/python/integrations/openfeature/) +- [Unleash](/platforms/python/integrations/unleash/) + +### Generic API +The generic API allows you to manually track feature flag evaluations. These +evaluations are held in memory, and in the event an error occurs, sent to +Sentry for review and analysis. Specifically, the generic integration enables +users to integrate with proprietary (or otherwise unsupported) feature flagging +solutions. **At the moment, we only support boolean flag evaluations.** + +```python +from sentry_sdk.feature_flags import add_feature_flag + +add_feature_flag('test-flag', False) # Records an evaluation and its result. + +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` -- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/) -- [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/) +Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false". diff --git a/docs/platforms/python/integrations/feature-flags/index.mdx b/docs/platforms/python/integrations/feature-flags/index.mdx deleted file mode 100644 index b5018499ae0e00..00000000000000 --- a/docs/platforms/python/integrations/feature-flags/index.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Feature Flags -description: "Learn about using Feature Flags with Sentry." ---- - -A feature flagging integration allows you to manually track feature flag evaluations through an API. These evaluations are collected in memory, and in the event an error occurs, sent to Sentry for review and analysis. - -Sentry has added support for a variety of providers. Click through the nested sidebar listings to learn more. diff --git a/docs/platforms/python/integrations/feature-flags/launchdarkly.mdx b/docs/platforms/python/integrations/launchdarkly/index.mdx similarity index 100% rename from docs/platforms/python/integrations/feature-flags/launchdarkly.mdx rename to docs/platforms/python/integrations/launchdarkly/index.mdx diff --git a/docs/platforms/python/integrations/feature-flags/openfeature.mdx b/docs/platforms/python/integrations/openfeature/index.mdx similarity index 100% rename from docs/platforms/python/integrations/feature-flags/openfeature.mdx rename to docs/platforms/python/integrations/openfeature/index.mdx diff --git a/docs/platforms/python/integrations/unleash/index.mdx b/docs/platforms/python/integrations/unleash/index.mdx new file mode 100644 index 00000000000000..219d3e62662a52 --- /dev/null +++ b/docs/platforms/python/integrations/unleash/index.mdx @@ -0,0 +1,64 @@ +--- +title: Unleash +description: "Learn how to use Sentry with Unleash." +--- + + + +The [Unleash](https://www.getunleash.io/) integration tracks feature flag evaluations produced by the Unleash 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` (>=2.20.0) and `UnleashClient` (>=6.0.1) from PyPI. + +```bash +pip install --upgrade sentry-sdk UnleashClient +``` + +## Configure + +Add `UnleashIntegration` to your `integrations` list: + +```python +import sentry_sdk +from sentry_sdk.integrations.unleash import UnleashIntegration + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + integrations=[UnleashIntegration()], +) +``` + +For more information on how to use Unleash, read Unleash's [Python reference](https://docs.getunleash.io/reference/sdks/python) and [quickstart guide](https://docs.getunleash.io/quickstart). + +## Verify + +Test the integration by evaluating a feature flag using your Unleash SDK before capturing an exception. + +```python {tabTitle: Python, using is_enabled} +import sentry_sdk +from UnleashClient import UnleashClient + +unleash = UnleashClient(...) # See Unleash quickstart. +unleash.initialize_client() + +test_flag_enabled = unleash.is_enabled("test-flag") +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` + +```python {tabTitle: Python, using get_variant} +import sentry_sdk +from UnleashClient import UnleashClient + +unleash = UnleashClient(...) # See Unleash quickstart. +unleash.initialize_client() + +test_flag_variant = unleash.get_variant("test-flag") +test_flag_enabled = test_flag_variant["enabled"] +sentry_sdk.capture_exception(Exception("Something went wrong!")) +``` + +Visit the [Sentry website](https://sentry.io/issues/) and confirm that your error +event has recorded the feature flag "test-flag", and its value is equal to `test_flag_enabled`. + + diff --git a/src/middleware.ts b/src/middleware.ts index 7deefdd8ac3368..03a1274b385179 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -505,6 +505,18 @@ const USER_DOCS_REDIRECTS: Redirect[] = [ from: '/platforms/python/tryton/', to: '/platforms/python/integrations/tryton/', }, + { + from: '/platforms/python/integrations/feature-flags/launchdarkly/', + to: '/platforms/python/integrations/launchdarkly/', + }, + { + from: '/platforms/python/integrations/feature-flags/openfeature/', + to: '/platforms/python/integrations/openfeature/', + }, + { + from: '/platforms/python/integrations/feature-flags/unleash/', + to: '/platforms/python/integrations/unleash/', + }, { from: '/clients/python/breadcrumbs/', to: '/platforms/python/legacy-sdk/breadcrumbs/',