Skip to content

chore(analytics): migrate useMetrics→useAnalytics, MetricsEventBuilder→AnalyticsEventBuilder, addTraitsToUser→identify (unowned files)#31249

Merged
NicolasMassart merged 7 commits into
mainfrom
analytics/pr1-unowned
Jun 9, 2026
Merged

chore(analytics): migrate useMetrics→useAnalytics, MetricsEventBuilder→AnalyticsEventBuilder, addTraitsToUser→identify (unowned files)#31249
NicolasMassart merged 7 commits into
mainfrom
analytics/pr1-unowned

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Migrates the remaining unowned files from the legacy analytics system (useMetrics, MetricsEventBuilder, addTraitsToUser) to the new system (useAnalytics, AnalyticsEventBuilder, identify).

This is part of the analytics migration cleanup series. These files have no CODEOWNERS entry, so this PR can be reviewed and merged by any mobile-platform contributor.

Files migrated:

  • DeleteWalletModal/index.tsxuseMetricsuseAnalytics
  • AccountStatus/index.tsxuseMetricsuseAnalytics
  • backupUtils.tsaddTraitsToUseridentify
  • Various test files — updated mocks and stale mock removal

Changelog

CHANGELOG entry: null

Related issues

Refs: #26686

Manual testing steps

N/A — analytics-only refactor, no behaviour change.

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
  • I've tested with a power user scenario
  • I've instrumented key operations with Sentry traces for production performance metrics

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.

Made with Cursor


Note

Low Risk
Refactor-only import and API renames with test mock updates; no intended change to analytics payloads or user-facing behavior.

Overview
Finishes analytics cleanup for unowned files by swapping legacy MetricsEventBuilder / useMetrics usage for AnalyticsEventBuilder (util/analytics) and useAnalytics, with onboarding flows still going through trackOnboarding.

Production: DeleteWalletModal, AccountStatus, and backupUtils now build events via AnalyticsEventBuilder.createEventBuilder instead of the core metrics builder (same events and properties).

Tests: Perf/unit tests mock useAnalytics instead of useMetrics; several suites adopt createMockUseAnalyticsHook / createMockEventBuilder; NetworksManagementView mock uses identify instead of addTraitsToUser; TrendingView drops withMetricsAwareness from the mock.

Reviewed by Cursor Bugbot for commit 97a1919. Bugbot is set up for automated code reviews on this repo. Configure here.

NicolasMassart and others added 2 commits June 8, 2026 20:46
…r->identify (unowned files)

Migrates 5 test files from useMetrics to useAnalytics and renames addTraitsToUser
to identify in 2 test files. Also removes stale addTraitsToUser mock field from
FeatureFlagOverride test (PR1 cleanup item - verify gate prerequisite for PR8).

Files:
- DeepLinkModal.perf-test.tsx
- TrendingView.test.tsx
- NetworkMultiSelector.test.tsx (useMetrics + identify rename)
- useNetworkConnectionBanner.test.tsx
- GestureWebViewWrapper.test.tsx
- NetworksManagementView.test.tsx (identify rename)
- FeatureFlagOverride.test.tsx (stale mock cleanup)

Co-authored-by: Cursor <cursoragent@cursor.com>
…in additional unowned files

Migrates DeleteWalletModal, AccountStatus, backupUtils, and SRP tests from
MetricsEventBuilder to AnalyticsEventBuilder.

Co-authored-by: Cursor <cursoragent@cursor.com>
@NicolasMassart NicolasMassart self-assigned this Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

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.

…mentation instead of jest.fn()

Co-authored-by: Cursor <cursoragent@cursor.com>
NicolasMassart and others added 2 commits June 9, 2026 11:13
…ountStatus test

Co-authored-by: Cursor <cursoragent@cursor.com>
…ntStatus mock

Co-authored-by: Cursor <cursoragent@cursor.com>
@NicolasMassart NicolasMassart marked this pull request as ready for review June 9, 2026 10:55
@NicolasMassart NicolasMassart requested a review from a team as a code owner June 9, 2026 10:55
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jun 9, 2026
Comment thread app/components/UI/DeleteWalletModal/index.tsx
… AccountStatus test

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added risk:medium AI analysis: medium risk and removed risk:low AI analysis: low risk labels Jun 9, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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.

Reviewed by Cursor Bugbot for commit 73e4c1d. Configure here.

Comment thread app/util/onboarding/backupUtils.ts
@NicolasMassart NicolasMassart enabled auto-merge June 9, 2026 13:00
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps
  • Selected Performance tags: @PerformanceAccountList, @PerformanceOnboarding, @PerformanceLogin, @PerformanceSwaps, @PerformanceLaunch, @PerformanceAssetLoading, @PerformancePredict, @PerformancePreps
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (global-infrastructure-change): Global infrastructure changed: app/components/hooks/useNetworkConnectionBanner/useNetworkConnectionBanner.test.tsx. Running all tests.

Performance Test Selection:
Hard rule (global-infrastructure-change): Global infrastructure changed: app/components/hooks/useNetworkConnectionBanner/useNetworkConnectionBanner.test.tsx. Running all tests.

View GitHub Actions results

@NicolasMassart NicolasMassart added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit a9337cb Jun 9, 2026
117 of 119 checks passed
@NicolasMassart NicolasMassart deleted the analytics/pr1-unowned branch June 9, 2026 14:24
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.82.0 Issue or pull request that will be included in release 7.82.0 label Jun 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.82.0 Issue or pull request that will be included in release 7.82.0 risk:medium AI analysis: medium risk size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants