Skip to content

refactor(analytics): PR E1 rename addTraitsToUser to identify in mobile-core-ux files#30473

Merged
NicolasMassart merged 1 commit into
mainfrom
refactor/26686_e1-core-ux_rename-identify
May 21, 2026
Merged

refactor(analytics): PR E1 rename addTraitsToUser to identify in mobile-core-ux files#30473
NicolasMassart merged 1 commit into
mainfrom
refactor/26686_e1-core-ux_rename-identify

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented May 20, 2026

Copy link
Copy Markdown
Contributor

Description

Part of the analytics cleanup workstream (#26686).

Renames .addTraitsToUser().identify() across all mobile-core-ux-owned Settings components and network hooks, and migrates AccountActions.tsx from the deprecated useMetrics to useAnalytics. Also removes stale MetaMetrics/MetaMetrics.events mocks from AccountsMenu.test.tsx.

Files touched:

  • BlockaidSettings.tsx, DisplayNFTMediaSettings, BatchAccountBalanceSettings, AutoDetectTokensSettings, AutoDetectNFTSettings — rename .addTraitsToUser.identify
  • useNetworkOperations.ts, useAddPopularNetwork.ts, NetworkManager/index.tsx — rename .addTraitsToUser.identify
  • AccountActions.tsx — migrate useMetricsuseAnalytics
  • Corresponding test files updated to use identify override in createMockUseAnalyticsHook
  • AccountsMenu.test.tsx — remove stale jest.mock('../../../core/Analytics', ...) and jest.mock('../../../core/Analytics/MetaMetrics.events', ...)

Changelog

CHANGELOG entry: null

Related issues

Closes: #26821
Refs: #26686

Manual testing steps

N/A

Screenshots/Recordings

Before

N/A — no UI changes.

After

N/A — no UI changes.

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, test affected areas)
  • I confirm that this PR addresses what is claimed in the PR title
  • I confirm that I've manually reviewed the changes if not manually tested

Made with Cursor


Note

Low Risk
Low risk refactor limited to analytics hook usage and test mocks, with minimal runtime behavior change beyond calling the new identify alias.

Overview
Updates mobile-core-ux components and network-related hooks to use useAnalytics().identify instead of the deprecated addTraitsToUser for updating analytics user traits (settings toggles and network add/remove flows).

Migrates AccountActions off useMetrics to useAnalytics, and cleans up related unit tests by updating mocked hook return values and removing stale MetaMetrics/MetaMetrics.events mocks in AccountsMenu.test.tsx.

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

…le-core-ux files

Renames `.addTraitsToUser()` → `.identify()` in all mobile-core-ux-owned
Settings components (BlockaidSettings, DisplayNFTMedia, BatchAccountBalance,
AutoDetectTokens, AutoDetectNFT), NetworkManager, useNetworkOperations,
and useAddPopularNetwork. Also migrates AccountActions.tsx from useMetrics
to useAnalytics. Removes stale MetaMetrics/MetaMetrics.events mocks from
AccountsMenu.test.tsx. Updates all corresponding test files.
Part of analytics cleanup workstream (#26686).
@NicolasMassart NicolasMassart self-assigned this May 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.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label May 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeNetworkAbstractions, SmokeAccounts, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 92%
click to see 🤖 AI reasoning details

E2E Test Selection:
All changes in this PR are a pure refactoring: replacing the deprecated addTraitsToUser method with the new identify method from useAnalytics. Both methods call the exact same underlying function (analytics.identify(userTraits)), so there is no behavioral change.

The AccountActions.tsx change additionally migrates from useMetrics to useAnalytics, but both hooks expose the same trackEvent and createEventBuilder API.

Affected components and their test coverage:

  1. NetworkManager, useAddPopularNetwork, useNetworkOperationsSmokeNetworkAbstractions covers network management UI, adding popular networks, and network operations.
  2. AccountActions.tsxSmokeAccounts covers account action menus and account management flows.
  3. BlockaidSettings.tsxSmokeConfirmations covers Blockaid security alert integration.
  4. Settings components (AutoDetectNFT, AutoDetectTokens, BatchAccountBalance, DisplayNFTMedia) → These are settings toggles; covered by the above tags as regression.

No performance-impacting changes were made (no rendering, state management, or data loading changes). The test files are updated to match the refactored code with no logic changes.

Performance Test Selection:
All changes are pure analytics method renaming (addTraitsToUser → identify) with no impact on rendering performance, data loading, state management, or any user-facing behavior. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@NicolasMassart NicolasMassart marked this pull request as ready for review May 21, 2026 08:52
@NicolasMassart NicolasMassart requested a review from a team as a code owner May 21, 2026 08:52
@NicolasMassart NicolasMassart moved this to Needs dev review in PR review queue May 21, 2026
@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue May 21, 2026
@NicolasMassart NicolasMassart added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit b9d8a78 May 21, 2026
322 of 339 checks passed
@NicolasMassart NicolasMassart deleted the refactor/26686_e1-core-ux_rename-identify branch May 21, 2026 11:33
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-S team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

PR E1: rename addTraitsToUser to identify in mobile-core-ux files already on useAnalytics

2 participants