Skip to content
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

feat(flags): Document self-serve feature flags integrations #12203

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/organization/integrations/feature-flag/self-serve/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: Self-Serve
sidebar_order: 1
description: Learn about Sentry's self-serve feature-flag integrations.
---

## Evaluation Tracking

Sentry can track flag evaluations as they happen within your application. Flag evaluations will appear in the "Feature Flag" section of 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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sentry can track flag evaluations as they happen within your application. Flag evaluations will appear in the "Feature Flag" section of 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).
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 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.

To set up self-serve evaluation tracking visit one of our supported languages pages:
* [JavaScript](/platforms/javascript/configuration/integrations/self-serve/)
* [Python](/platforms/python/integrations/self-serve/)

## Change Tracking

Sentry can track changes to feature flag definitions and report suspicious feature flag edits.

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.

### API Documentation

If you're using a self-serve integration it means you will likelyneed to write code to support this endpoint. This section documents our authentication proceedures as well as the resource's fields and structure.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you're using a self-serve integration it means you will likelyneed to write code to support this endpoint. This section documents our authentication proceedures as well as the resource's fields and structure.
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.


#### Authentication

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:

```python
def hmac_sha256_hex_digest(secret: str, message: bytes):
return hmac.new(secret.encode(), message, hashlib.sha256).hexdigest()
```

The result of this function must be sent as a header to Sentry: `X-Sentry-Signature signature_result`.

#### API Blueprint

[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.

### 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) 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.
2. **Register the webhook URL**.
- Copy the provided Sentry webhook URL and configure your feature flagging system to emit web hooks to this URL.
3. **Set the Signing Secret**.
- In your feature flagging system's UI retries the "Signing Secret".
- Copy the signing secret in the revealed input box and paste it into the input box labeled "Secret" in Sentry.
- Save the secret by clicking "Save Secret" in the Sentry fly out.

Once saved Sentry will now accept and authenticate all inbound hooks to your organization's feature flag webhook endpoint.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: FeatureFlags
title: Self-Serve Feature Flags Integration
description: "Learn how to attach custom feature flag data to Sentry error events."
notSupported:
- javascript.aws-lambda
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/javascript/common/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ description: With Feature Flags, Sentry tracks feature flag evaluations in your
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/)
- [Manual Tracking](/platforms/javascript/configuration/integrations/featureflags/) - if you use an unsupported or in-house provider, you may track evaluations through an API.
- [Self-Serve](/platforms/javascript/configuration/integrations/self-serve/)

<PlatformContent includePath="feature-flags/enable-change-tracking" />
2 changes: 1 addition & 1 deletion docs/platforms/python/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Evaluation tracking requires enabling an SDK integration. Integrations are provi

- [OpenFeature](/platforms/python/integrations/openfeature/)
- [LaunchDarkly](/platforms/python/integrations/launchdarkly/)
- [Manual Tracking](/platforms/javascript/configuration/integrations/featureflags/) - if you use an unsupported or in-house provider, you may track evaluations through an API.
- [Self-Serve](/platforms/python/integrations/self-serve/)

<PlatformContent includePath="feature-flags/enable-change-tracking" />
50 changes: 50 additions & 0 deletions docs/platforms/python/integrations/self-serve/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: Self Serve Feature Flags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title: Self Serve Feature Flags
title: Self-Serve Feature Flags

description: "Learn how to attach custom feature flag data to Sentry error events."
---

<PlatformContent includePath="feature-flags/prerelease-alert" />

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.
**At the moment, we only support boolean flag evaluations.**

## Install

Install `sentry-sdk` from PyPI.

```bash
pip install --upgrade 'sentry-sdk'
```

## Configure

Add `FeatureFlagsIntegration()` to your `integrations` list:

```python
import sentry_sdk
from sentry_sdk.integrations.featureflags import FeatureFlagsIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
FeatureFlagsIntegration(),
],
)
```

## Verify

The integration is tested by calling the `add_feature_flag` API before capturing an exception.

```python
import sentry_sdk
from sentry_sdk.integrations.featureflags import add_feature_flag

add_feature_flag('test-flag', False)

sentry_sdk.capture_exception(Exception("Something went wrong!"))
```

Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Visit the Sentry website and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".


<PlatformContent includePath="feature-flags/next-steps" />
1 change: 1 addition & 0 deletions docs/product/explore/feature-flags/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ Change tracking enables Sentry to listen for additions, removals, and modificati

To set up change tracking, visit the webhook integration documentation for your provider:
* [LaunchDarkly](/organization/integrations/feature-flag/launchdarkly/#change-tracking)
* [Self-Serve](/organization/integrations/feature-flag/self-serve/#change-tracking)
Loading