It would be a good idea to add some reliable feature flag implementation.
Basics
Features should be defined as simply as possible, in the codebase/config.
Implementation in the ruby codebase should be robust and not introduce too many conditionals.
A javascript implementation is needed - this might just be an object injected into the global state by the backend. It must be easy/clean to use.
Implementation in the routes file should provide a nice DSL
Avoids hitting the database unless absolutely needed
A mapping table between features and users should exist.
Features are always on in development unless FEATURE_FLAG_ENV=xxxxx is set. In this case, it should load the flags for the specified environment.
Config could look like this:
- code: feature-2fa
title: Two Factor Authentication
environments:
production: on / off / configurable
staging: on / off / configurable
Where the code is used in the codebase conditionals and DSLs, the title is used in any admin panels and the environments apply:
* `on` - On for all users (conditionals can be removed in due course)
* `off` - off for all users (off for all users, used to ship incomplete development code)
* `configurable` - Queries the user model to see if the feature is on for them.
Even better
A page in the admin panel that shows the YAML file and the status of any configurable features in a nice way, for customer support staff.
The ability to "flip" the feature on a per-user (or per-"entity") basis from the admin panel.
Ideally, it should be possible to add an arbitrary number of environments to the yaml file.
A generator to create a new "feature". This should append an item to the YAML file with all environments switched to off and also add the correct conditionals to the other scaffolding created. This will depend on having a good scaffolding generator set up, which is a separate piece of work.
Gotchas
Thread safety
Pain of maintainability
Crusty old conditionals left over from flags that are on for everyone.
It would be a good idea to add some reliable feature flag implementation.
Basics
FEATURE_FLAG_ENV=xxxxx
is set. In this case, it should load the flags for the specified environment.Config could look like this:
Where the
code
is used in the codebase conditionals and DSLs, the title is used in any admin panels and the environments apply:Even better
Gotchas
on
for everyone.OTS Solutions
These may be more robust:
Other things to consider