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(27256): implement remote feature flag feature #28684

Merged
merged 18 commits into from
Dec 3, 2024

Conversation

DDDDDanica
Copy link
Contributor

@DDDDDanica DDDDDanica commented Nov 25, 2024

Description

Open in GitHub Codespaces

Related issues

Fixes: #27256

Manual testing steps

  1. Load the extension
  2. Option 1: input chrome.storage.local.get(console.log) in dev tools console, and you'll find in data => RemoteFeatureFlagController => contains 2 dataset, cacheTimestamp and remoteFeatureFlags with value
  3. Option 2: go to settings => advanced, and click download stage logs button, you'll find remoteFeatureFlags with cached value in your state.
  4. Option 3: Settings => about page, if you open console in dev tools, there's a log after Feature flag fetched successfully, which will be removed after we implement 1st feature flag in production

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.

Copy link

sentry-io bot commented Nov 25, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: app/scripts/background.js

Function Unhandled Issue
setupController Error: Custom network client not found with ID '8f31c082-5580-4881-b948-616db1204095' ...
Event Count: 230 Affected Users: 0
initialize TypeError: e is not iterable /scripts/app-init.js
Event Count: 147 Affected Users: 0
setupController Error: NetworkController state is invalid: selectedNetworkClientId '54875d44-238f-416a-8033-765a3a2307... ...
Event Count: 71 Affected Users: 0

Did you find this useful? React with a 👍 or 👎

@DDDDDanica DDDDDanica force-pushed the feature/27256-remote-feature-flag branch 13 times, most recently from 3942cd2 to 9bddc8d Compare November 27, 2024 23:55
@@ -60,7 +61,7 @@ const mapStateToProps = (state, ownProps) => {
const {
metamask: { currencyRates },
} = state;

const remoteFeatureFlags = getRemoteFeatureFlags(state);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be removed after 1st feature flag is implemented in production

@@ -53,6 +57,13 @@ export default class InfoTab extends PureComponent {
componentDidMount() {
const { t } = this.context;
handleSettingsRefs(t, t('about'), this.settingsRefs);
if (this.props.remoteFeatureFlags.length > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be removed after 1st feature flag is implemented in production

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of (this.props.remoteFeatureFlags.length > 0, can we use an actual feature flag. So that this becomes something like

if (this.props.remoteFeatureFlags[TEST_FLAG] > 0) {
    console.log(

So we can fully demonstrate how teams would use the feature flag system?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, added 5204e9c

@@ -885,12 +884,16 @@ export function setupController(
senderUrl?.origin === `chrome-extension://${browser.runtime.id}`;
}

controller.remoteFeatureFlagController.getRemoteFeatureFlags();
Copy link
Contributor

Choose a reason for hiding this comment

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

we will need error handling here now

Copy link
Contributor

Choose a reason for hiding this comment

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

and should we remove the controller.remoteFeatureFlagController.getRemoteFeatureFlags() call on 887, because we have one on 896?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes this line is removed, it was for testing purpose 🙏🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Error handling within initializeRemoteFeatureFlags can be found 5204e9c

@DDDDDanica DDDDDanica force-pushed the feature/27256-remote-feature-flag branch from 0e78bb0 to e1c605a Compare November 28, 2024 17:43
app/scripts/background.js Outdated Show resolved Hide resolved
@DDDDDanica DDDDDanica force-pushed the feature/27256-remote-feature-flag branch 2 times, most recently from d6d0a91 to a2b12b6 Compare November 28, 2024 19:56
Copy link

socket-security bot commented Nov 28, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@DDDDDanica DDDDDanica self-assigned this Nov 28, 2024
@DDDDDanica DDDDDanica force-pushed the feature/27256-remote-feature-flag branch from a2b12b6 to 79cdc1c Compare November 28, 2024 21:31
@DDDDDanica DDDDDanica marked this pull request as ready for review November 28, 2024 21:33
@DDDDDanica DDDDDanica requested review from a team as code owners November 28, 2024 21:33
@DDDDDanica DDDDDanica force-pushed the feature/27256-remote-feature-flag branch 2 times, most recently from 517fd2c to 7421c8e Compare December 3, 2024 00:52
@DDDDDanica DDDDDanica requested a review from a team as a code owner December 3, 2024 00:52
@metamaskbot
Copy link
Collaborator

Builds ready [7421c8e]
Page Load Metrics (1790 ± 41 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1635195517928541
domContentLoaded1622194517658641
load1645195617908541
domInteractive246830126
backgroundConnect95223136
firstReactRender15381852
getState1093171415627
initialActions01000
loadScripts1188149213447636
setupStore77711157
uiStartup18852641209517986
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 10.38 KiB (0.19%)
  • ui: 420 Bytes (0.01%)
  • common: 169 Bytes (0.00%)

@DDDDDanica DDDDDanica force-pushed the feature/27256-remote-feature-flag branch from 7421c8e to 6d474f7 Compare December 3, 2024 01:51
@DDDDDanica
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

No policy changes

@metamaskbot
Copy link
Collaborator

Builds ready [6d474f7]
Page Load Metrics (2456 ± 138 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint28427841701924444
domContentLoaded183531372426299144
load189531512456288138
domInteractive30116582211
backgroundConnect776342311
firstReactRender17512894
getState1093231674421
initialActions01000
loadScripts142325471875260125
setupStore77514147
uiStartup221434792868329158
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 10.38 KiB (0.19%)
  • ui: 420 Bytes (0.01%)
  • common: 169 Bytes (0.00%)

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@metamaskbot
Copy link
Collaborator

Builds ready [2818e50]
Page Load Metrics (2185 ± 102 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint188626342190210101
domContentLoaded18632502215119795
load189225862185212102
domInteractive277641157
backgroundConnect883372412
firstReactRender17242031
getState983071474019
initialActions01000
loadScripts14162021165116981
setupStore78313168
uiStartup218333602528282135
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 10.38 KiB (0.19%)
  • ui: 420 Bytes (0.01%)
  • common: 144 Bytes (0.00%)

Copy link
Contributor

@itsyoboieltr itsyoboieltr left a comment

Choose a reason for hiding this comment

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

LGTM! great work on this!

@@ -1094,6 +1095,22 @@ export function setupController(
}
}

/**
* Initializes remote feature flags by making a request to fetch them from the clientConfigApi.
* This function is called when MM is during internal process.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* This function is called when MM is during internal process.
* This function is called during initialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

just left a small nit

@DDDDDanica DDDDDanica added this pull request to the merge queue Dec 3, 2024
Merged via the queue into main with commit 589d7e4 Dec 3, 2024
75 checks passed
@DDDDDanica DDDDDanica deleted the feature/27256-remote-feature-flag branch December 3, 2024 16:29
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 2024
@metamaskbot metamaskbot added the release-12.10.0 Issue or pull request that will be included in release 12.10.0 label Dec 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.10.0 Issue or pull request that will be included in release 12.10.0 team-extension-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Implement feature flags in extension
5 participants