Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(27255): allow local modification for remote feature flags #29696

Merged
merged 55 commits into from
Feb 21, 2025

Conversation

DDDDDanica
Copy link
Contributor

@DDDDDanica DDDDDanica commented Jan 14, 2025

Description

Note

You can now follow the steps here to review the PR.

Local Feature Flag Override System

This PR implements a system that allows developers to override remote feature flags locally through manifest.json, providing more flexibility in development and testing environments.

Key Features

  1. Local Feature Flag Override

    • Developers can override remoteFeatureFlag values by defining them in .manifest-overrides.json
    • These overrides take precedence over values received from the controller
    • Accessible in all development environments:
      • Local builds
      • Webpack builds
      • E2E tests
  2. Testing Integration

    • Leverages the manifest system introduced in PR #26588
    • Allows custom remoteFeatureFlag objects to be passed within test withFixtures
    • Simplifies feature flag testing scenarios
  3. Developer Validation

    • Override values can be verified through the developer options panel
    • Provides immediate feedback on applied feature flag settings

This enhancement streamlines the development workflow by providing local control over feature flags without requiring changes to the controller or deployment configurations.

Usage Example

A. Local build

  1. Define overrides in remoteFeatureFlags in .manifest-overrides.json:
{
  "_flags": {
    "remoteFeatureFlags": {
      "testFlagForThreshold": {
        "name": "test-flag",
        "value": "121212"
      }
    }
  }
}
  1. Verify in Developer Options:
    • Open extension
    • Click on the account menu (top-right corner)
    • Select "Settings" > "Developer Options"
    • Look for "Remote Feature Flags" section to verify your overrides
Screenshot 2025-01-14 at 00 48 22

B. e2e test

Add the customized value in

fixtures: new FixtureBuilder()
          .withMetaMetricsController({
            metaMetricsId: MOCK_META_METRICS_ID,
            participateInMetaMetrics: true,
          })
          .build(),
           manifestFlags: {
                    remoteFeatureFlags: MOCK_CUSTOMIZED_REMOTE_FEATURE_FLAGS,
                  },

Open in GitHub Codespaces

Related issues

Fixes: #27255

Manual testing steps

Please check <### Usage Example> above to check how to test manually.

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-extension-platform Extension Platform team label Jan 14, 2025
@DDDDDanica
Copy link
Contributor Author

@metamaskbot update-policies

Copy link

socket-security bot commented Jan 14, 2025

No dependency changes detected. Learn more about Socket for GitHub ↗︎

👍 No dependency changes detected in pull request

@metamaskbot
Copy link
Collaborator

Policy update failed. You can review the logs or retry the policy update here

@DDDDDanica DDDDDanica force-pushed the feature/remote-feature-flags-manifest-adaption branch 2 times, most recently from 1e9217f to 1905574 Compare January 14, 2025 14:48
@DDDDDanica DDDDDanica self-assigned this Jan 14, 2025
@DDDDDanica
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policy update failed. You can review the logs or retry the policy update here

@DDDDDanica DDDDDanica force-pushed the feature/remote-feature-flags-manifest-adaption branch from 1905574 to ced7bf4 Compare January 14, 2025 15:01
@DDDDDanica
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@DDDDDanica DDDDDanica force-pushed the feature/remote-feature-flags-manifest-adaption branch 5 times, most recently from 704d4ab to 511c2d5 Compare January 15, 2025 20:53
@DDDDDanica
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@DDDDDanica DDDDDanica force-pushed the feature/remote-feature-flags-manifest-adaption branch from 6ccfac6 to 804e3d7 Compare January 15, 2025 21:18
@DDDDDanica
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Builds ready [804e3d7]
Page Load Metrics (1723 ± 60 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint45620351587392188
domContentLoaded15032022169712661
load15242036172312560
domInteractive24187493617
backgroundConnect85926168
firstReactRender1698362612
getState575252411
initialActions01000
loadScripts11321539127810952
setupStore511711
uiStartup17742603202619794
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 260 Bytes (0.00%)
  • ui: 869 Bytes (0.01%)
  • common: 233 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

Builds ready [16c667e]
Page Load Metrics (1860 ± 60 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint43020891774334160
domContentLoaded16822062183212661
load17052089186012660
domInteractive28663795
backgroundConnect77124178
firstReactRender1783472412
getState773182010
initialActions01000
loadScripts12441585138110651
setupStore662252311
uiStartup19702466213614067
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 260 Bytes (0.00%)
  • ui: 869 Bytes (0.01%)
  • common: 233 Bytes (0.00%)

@DDDDDanica
Copy link
Contributor Author

Walk through the PR changes from here -

/**
* Feature flags to control business logic behavior
*/
remoteFeatureFlags?: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Include the type of remoteFeatureFlags in manifest as optional value. We include testFlagForThreshold that's created for testing purpose in remote feature flag API .

@@ -11,6 +11,7 @@ const baradDurManifest = isManifestV3
? require('../../app/manifest/v3/_barad_dur.json')
: require('../../app/manifest/v2/_barad_dur.json');
const { loadBuildTypesConfig } = require('../lib/build-type');
const manifestFlags = require('../../manifest-flags.json');
Copy link
Contributor Author

@DDDDDanica DDDDDanica Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Read customized manifestFlags from manifest-flags.json so we can override the one from controller (API) - old build system

@@ -1,3 +1,5 @@
import manifestFlags from '../../../../../manifest-flags.json';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Read customized manifestFlags from manifest-flags.json so we can override the one from controller (API) - webpack build

@@ -47,8 +48,10 @@ function createManifestTasks({
browserVersionMap[platform],
await getBuildModifications(buildType, platform),
customArrayMerge,
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Add customized local manifestFlags to manifest file (old build system)

@HowardBraham HowardBraham dismissed their stale review February 19, 2025 21:30

Changes made

@metamaskbot
Copy link
Collaborator

Builds ready [4248edf]
Page Load Metrics (1641 ± 46 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1525183316509345
domContentLoaded1459176816199043
load1471182916419546
domInteractive25110422512
backgroundConnect106428199
firstReactRender1495292411
getState56212147
initialActions01000
loadScripts1047131511797637
setupStore889332713
uiStartup17232552192018790
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -6.64 KiB (-0.11%)
  • ui: 762 Bytes (0.01%)
  • common: 19.7 KiB (0.21%)

@metamaskbot
Copy link
Collaborator

Builds ready [1071e2b]
Page Load Metrics (1663 ± 46 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint47618951600271130
domContentLoaded15191886164410149
load1528189516639546
domInteractive2393382210
backgroundConnect96325178
firstReactRender1479362512
getState55011126
initialActions01000
loadScripts1093146812038340
setupStore76019189
uiStartup17592168190211154
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -6.64 KiB (-0.11%)
  • ui: 767 Bytes (0.01%)
  • common: 19.7 KiB (0.21%)

@metamaskbot
Copy link
Collaborator

Builds ready [dcb78e3]
Page Load Metrics (1998 ± 150 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint35025121897458220
domContentLoaded161024811967314151
load162025141998312150
domInteractive25187553818
backgroundConnect1080342211
firstReactRender1583402512
getState65919168
initialActions00000
loadScripts116319131460263126
setupStore86122189
uiStartup185628402259340163
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -6.64 KiB (-0.11%)
  • ui: 767 Bytes (0.01%)
  • common: 19.7 KiB (0.21%)

@metamaskbot
Copy link
Collaborator

Builds ready [96fe46d]
Page Load Metrics (1824 ± 84 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22921571539613294
domContentLoaded15452101179116177
load15542158182417684
domInteractive25110412010
backgroundConnect8124403818
firstReactRender1475362412
getState55619188
initialActions01000
loadScripts11081537130313464
setupStore7511394
uiStartup18132453207118689
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -6.64 KiB (-0.11%)
  • ui: 767 Bytes (0.01%)
  • common: 19.7 KiB (0.21%)

@metamaskbot
Copy link
Collaborator

Builds ready [5ad5fdb]
Page Load Metrics (1873 ± 90 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14612349186818388
domContentLoaded14512296184318086
load14632350187318790
domInteractive258541178
backgroundConnect126529199
firstReactRender1479382512
getState65512136
initialActions00000
loadScripts10371772135515977
setupStore86320209
uiStartup17582655213919393
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -6.64 KiB (-0.11%)
  • ui: 740 Bytes (0.01%)
  • common: 19.7 KiB (0.21%)

Copy link
Contributor

@davidmurdoch davidmurdoch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find one typo. Don't be mad 😅

Co-authored-by: David Murdoch <[email protected]>
@metamaskbot
Copy link
Collaborator

Builds ready [1e89e33]
Page Load Metrics (1811 ± 73 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint46320701689422203
domContentLoaded15442060178814670
load15492077181115173
domInteractive18102412211
backgroundConnect86027178
firstReactRender1574402211
getState566222311
initialActions01000
loadScripts11481565132212661
setupStore86518189
uiStartup17722413210517484
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -6.64 KiB (-0.11%)
  • ui: 740 Bytes (0.01%)
  • common: 19.7 KiB (0.21%)

@DDDDDanica DDDDDanica added this pull request to the merge queue Feb 21, 2025
Merged via the queue into main with commit 5a84737 Feb 21, 2025
79 checks passed
@DDDDDanica DDDDDanica deleted the feature/remote-feature-flags-manifest-adaption branch February 21, 2025 01:07
@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 2025
@metamaskbot metamaskbot added the release-12.14.0 Issue or pull request that will be included in release 12.14.0 label Feb 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.14.0 Issue or pull request that will be included in release 12.14.0 team-extension-platform Extension Platform team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modify each remote feature flags locally for testing purpose
9 participants