feat: import newremote feature flag controller with override functionality
Description
This PR adds comprehensive override functionality to the RemoteFeatureFlagController that was added in this PR, allowing developers and users to locally override remote feature flags for testing and debugging purposes. The implementation also includes enhanced A/B test visibility features that provide access to available test groups.
What is the reason for the change? The need to override remote feature flags locally for development, testing, and debugging scenarios without modifying the remote configuration.
What is the improvement/solution?
- Added local override system that takes precedence over remote flags
- Enhanced state management to track both remote flags and local overrides separately
- Added A/B test raw flag storage to provide visibility into available test groups
- Implemented comprehensive API methods for managing overrides and accessing flag information
Changelog
CHANGELOG entry: Added override functionality to remote feature flags with methods to set, get, clear overrides and access A/B test groups
Related issues
Fixes:
Manual testing steps
Feature: Remote Feature Flag Override Functionality
Scenario: user sets a local override for a feature flag Given the RemoteFeatureFlagController is initialized with remote flags When user calls setFlagOverride('testFlag', true) Then testFlag selector should return the override value true And getFlagOverride('testFlag') should return true
Scenario: user clears a specific flag override Given a feature flag has a local override set When user calls clearFlagOverride('testFlag') Then testFlag selector should return the original remote value And getFlagOverride('testFlag') should return undefined
Scenario: user accesses A/B test groups Given remote flags contain A/B test configurations When user calls rawProcessedRemoteFeatureFlags selector Then it should return an array of available test groups with names and values
Screenshots/Recordings
Before
After
Pre-merge author checklist
- [x] I've followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards.
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using JSDoc format if applicable
- [x] I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
Pre-merge reviewer checklist
- [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.
The engine ready checks might not be necessary assuming this context is used in the right place. We already have a
ControllersGatethat blocks the majority of components from rendering before the engine is initialized. Can we rely on that instead?
Yes, correct, I don't think it is necessary at all. I had that logic because I was having trouble getting it to start I thought the issue was that the controller wasn't loading but it was because the controller was broken and wasn't building
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
| Diff | Package | Supply Chain Security |
Vulnerability | Quality | Maintenance | License |
|---|---|---|---|---|---|---|
| npm/@metamask/remote-feature-flag-controller@3.0.0 ⏵ 3.1.0 |
Codecov Report
:x: Patch coverage is 77.41935% with 14 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 79.31%. Comparing base (80b13d3) to head (236faec).
:warning: Report is 39 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| .../Views/FeatureFlagOverride/FeatureFlagOverride.tsx | 50.00% | 12 Missing and 2 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #23487 +/- ##
==========================================
+ Coverage 79.11% 79.31% +0.19%
==========================================
Files 4053 4057 +4
Lines 106578 106769 +191
Branches 21592 21642 +50
==========================================
+ Hits 84321 84679 +358
+ Misses 16379 16192 -187
- Partials 5878 5898 +20
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
🔍 Smart E2E Test Selection
- Selected E2E tags: SmokeCore, SmokeAccounts, SmokeConfirmationsRedesigned, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeRamps, SmokeMultiChainPermissions, SmokePerps, SmokePredictions
- Risk Level: high
- AI Confidence: 85%
click to see 🤖 AI reasoning details
This PR makes significant changes to the core feature flag system which is used throughout the entire application:
-
Package Update: The
@metamask/remote-feature-flag-controlleris upgraded from v3.0.0 to v3.1.0, introducing new controller methods for managing local overrides. -
Core Selector Changes: The
selectRemoteFeatureFlagsselector is modified to merge remote flags with local overrides. This selector is used in 50+ places across the codebase including:- Perps feature flags
- Predictions feature flags
- Carousel feature flags
- Earn/Staking feature flags
- Bridge configuration
- Notifications
- Network blacklist
- Solana testnet
- Gas fees sponsored
- OTA updates
- Homepage
- Token search discovery
- DeFi positions
- Confirmations redesign
- Multichain accounts
-
State Structure Changes: The
RemoteFeatureFlagControllerstate now includeslocalOverridesandrawRemoteFeatureFlagsfields, which affects the initial background state used in tests. -
Context API Changes: The
FeatureFlagOverrideContextnow delegates override management to the Engine's controller instead of local React state, which is a fundamental architectural change. -
New Feature Flag Types: Added support for A/B test feature flags (
FeatureFlagAbTest) which could affect how features are rolled out.
Given that feature flags control the behavior of virtually every major feature in the app, and this change modifies the core mechanism for how flags are retrieved and overridden, comprehensive testing is warranted. The changes could potentially affect any feature that relies on feature flags, which includes confirmations, staking, swaps, bridge, multichain accounts, and more.
Quality Gate passed
Issues
7 New issues
0 Accepted issues
Measures
0 Security Hotspots
80.3% Coverage on New Code
0.0% Duplication on New Code