Adding a Feature Flag with FeatureToggle - department-of-veterans-affairs/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. For UAT and Prod envs these feature toggles are managed in our appeals-deployment repository in features-config.yml.
Enabling a feature in production (Tech Lead Only as part of a Deployment Request)
- Either find your flag or add it under features_config -> certification -> prod in features-config.yml.
# Example of config_file:
# [
# {
# feature: "enable_all_feature",
# enable_all: true # this can only be a value of true
# },
# {
# feature: "enable_users",
# users: ["VHAISADJURIN", "VHAISAPROKOA", "VHAISWSTEWAA"]
# },
# {
# feature: "enable_regional_offices",
# users: ["CSS_ID_1"],
# regional_offices: ["RO01"]
# }
# ]
- 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
A script sets all FeatureFlags found in the code to active in dev scripts/enable_features_dev.rb
- Use
make enable-feature-flags
to run this script. - This is also part of
make reset
. - This script scans files for
FeatureToggle.enabled
orfeature_enabled
. - To prevent a toggle from being enabled by this script add it to this array
- 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 |
---|---|---|---|---|---|---|---|---|
acd_cases_tied_to_judges_no_longer_with_board | Cases Tied to Judges No Longer with the Board or Otherwise Ineligible | |||||||
acd_disable_legacy_lock_ready_appeals | LOCK_READY_APPEALS | |||||||
acd_distribute_by_docket_date | By Docket Date | |||||||
acd_exclude_from_affinity | Named Judge Affinity Inclusion Levers | Named Judge Affinity Inclusion Levers | MoonWalkers ๐ | Q1 2024 | ||||
alert_duplicate_veterans | ||||||||
api_v3 | ||||||||
appeal_viz | ||||||||
async_manual_start | Manually running Scheduled Jobs | |||||||
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 | |||
cavc_dashboard_workflow | In development | |||||||
ce_api_demo_toggle | Feature toggle to enable or disable the mocked Claim Evidence API success/failure response on Demo environments and local. | APPEALS-27311 and APPEALS-27458 | ||||||
cc_vacatur_visibility | Controls the visibility of the task descriptions for motions to vacate in case timeline | In development | ||||||
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 | |||
justification_reason | Created for MST/PACT justification reason for adding/editing the MST/PACT status of an issue. This work was not enabled upon release but the work was hidden behind the justification_reason feature toggle in case it was needed in the future. Since this work was never released with MST/PACT, the toggle is disabled by default in disabled_flags within the file enabled_features_dev.rb . |
APPEALS-17497 and APPEALS-37777 | ||||||
legacy_das_deprecation | ||||||||
legacy_mst_pact_identification | Enable/disable MST/PACT special issue designation on Legacy appeals, and issues within Caseflow. | APPEALS-17497 and APPEALS-37777 | ||||||
mpi_nod_updates | Disables MPI NOD work for updating SFNOD in corres in VACOLS. | 10/13/2022 | IN DEV | |||||
mst_identification | Enable/disable MST special issue designation on Legacy/AMA appeals, request issues, and decision issues within Caseflow. | APPEALS-17497 and APPEALS-37777 | ||||||
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 | ||
pact_identification | Enable/disable PACT special issue designation on Legacy/AMA appeals, request issues, and decision issues within Caseflow. | APPEALS-17497 and APPEALS-37777 | ||||||
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 | ||
queue_correspondence | Enable/disable C&P correspondence mail package workflow within Caseflow Queue | APPEALS-27311 and APPEALS-27458 | ||||||
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 | |||
split_appeal_workflow | ||||||||
sys_admin_page | Allows system admins to access new admin page | APPEALS-10135 | 10/21/2022 | IN DEV | ||||
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 | ||||||||
vso_virtual_opt_in | Limits access to the Hearings section of the Case Details page for VSO users to allow for a limited release of the VSO Virtual Opt-In feature. | #17295 | ||||||
window_slider |