refactor(analytics): PR E1 rename addTraitsToUser to identify in mobile-core-ux files#30473
Conversation
…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).
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: The Affected components and their test coverage:
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: |
|



Description
Part of the analytics cleanup workstream (#26686).
Renames
.addTraitsToUser()→.identify()across all mobile-core-ux-owned Settings components and network hooks, and migratesAccountActions.tsxfrom the deprecateduseMetricstouseAnalytics. Also removes staleMetaMetrics/MetaMetrics.eventsmocks fromAccountsMenu.test.tsx.Files touched:
BlockaidSettings.tsx,DisplayNFTMediaSettings,BatchAccountBalanceSettings,AutoDetectTokensSettings,AutoDetectNFTSettings— rename.addTraitsToUser→.identifyuseNetworkOperations.ts,useAddPopularNetwork.ts,NetworkManager/index.tsx— rename.addTraitsToUser→.identifyAccountActions.tsx— migrateuseMetrics→useAnalyticsidentifyoverride increateMockUseAnalyticsHookAccountsMenu.test.tsx— remove stalejest.mock('../../../core/Analytics', ...)andjest.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
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
identifyalias.Overview
Updates mobile-core-ux components and network-related hooks to use
useAnalytics().identifyinstead of the deprecatedaddTraitsToUserfor updating analytics user traits (settings toggles and network add/remove flows).Migrates
AccountActionsoffuseMetricstouseAnalytics, and cleans up related unit tests by updating mocked hook return values and removing staleMetaMetrics/MetaMetrics.eventsmocks inAccountsMenu.test.tsx.Reviewed by Cursor Bugbot for commit 367f37e. Bugbot is set up for automated code reviews on this repo. Configure here.