Skip to content

chore(analytics): migrate useMetrics→useAnalytics and MetricsEventBuilder→AnalyticsEventBuilder (assets files)#31251

Merged
NicolasMassart merged 3 commits into
mainfrom
analytics/pr3-assets
Jun 9, 2026
Merged

chore(analytics): migrate useMetrics→useAnalytics and MetricsEventBuilder→AnalyticsEventBuilder (assets files)#31251
NicolasMassart merged 3 commits into
mainfrom
analytics/pr3-assets

Conversation

@NicolasMassart

@NicolasMassart NicolasMassart commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Migrates assets-related test files from the legacy analytics system (useMetrics, MetricsEventBuilder, addTraitsToUser) to the new system (useAnalytics, AnalyticsEventBuilder, identify).

Part of the analytics migration cleanup series. All changes are in files owned by the assets team.

Files migrated: DeFiPositionsListItem.test.tsx, TokenList.test.tsx, TokenListItem.test.tsx, NftDetails.test.ts.

Note: TokenListItem.test.tsx has a pre-existing test failure on main unrelated to this change (tracked by #31019).

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
Changes are limited to test mocks and import paths; runtime wallet/assets behavior is unchanged.

Overview
Updates assets-team unit tests so mocks and assertions match the new analytics API—no production code changes.

DeFi / token list tests swap MetricsEventBuilder for AnalyticsEventBuilder (imports and jest.requireActual paths under util/analytics). DeFi navigation analytics expectations now build events with AnalyticsEventBuilder.createEventBuilder.

TokenList.test.tsx extends the useAnalytics mock with identify and a default isDataRecorded implementation so it mirrors the current hook surface.

TokenListItem.test.tsx loads MetaMetricsEvents from core/Analytics instead of the legacy useMetrics path for mUSD CTA event assertions.

NftDetails.test.ts aligns the useAnalytics mock with the new API (identify; drops unused legacy mock fields like addTraitsToUser / isDataRecorded where no longer needed).

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

…er->AnalyticsEventBuilder, addTraitsToUser->identify (assets files)

Migrates 4 asset-owned test files: TokenListItem (useMetrics), DeFiPositionsListItem
(MetricsEventBuilder), TokenList and NftDetails (identify rename).

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.

@mm-token-exchange-service mm-token-exchange-service Bot added the team-mobile-platform Mobile Platform team label Jun 9, 2026
@github-actions github-actions Bot added the size-S label Jun 9, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added INVALID-PR-TEMPLATE PR's body doesn't match template and removed INVALID-PR-TEMPLATE PR's body doesn't match template labels Jun 9, 2026
@NicolasMassart NicolasMassart marked this pull request as ready for review June 9, 2026 08:57
@NicolasMassart NicolasMassart requested a review from a team as a code owner June 9, 2026 08:57

@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 c428e99. Configure here.

Comment thread app/components/UI/Tokens/TokenList/TokenListItem/TokenListItem.test.tsx Outdated
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jun 9, 2026

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

Copy link
Copy Markdown

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: c428e99cf7

ℹ️ 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/UI/Tokens/TokenList/TokenListItem/TokenListItem.test.tsx Outdated
…enList mock

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added risk:low AI analysis: low risk and removed risk:medium AI analysis: medium risk labels Jun 9, 2026
@NicolasMassart NicolasMassart marked this pull request as draft June 9, 2026 09:43
…okenListItem test

Co-authored-by: Cursor <cursoragent@cursor.com>
@NicolasMassart NicolasMassart marked this pull request as ready for review June 9, 2026 10:39
@NicolasMassart NicolasMassart added this pull request to the merge queue Jun 9, 2026
Merged via the queue into main with commit bb43735 Jun 9, 2026
63 checks passed
@NicolasMassart NicolasMassart deleted the analytics/pr3-assets branch June 9, 2026 13:20
@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:low AI analysis: low risk size-S team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants