Skip to content

Commit 92ed334

Browse files
committed
get_variant example
1 parent f91ef93 commit 92ed334

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/platforms/python/unleash/index.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ For more information on how to use Unleash, read Unleash's [Python reference](ht
4646

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

49-
```python
49+
```python {tabTitle: Python, using is_enabled}
5050
import sentry_sdk
5151

5252
# Re-use `unleash_client` from the previous step.
@@ -55,9 +55,17 @@ test_flag_enabled = unleash_client.is_enabled("test-flag")
5555
sentry_sdk.capture_exception(Exception("Something went wrong!"))
5656
```
5757

58-
Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value
59-
is equal to `test_flag_enabled`.
58+
```python {tabTitle: Python, using get_variant}
59+
import sentry_sdk
60+
61+
# Re-use `unleash_client` from the previous step.
62+
test_flag_variant = unleash_client.get_variant("test-flag")
63+
test_flag_enabled = test_flag_variant["enabled"]
6064

61-
Note that we also track the `"enabled"` field in the results of [`get_variant()`](https://docs.getunleash.io/reference/sdks/python#getting-a-variant) calls.
65+
sentry_sdk.capture_exception(Exception("Something went wrong!"))
66+
```
67+
68+
Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag", and its value
69+
is equal to `test_flag_enabled`.
6270

6371
<PlatformContent includePath="feature-flags/next-steps" />

0 commit comments

Comments
 (0)