Skip to content

refactor(analytics): C2 migrate network, accounts, and permissions to useAnalytics#27748

Merged
NicolasMassart merged 4 commits into
mainfrom
refactor/26686_c2_network-accounts-permissions
Mar 23, 2026
Merged

refactor(analytics): C2 migrate network, accounts, and permissions to useAnalytics#27748
NicolasMassart merged 4 commits into
mainfrom
refactor/26686_c2_network-accounts-permissions

Conversation

@NicolasMassart
Copy link
Copy Markdown
Contributor

@NicolasMassart NicolasMassart commented Mar 20, 2026

Description

Part of the analytics cleanup effort (#26686). This PR migrates network, accounts, and permissions files from the deprecated useMetrics hook and MetricsEventBuilder to the new useAnalytics hook and AnalyticsEventBuilder.

Renames applied across 24 files:

  • useMetricsuseAnalytics
  • MetricsEventBuilderAnalyticsEventBuilder
  • addTraitsToUseridentify
  • getMetaMetricsIdgetAnalyticsId

Test mocks updated to match the new API shape (adds identify mock, uses jest.mocked() pattern).

Changelog

CHANGELOG entry: null

Related issues

Refs: #26813

Manual testing steps

N/A — purely mechanical rename with no behavior change. Existing unit tests updated and passing.

Screenshots/Recordings

Before

N/A

After

N/A

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.

Note

Low Risk
Mostly mechanical analytics API migration; primary risk is missed hook import or mismatched method names causing analytics calls (or tests) to break at runtime.

Overview
Migrates several network, accounts, and permissions UI surfaces from deprecated useMetrics/MetricsEventBuilder to the newer useAnalytics/AnalyticsEventBuilder, keeping the same event tracking behavior.

Updates places that previously set user traits during network add/update flows to call identify instead of addTraitsToUser, and refactors Jest mocks to the new hook shape using createMockUseAnalyticsHook.

Written by Cursor Bugbot for commit 861220b. This will update automatically on new commits. Configure here.

@NicolasMassart NicolasMassart self-assigned this Mar 20, 2026
@github-actions
Copy link
Copy Markdown
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-mobile-platform Mobile Platform team label Mar 20, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Mar 20, 2026
@NicolasMassart NicolasMassart changed the title refactor(analytics): migrate network, accounts, and permissions to useAnalytics refactor(analytics): C2 migrate network, accounts, and permissions to useAnalytics Mar 23, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review March 23, 2026 11:47
@NicolasMassart NicolasMassart requested review from a team as code owners March 23, 2026 11:47
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b811c4585

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/components/Views/AccountActions/AccountActions.tsx Outdated
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 23, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/Views/AccountActions/AccountActions.tsx Outdated
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.46%. Comparing base (fbfbf17) to head (40b1dae).
⚠️ Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
.../DeprecatedNetworkModal/DeprecatedNetworkModal.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27748      +/-   ##
==========================================
+ Coverage   82.41%   82.46%   +0.04%     
==========================================
  Files        4804     4801       -3     
  Lines      124015   123794     -221     
  Branches    27634    27597      -37     
==========================================
- Hits       102210   102083     -127     
+ Misses      14724    14639      -85     
+ Partials     7081     7072       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

AccountActions.tsx is owned by @MetaMask/mobile-core-ux, which would
add a second extra code owner to this PR. Deferring to C3 where other
mobile-core-ux files are already planned.
@NicolasMassart NicolasMassart removed the request for review from a team March 23, 2026 15:55
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeMultiChainAPI, SmokeAccounts, SmokeWalletPlatform, SmokeIdentity, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR migrates multiple components from the deprecated useMetrics hook to the new useAnalytics hook. While this is primarily a refactoring change (same analytics functionality, different hook), it touches critical user-facing flows that must be validated:

  1. AccountConnect / MultichainAccountConnect - dApp connection flows: analytics tracking during connect/disconnect must work. Affects SmokeNetworkExpansion (Solana dApp connect), SmokeMultiChainAPI (CAIP-25 sessions), SmokeNetworkAbstractions (chain permissions).

  2. AccountPermissions / NetworkPermissionsConnected - Permission management UI: analytics events during permission grant/revoke. Affects SmokeNetworkAbstractions, SmokeMultiChainAPI, SmokeNetworkExpansion.

  3. PermissionApproval - The approval flow component used when dApps request permissions. Critical for all dApp connection tests.

  4. AccountRightButton - Browser account button, used in dApp interaction flows.

  5. BackupAndSyncToggle / BackupAndSyncFeaturesToggles - Identity sync settings. Affects SmokeIdentity.

  6. NetworkModal / DeprecatedNetworkModal - Network addition flows with addTraitsToUseridentify rename. Affects SmokeNetworkAbstractions.

  7. AddAccountActions / MultichainAddWalletActions - Account creation flows. Affects SmokeAccounts, SmokeWalletPlatform.

The identify vs addTraitsToUser rename in NetworkModal is a slight behavioral change worth validating. All other changes are pure hook swaps. SmokeConfirmations is included because PermissionApproval is part of the confirmation/approval flow system. SmokeWalletPlatform and SmokeAccounts cover multi-SRP and account management flows touched by AddAccountActions changes. SmokeIdentity covers BackupAndSync components.

Performance Test Selection:
This PR is a pure refactoring change migrating from useMetrics to useAnalytics hook. No UI rendering changes, no data loading changes, no state management changes, and no performance-sensitive code paths are modified. The analytics hook swap does not affect rendering performance, asset loading, or any measured performance metrics.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Mar 23, 2026
@NicolasMassart NicolasMassart added this pull request to the merge queue Mar 23, 2026
Merged via the queue into main with commit 6d23927 Mar 23, 2026
109 of 110 checks passed
@NicolasMassart NicolasMassart deleted the refactor/26686_c2_network-accounts-permissions branch March 23, 2026 18:35
@github-project-automation github-project-automation Bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Mar 23, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 23, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 23, 2026
@gantunesr
Copy link
Copy Markdown
Member

Forgot to add to the approval comment, I just reviewed the Accounts CO files and not the entire PR

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.72.0 Issue or pull request that will be included in release 7.72.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants