Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit 09160c2

Browse files
authored
ref(features) Add more details on feature graduation (#408)
1 parent 2bfe62a commit 09160c2

File tree

1 file changed

+49
-20
lines changed

1 file changed

+49
-20
lines changed

src/docs/feature-flags.mdx

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ may prove difficult to find because `trends` may appear throughout the codebase.
2828
But a name like `performance-trends-view` is more likely to be unique and easier
2929
to remove later
3030

31-
# Creating a new Feature Flag
31+
## Creating a new Feature Flag
3232

33-
## Determine what scope the feature should have
33+
### Determine what scope the feature should have
3434

3535
Features can be scoped by organization, and projects. If you're not confident
3636
you want a project feature, create an organization level one. In this example
3737
we'll build a feature called `test-feature` scoped at the _organization_ level.
3838

39-
## Add your feature to server.py
39+
### Add your feature to server.py
4040

4141
[`conf/server.py`](https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py)
4242
contains many of the default settings in the application. Here you will add
@@ -55,7 +55,7 @@ SENTRY_FEATURES = {
5555
}
5656
```
5757

58-
## Add your feature to the FeatureManager
58+
### Add your feature to the FeatureManager
5959

6060
The `FeatureManager` handles the application features. We add all the features
6161
to the `FeatureManager`, including the type of feature we want to add to the
@@ -74,7 +74,7 @@ If you don't plan to use flagr don't pass this third parameter, for example:
7474
default_manager.add('organizations:test-feature', OrganizationFeature)
7575
```
7676

77-
## Add it to the Organization Model Serializer
77+
### Add it to the Organization Model Serializer
7878

7979
The Organization model serializer
8080
(`src/sentry/api/serializers/models/organization.py`) builds a list
@@ -101,9 +101,9 @@ if getattr(obj.flags, 'require_2fa'):
101101
feature_list.append('require-2fa')
102102
```
103103

104-
# Checking your feature
104+
## Checking your feature
105105

106-
## In Python code
106+
### In Python code
107107

108108
The FeatureManager's `has` method checks see if the feature exists. The has
109109
method takes in the feature's name, the object that corresponds to the scope of
@@ -121,13 +121,13 @@ the organization and the type of user given. Note that when we give the feature
121121
to the frontend, we remove the scope prefix, and
122122
our `'organizations:test-feature'` becomes `'test-feature'`.
123123

124-
## In JavaScript
124+
### In JavaScript
125125

126126
There is a difference between using the flag in Sentry and in GetSentry. At this
127127
stage you're not quite ready to use your feature flag in GetSentry, but you are
128128
able to use it inside Sentry.
129129

130-
## Declarative features with the Feature component
130+
### Declarative features with the Feature component
131131

132132
React uses a declarative programming paradigm. As such, we have a utility
133133
component that we use to hide components based on the feature flags available to
@@ -143,7 +143,7 @@ const toRender = (
143143
);
144144
```
145145

146-
## Imperative feature flag checks
146+
### Imperative feature flag checks
147147

148148
There are some exceptions when React components are generated imperatively (e.g.
149149
headers/columns for Tables). In difficult times like these, the `Organization`
@@ -157,7 +157,7 @@ const {organization} = this.props;
157157
organization.features.includes('test-feature'); // evals to True/False
158158
```
159159

160-
# Enabling features in development
160+
## Enabling features in development
161161

162162
In Sentry you can run `sentry devserver` to view your changes in development
163163
mode. If you would like to view a change behind a feature flag, you will need to
@@ -173,7 +173,7 @@ SENTRY_FEATURES['organizations:test-feature'] = True
173173
Where `SENTRY_FEATURES` will correspond to the `SENTRY_FEATURES` from `step 2`.
174174
Set it to `True` if you'd like the feature to be available and `False` if not.
175175

176-
## Flagr in development
176+
### Flagr in development
177177

178178
In general, you do not need to run flagr in development to test your feature
179179
flagging. If you do want to run flagr, you'll need to be running
@@ -185,7 +185,7 @@ flagging. If you do want to run flagr, you'll need to be running
185185
Your local instance of flagr can be found at
186186
[localhost:18000](http://localhost:18000/#/)
187187

188-
# Enabling your feature in production
188+
## Enabling your feature in production
189189

190190
Feature flags are declared in Sentry's codebase. For self-hosted users, those
191191
flags are then configured via `sentry.conf.py`. For Sentry's SaaS deployment,
@@ -241,7 +241,7 @@ must be matched for a feature to be enabled.
241241
Represents the distribution of variants in a segment, because we'll only have
242242
one variant this value should always be 100% for each segment.
243243

244-
## Creating a segment constraint
244+
### Creating a segment constraint
245245

246246
When creating a segment, without the distribution set, Flagr will respond as if
247247
the segment doesn't exist yet. This means that if you're creating or modifying a
@@ -382,14 +382,43 @@ your feature.
382382

383383
## After launch (Graduation)
384384

385-
After your feature has been mainlined and is available for all hosted customers:
385+
After your feature has been mainlined and is available for all customers on
386+
sentry.io, you have a few potential paths:
386387

387-
- If the feature cannot be disabled, or if no application specific overrides are required, remove the feature flag and all related checks from the Sentry code base. If necessary, also remove references to the feature from the [onpremise](https://github.com/getsentry/onpremise) and getsentry repositories.
388-
- If the feature flag controls a behavior specific to Sentry SaaS, leave it disabled in Sentry and add appropriate feature handlers in getsentry (see below). In this case, keep in mind that the feature is also disabled during development.
389-
- If the feature is generally available but is constrained to specific organizations or projects on Sentry SaaS, enable the feature by default in in [`conf/server.py`](https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py) and add appropriate feature handlers in getsentry. This ensures that the feature is enabled in development and self-hosted Sentry installations.
390-
- If the feature was enabled through flagr, delete the feature from the Flagr UI. This is done by navigating to the flag configuration page then clicking **Delete Flag** at the bottom of the page.
388+
- If the feature cannot be disabled, or you don't need to conditionally disable
389+
the feature, remove the feature flag and all related checks from the Sentry
390+
code base. If necessary, also remove references to the feature from the
391+
[onpremise](https://github.com/getsentry/onpremise) and getsentry
392+
repositories.
393+
- If the feature will only be available to SaaS customers on specific plans, you
394+
need to add your feature flag to the appropriate plans and update feature
395+
handlers (see below).You should also enable the feature by default in
396+
[`conf/server.py`](https://github.com/getsentry/sentry/blob/master/src/sentry/conf/server.py)
397+
in sentry to ensure that the feature is available for self-hosted deployments.
391398

392-
To override features in getsentry, follow these steps:
399+
Finally, if your feature was enabled through flagr, delete the feature from the
400+
Flagr UI. This is done by navigating to the flag configuration page then
401+
clicking **Delete Flag** at the bottom of the page.
402+
403+
404+
## Getsentry feature handlers
405+
406+
Getsentry contains a variety of feature handlers that override the
407+
`SENTRY_FEATURES` map.
408+
409+
### Plan specific features
410+
411+
If your feature is available for a subset of plans (eg. only on Business plans)
412+
you need to:
413+
414+
1. Disable the feature in `getsentry/conf/settings/defaults.py` by updating `SENTRY_FEATURES`.
415+
2. Add your feature to the appropriate plan feature list.
416+
3. Update `SubscriptionPlanFeatureHandler` to handle your feature.
417+
418+
### Custom handlers
419+
420+
If your feature requires additional logic to become active, you can also
421+
implement a feature handler in getsentry, follow these steps:
393422

394423
1. Disable the feature in `getsentry/conf/settings/defaults.py` by updating `SENTRY_FEATURES`.
395424
2. Add a new feature handler class in `getsentry/features.py` that determines availability of the feature based on the organization or actor.

0 commit comments

Comments
 (0)