|
| 1 | +--- |
| 2 | +title: Unleash |
| 3 | +description: "Learn how to use Sentry with Unleash." |
| 4 | +--- |
| 5 | + |
| 6 | +<PlatformContent includePath="feature-flags/prerelease-alert" /> |
| 7 | + |
| 8 | +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.** |
| 9 | + |
| 10 | +## Install |
| 11 | + |
| 12 | +Install `sentry-sdk` (>=2.19.3) and `UnleashClient` (>=6.0.1) from PyPI. |
| 13 | + |
| 14 | +```bash |
| 15 | +pip install --upgrade sentry-sdk UnleashClient |
| 16 | +``` |
| 17 | + |
| 18 | +## Configure |
| 19 | + |
| 20 | +Add `UnleashIntegration` to your `integrations` list: |
| 21 | + |
| 22 | +```python |
| 23 | +import sentry_sdk |
| 24 | +from sentry_sdk.integrations.unleash import UnleashIntegration |
| 25 | + |
| 26 | +sentry_sdk.init( |
| 27 | + dsn="___PUBLIC_DSN___", |
| 28 | + integrations=[UnleashIntegration()], |
| 29 | +) |
| 30 | +``` |
| 31 | + |
| 32 | +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). |
| 33 | + |
| 34 | +## Verify |
| 35 | + |
| 36 | +Test the integration by evaluating a feature flag using your Unleash SDK before capturing an exception. |
| 37 | + |
| 38 | +```python {tabTitle: Python, using is_enabled} |
| 39 | +import sentry_sdk |
| 40 | +from UnleashClient import UnleashClient |
| 41 | + |
| 42 | +unleash_client = UnleashClient(...) # See Unleash quickstart. |
| 43 | +test_flag_enabled = unleash_client.is_enabled("test-flag") |
| 44 | + |
| 45 | +sentry_sdk.capture_exception(Exception("Something went wrong!")) |
| 46 | +``` |
| 47 | + |
| 48 | +```python {tabTitle: Python, using get_variant} |
| 49 | +import sentry_sdk |
| 50 | +from UnleashClient import UnleashClient |
| 51 | + |
| 52 | +unleash_client = UnleashClient(...) # See Unleash quickstart. |
| 53 | +test_flag_variant = unleash_client.get_variant("test-flag") |
| 54 | +test_flag_enabled = test_flag_variant["enabled"] |
| 55 | + |
| 56 | +sentry_sdk.capture_exception(Exception("Something went wrong!")) |
| 57 | +``` |
| 58 | + |
| 59 | +Visit the [Sentry website](https://sentry.io/issues/) and confirm that your error |
| 60 | +event has recorded the feature flag "test-flag", and its value is equal to `test_flag_enabled`. |
| 61 | + |
| 62 | +<PlatformContent includePath="feature-flags/next-steps" /> |
0 commit comments