Skip to content

Commit 29796de

Browse files
cmanallencoolguyzonealiu39
authored
feat(flags): Document self-serve feature flags integrations (#12203)
* Add generic provider docs * Add SDK docs and links * Minor fixes * Wording Co-authored-by: Alex Krawiec <[email protected]> * Missing word Co-authored-by: Alex Krawiec <[email protected]> * Fix wording * Test nesting * Move to nested structure * Update links * Capitaliztion * Rename and update links * Fix import path * Rename to feature-flags * Fix url * Remove placeholder wording Co-authored-by: Andrew Liu <[email protected]> * More wording * Pluralize * Use singular to fix search * Fix linkage --------- Co-authored-by: Alex Krawiec <[email protected]> Co-authored-by: Andrew Liu <[email protected]>
1 parent 338924e commit 29796de

File tree

12 files changed

+126
-9
lines changed

12 files changed

+126
-9
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
2-
title: Feature Flag
2+
title: Feature Flags
33
sidebar_order: 90
44
description: "Learn more about Sentry's feature flag integrations."
55
---
66

7-
- [Split](/organization/integrations/feature-flag/split/)
87
- [LaunchDarkly](/organization/integrations/feature-flag/launchdarkly/)
8+
- [Self-Serve](/organization/integrations/feature-flag/self-serve/)
9+
- [Split](/organization/integrations/feature-flag/split/)

docs/organization/integrations/feature-flag/launchdarkly/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Sentry can track flag evaluations as they happen within your application. Flag
1212

1313
To set up evaluation tracking visit one of our supported languages pages:
1414
* [JavaScript](/platforms/javascript/configuration/integrations/launchdarkly/)
15-
* [Python](/platforms/python/integrations/launchdarkly/)
15+
* [Python](/platforms/python/integrations/feature-flags/launchdarkly/)
1616

1717
## Change Tracking
1818

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Self-Serve
3+
sidebar_order: 1
4+
description: Learn about Sentry's self-serve feature-flag integrations.
5+
---
6+
7+
## Evaluation Tracking
8+
9+
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).
10+
11+
### Set Up Evaluation Tracking
12+
13+
To set up evaluation tracking visit the [explore page](/product/explore/feature-flags/) and select the language and SDK of your choice. Not using a supported SDK? That's okay. We support self-serve integrations with your existing system.
14+
15+
To set up self-serve evaluation tracking visit one of our supported languages pages:
16+
* [JavaScript](/platforms/javascript/configuration/integrations/self-serve/)
17+
* [Python](/platforms/python/integrations/feature-flags/self-serve/)
18+
19+
## Change Tracking
20+
21+
Sentry can track changes to feature flag definitions and report suspicious feature flag edits.
22+
23+
Sentry offers a change tracking feature which functions as an audit-log of feature flag changes. When a feature flag definition changes in your back-end you can emit a web hook to Sentry.
24+
25+
### API Documentation
26+
27+
If you're using a self-serve integration it means you will likely need to write code to support this endpoint. This section documents our authentication procedures as well as the resource's fields and structure.
28+
29+
#### Authentication
30+
31+
Authentication is performed using a "signing secret". The "signing secret" must be used to sign the web hook payload in your feature flagging system. Signing the payload with your secret produces a "signature". Sentry needs this signature so it can compare the results of our signing function to yours. Both sides must use the same signing function. Sentry uses a HMAC SHA256 hex-digest of the web hook payload. In Python this function looks like:
32+
33+
```python
34+
def hmac_sha256_hex_digest(secret: str, message: bytes):
35+
return hmac.new(secret.encode(), message, hashlib.sha256).hexdigest()
36+
```
37+
38+
The result of this function must be sent as a header to Sentry: `X-Sentry-Signature signature_result`.
39+
40+
#### API Blueprint
41+
42+
[An API blueprint is available at this permalink](https://github.com/getsentry/sentry/blob/ed324708947ca26392d6579ed76b93fc94a61ab6/src/sentry/flags/docs/api.md#create-generic-flag-log-post). We strive to keep this page updated. Be sure to check the latest master branch for new protocol versions. We will always maintain backwards compatibility so there is no harm in implementing an old version. However, new versions might introduce new features.
43+
44+
### Set Up Change Tracking
45+
46+
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) in a new tab. Then follow the steps listed below.
47+
48+
1. **Click the "Add New Provider" button.**
49+
- One webhook secret can be registered per provider type.
50+
2. **Register the webhook URL**.
51+
- Copy the provided Sentry webhook URL and configure your feature flagging system to emit web hooks to this URL.
52+
3. **Set the Signing Secret**.
53+
- In your feature flagging system's UI find the "Signing Secret".
54+
- Copy the signing secret and paste it into the input box labeled "Secret" in Sentry.
55+
- In Sentry, save the secret by clicking "Save Secret".
56+
57+
Once saved Sentry will now accept and authenticate all inbound hooks to your organization's feature flag webhook endpoint.

docs/platforms/javascript/common/configuration/integrations/featureflags.mdx renamed to docs/platforms/javascript/common/configuration/integrations/self-serve.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: FeatureFlags
2+
title: Self-Serve Feature Flags Integration
33
description: "Learn how to attach custom feature flag data to Sentry error events."
44
notSupported:
55
- javascript.aws-lambda

docs/platforms/javascript/common/feature-flags/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your
3333
Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below.
3434
- [OpenFeature](/platforms/javascript/configuration/integrations/openfeature/)
3535
- [LaunchDarkly](/platforms/javascript/configuration/integrations/launchdarkly/)
36-
- [Manual Tracking](/platforms/javascript/configuration/integrations/featureflags/) - if you use an unsupported or in-house provider, you may track evaluations through an API.
36+
- [Self-Serve](/platforms/javascript/configuration/integrations/self-serve/)
3737

3838
<PlatformContent includePath="feature-flags/enable-change-tracking" />

docs/platforms/python/feature-flags/index.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your
1414

1515
Evaluation tracking requires enabling an SDK integration. Integrations are provider specific. Documentation for supported providers is listed below.
1616

17-
- [OpenFeature](/platforms/python/integrations/openfeature/)
18-
- [LaunchDarkly](/platforms/python/integrations/launchdarkly/)
17+
- [OpenFeature](/platforms/python/integrations/feature-flags/openfeature/)
18+
- [LaunchDarkly](/platforms/python/integrations/feature-flags/launchdarkly/)
19+
- [Self-Serve](/platforms/python/integrations/feature-flags/self-serve/)
1920

2021
<PlatformContent includePath="feature-flags/enable-change-tracking" />
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
title: Feature Flags
3+
description: "Learn about using Feature Flags with Sentry."
4+
---
5+
6+
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.
7+
8+
Sentry has added support for a variety of providers. Click through the nested sidebar listings to learn more.
File renamed without changes.
File renamed without changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: Self-Serve
3+
description: "Learn how to attach custom feature flag data to Sentry error events."
4+
---
5+
6+
<PlatformContent includePath="feature-flags/prerelease-alert" />
7+
8+
The Feature Flags integration allows you to manually track feature flag evaluations through an API. These evaluations are held in memory, and in the event an error occurs, sent to Sentry for review and analysis. Specifically, the self-serve integration enables users to integrate with proprietary (or otherwise unsupported) feature flagging solutions. **At the moment, we only support boolean flag evaluations.**
9+
10+
## Install
11+
12+
Install `sentry-sdk` from PyPI.
13+
14+
```bash
15+
pip install --upgrade 'sentry-sdk'
16+
```
17+
18+
## Configure
19+
20+
Add `FeatureFlagsIntegration()` to your `integrations` list:
21+
22+
```python
23+
import sentry_sdk
24+
from sentry_sdk.integrations.feature_flags import FeatureFlagsIntegration
25+
26+
sentry_sdk.init(
27+
dsn="___PUBLIC_DSN___",
28+
integrations=[
29+
FeatureFlagsIntegration(),
30+
],
31+
)
32+
```
33+
34+
## Verify
35+
36+
The integration is tested by calling the `add_feature_flag` API before capturing an exception.
37+
38+
```python
39+
import sentry_sdk
40+
from sentry_sdk.integrations.feature_flags import add_feature_flag
41+
42+
add_feature_flag('test-flag', False)
43+
44+
sentry_sdk.capture_exception(Exception("Something went wrong!"))
45+
```
46+
47+
Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
48+
49+
<PlatformContent includePath="feature-flags/next-steps" />

0 commit comments

Comments
 (0)