Adding a Feature Flag with FeatureToggle - TISTATechnologies/caseflow GitHub Wiki
FeatureToggle
FeatureToggle allows us to hide features behind a flag. Using this we can safely release partial features, hold back new UI until users have been prepared, and selectively activate features for testing with specific users. These feature toggles are managed in our appeals-deployment repository in features-config.yml.
Enabling a feature in production
- Either find your flag or add it under features_config -> certification -> prod in features-config.yml.
- You can add which users or regional offices the feature should be enabled for by adding users' css_ids or regional office codes
- Create a PR (example) with your changes and grab a fellow caseflower to review.
- Either wait for the standard deployment at 10:45a EST or manually run the enable feature script in jenkins
- Look for a successful deploy in slack
Usage on the back end
Global
FeatureToggle.enable!(:foo)
Regional Office Specific
FeatureToggle.enable!(:bar, regional_offices: ["RO01", "RO02"])
User Specific
FeatureToggle.disable!(:bar, users: ["CSS_ID_1", "CSS_ID_2"])
current_user
for a feature flag where current_user
is in scope
Only use Depending on where the feature flag is used in the backend, the current_user
method may or may not be in scope. However, because the StubbableUser
module includes a current_user
method, tests will pass even if current_user
is used out of scope. As a result, incorrectly using current_user
for the user parameter of a feature toggle could introduce a bug that won’t break tests.
To avoid this situation, be sure to only use current_user
where it is in scope. To test the scenario where current_user
is out of scope, you can mock the current_user
method to throw an error.
Meta
Development Environment
Set all FeatureFlags to active in dev
scripts/enable_features_dev.rb
(NOTE this is run automatically as part of make reset
.)
Individual global features can be adjusted on the user selection page
Getting a FeatureFlag State
FeatureToggle.details_for(:foo)
- You must specify the scope at which you're checking the feature
state: if you check
enabled?
without specifying a user, the result will befalse
if the feature is only enabled for specific user/regional office.
FeatureToggle.enabled?(:bar, user: current_user)
NB: State checking methods receive User
objects, not Arrays
Getting the current FeatureFlags
FeatureToggle.features
=> [:appeals_status, :certification_v2, :reader]
Usage on the front end
In many parts of the caseflow application, we use the following pattern to pass feature flags to and check if they are enabled on the front end.
FeatureToggle
s are passed to a specific application through its index.html.erb file. This gives us the ability to check these feature toggles in specific components.
Currently Implemented Toggles
Toggle Name | Description | Related Epic/Tickets | Sprint Team | Created | Released | Paused | State | Notes |
---|---|---|---|---|---|---|---|---|
alert_duplicate_veterans | ||||||||
api_v3 | ||||||||
appeal_viz | ||||||||
attorney_fees | ||||||||
automatic_ramp_rollback | ||||||||
bgs_forward_proxy | ||||||||
cavc_remand | Controls the JMR & JMPR CAVC Remand flow access | JMR/JMPR CAVC Remand Entry & JMR/JMPR Task & Routing Logic | :dolphin: Echo | Dec 2020 | Feb 16, 2021 | |||
mdr_cavc_remand | Controls the MDR CAVC Remand flow access. Requires cavc_remand enabled |
:dolphin: Echo | Jan 2021 | |||||
reversal_cavc_remand | Controls the Straight Reversal CAVC Remand flow access. Requires cavc_remand enabled |
:dolphin: Echo | Jan 2021 | |||||
dismissal_cavc_remand | Controls the Death Dismissal CAVC Remand flow access. Requires cavc_remand enabled |
:dolphin: Echo | Jan 2021 | |||||
contestable_rating_decisions | ||||||||
correct_claim_reviews | ||||||||
covid_timeliness_exemption | ||||||||
detect_contention_exam | ||||||||
disability_issue_test | ||||||||
disable_claim_establishment | ||||||||
docket_switch | Related to work around enabling ClerkOfTheBoard users to initiate a docket switch |
#13978 | :fox_face: Foxtrot | |||||
edit_contention_text | ||||||||
inbox | ||||||||
judge_admin_scm | Related to work around allowing judge teams to have admins that are neither attorneys or judges | #11801 | :dolphin: Echo | PLANNED ROLLBACK | Was scrapped by board and has a planned rollback in #13991 | |||
legacy_das_deprecation | ||||||||
overtime_revamp | Determines whether judges can mark cases as overtime in caseflow #13418 | #13418 | :dolphin: Echo | 5/23/2020 | READY FOR PILOT | Will remove once enabled for all judges | ||
priority_acd | Determines whether the requested case distribution for a judge should use the updated distribution logic described in #14538 | #14538 | :dolphin: Echo | 6/29/2020 | IN DEV | Will remove once enabled for all judges | ||
ramp_intake | ||||||||
ratings_at_issue | ||||||||
release_db_connections | ||||||||
restrict_appeal_intakes | ||||||||
review_motion_to_vacate | ||||||||
schedule_virtual_hearings | Enables a dropdown in Hearing Details page to allow hearing coordinators to switch a video hearing to a virtual hearing | #11132 | :dancer: Tango | 10/25/2019 | 05/19/2020 | IN PROD | It's been enabled for all hearing coordinators (#14282) and will be removed | |
schedule_virtual_hearings_for_central | Enables a dropdown in Hearing Details page to allow hearing coordinators to switch a central hearing to a virtual hearing | #13804 | :dancer: Tango | WIP | It's being worked on in #13832 | |||
scm_view_judge_assign_queue | Gives members of the Case Movement team access to Judge Assign queues | #12423 | :dolphin: Echo | Might be ready to be removed? | ||||
send_original_dta_contentions | ||||||||
set_no_cache_headers | ||||||||
show_future_ratings | ||||||||
special_issues_revamp | Controls whether the four new contentions & validation applies for Queue (Atty Checkout and Judge Checkout) | #13423 | :dolphin: Echo | 8/3/2020 | FULLY RELEASED | To be removed after epic is user tested and fully released | ||
special_issues_revamp_dispatch | Controls whether the four new contentions & validation applies for Caseflow Dispatch | #13423 | :dolphin: Echo | OBE | Feature to be removed from Caseflow Dispatch completely | |||
unidentified_issue_decision_date | ||||||||
use_ama_activation_date | ||||||||
use_poa_claimants | ||||||||
user_queue_pagination | Determines whether or not a user's queue is paginated on the back end | #14142 | :dolphin: Echo | 7/30/2020 | FULLY RELEASED | To be removed after epic is user tested | ||
vbms_forward_proxy | ||||||||
vbms_pagination | ||||||||
verify_unidentified_issue | ||||||||
vso_claimant_representative | ||||||||
window_slider |