Skip to content

fix: add hasPerpsMarket to token details opened event cp-7.73.0#28242

Merged
sahar-fehri merged 12 commits into
mainfrom
fix/update-token-details-opened-event
Apr 3, 2026
Merged

fix: add hasPerpsMarket to token details opened event cp-7.73.0#28242
sahar-fehri merged 12 commits into
mainfrom
fix/update-token-details-opened-event

Conversation

@sahar-fehri

@sahar-fehri sahar-fehri commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Description

Updates the TOKEN_DETAILS_OPENED analytics event to include has_perps_market and severity properties, providing richer context about the token details screen state when the event fires.

Changelog

CHANGELOG entry: adds event property to token details opened event

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

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

Medium Risk
Medium risk because it changes when TOKEN_DETAILS_OPENED fires by deferring until market insights and perps market data settle, which can impact analytics timing/volume. UI behavior is largely unchanged, but the added async coordination and stale-payload guarding could introduce missed/duplicated events if incorrect.

Overview
Enhances TOKEN_DETAILS_OPENED analytics to include has_perps_market and severity (from security data), and refactors the tracking so it fires only once per token+source.

Tracking is now deferred in TokenDetailsRouteWrapper until both market-insights display resolution and perps market lookup are settled, with a token-key guard to drop stale market-insights callbacks after navigation.

Updates AssetOverviewContent’s onMarketInsightsDisplayResolved callback to return { isDisplayed, severity } (instead of a boolean) and adjusts unit tests accordingly, plus adds an e2e page-object retry loop for reading the Perps balance value more reliably.

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

@sahar-fehri sahar-fehri requested a review from a team as a code owner April 1, 2026 09:36
@github-actions

github-actions Bot commented Apr 1, 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.

@github-actions github-actions Bot added size-M risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026
Comment thread app/components/UI/TokenDetails/Views/TokenDetails.tsx Outdated
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026
Comment thread app/components/UI/TokenDetails/Views/TokenDetails.tsx Outdated
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026
const [tokenDetailsOpenedFlushNonce, setTokenDetailsOpenedFlushNonce] =
useState(0);

const flushTokenDetailsOpenedIfReady = useCallback(() => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This fct decides whether it's time to fire the TOKEN_DETAILS_OPENED analytics event. It gates on two async data sources settling before it fires.
1-Market insights must have resolved

2- Perps market lookup must have settled

@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 1, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 1, 2026

@Prithpal-Sooriya Prithpal-Sooriya 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.

Nice!

@Prithpal-Sooriya

Copy link
Copy Markdown
Contributor

@cursoragent READ AND FOLLOW THESE MEMORY FILES:

Can you try fixing the failing E2E tests? I feel like it should be a nice simple fix.

@cursor

cursor Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Implemented a targeted E2E stability fix for the failing Perps smoke test path.

What I changed

File: tests/page-objects/Perps/PerpsTabView.ts

  • Hardened getBalance() to use Utilities.executeWithRetry(...) (20s / 1s interval).
  • Updated balance lookup order to:
    1. perps-market-balance-value (preferred)
    2. legacy perps-balance-value
    3. legacy perps-balance-button (last fallback only if visible)
  • Added a helper getBalanceFromElement(...) to centralize parsing.

Why this should fix the CI failure

The Android smoke failure was:

  • No views in hierarchy found ... "perps-balance-button" in perps-add-funds.spec.ts.

This fix prevents brittle early fallback to that legacy selector by waiting/retrying for the modern balance value element first.

Validation done

  • Confirmed failing job/test from GitHub logs (tests/smoke/perps/perps-add-funds.spec.ts).
  • Ran lint on modified file successfully:
    • yarn eslint tests/page-objects/Perps/PerpsTabView.ts --fix
  • yarn lint:tsc currently fails due unrelated pre-existing repo issue:
    • missing app/util/termsOfUse/termsOfUseContent

Git

  • Committed and pushed to branch fix/update-token-details-opened-event:
    • 4d0f09fcf7
    • commit message: test(e2e): harden perps perpsTab balance lookup

If you want, I can also add a narrow regression spec/assertion around this balance-element fallback behavior so this class of flake is caught earlier in CI.

Reflection Statement: Existing memory guidance was sufficient; no new reusable insight needed beyond this targeted selector-stability fix.

Also, since I had to run a full yarn install in this environment, you may want to run an env setup agent so future agents don’t repeat it. Suggested prompt:

“Analyze this repo’s cloud-agent startup environment and update it so Yarn dependencies are preinstalled/cached for metamask-mobile E2E and lint workflows.”

Open in Web Open in Cursor 

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@cursor cursor Bot requested a review from a team as a code owner April 2, 2026 18:25
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Apr 2, 2026
Comment thread app/components/UI/TokenDetails/Views/TokenDetails.tsx
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@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 Apr 2, 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.

Comment thread app/components/UI/TokenDetails/Views/TokenDetails.test.tsx
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@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 Apr 2, 2026
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:

Changes analyzed:

  1. tests/page-objects/Perps/PerpsTabView.ts (CRITICAL - test infrastructure): Refactors getBalance() to use Utilities.executeWithRetry with a 20-second timeout and 1-second interval, and extracts getBalanceFromElement() as a private helper. This directly improves reliability of Perps E2E tests. → Requires SmokePerps to validate the page object still works correctly.

  2. app/components/UI/TokenDetails/Views/TokenDetails.tsx:

    • Integrates usePerpsMarketForAsset hook to fetch perps market data for the current token
    • Adds has_perps_market property to TOKEN_DETAILS_OPENED analytics event
    • Defers analytics tracking until both market insights AND perps market data have settled (avoids race conditions)
    • Changes onMarketInsightsDisplayResolved prop to pass { isDisplayed, severity } object
      → Affects token details screen (part of wallet platform) → SmokeWalletPlatform
  3. app/components/UI/TokenDetails/components/AssetOverviewContent.tsx: Updates onMarketInsightsDisplayResolved callback signature to include severity in the payload. This is a refactoring of the callback interface between AssetOverviewContent and TokenDetails. → SmokeWalletPlatform

  4. Test files (.test.tsx): Unit test updates matching the above changes — no additional E2E impact.

Tag dependency chain:

  • SmokePerps is directly affected by the PerpsTabView page object change and the Perps market integration in TokenDetails
  • Per SmokePerps description: "When selecting SmokePerps, also select SmokeWalletPlatform (Trending section) and SmokeConfirmations (Add Funds deposits are on-chain transactions)"
  • SmokeWalletPlatform covers token details display and transaction history
  • SmokeConfirmations is required as a dependency of SmokePerps

Not selected:

  • SmokeAccounts, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeTrade, SmokeCard, SmokeRamps, SmokeMultiChainAPI, SmokePredictions, FlaskBuildTests — none of these are affected by the changes to Perps page objects or TokenDetails analytics/callback refactoring.

Performance Test Selection:
No performance-sensitive code paths are changed. The TokenDetails changes are analytics tracking refactoring (deferred event firing) and callback signature changes — not UI rendering, list performance, or data loading changes. The PerpsTabView change is a test infrastructure improvement (retry logic), not app code. No performance test tags are warranted.

View GitHub Actions results

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

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

@sonarqubecloud

sonarqubecloud Bot commented Apr 2, 2026

Copy link
Copy Markdown

@sahar-fehri sahar-fehri changed the title fix: add hasPerpsMarket to token details opened event fix: add hasPerpsMarket to token details opened event cp-7.73.0 Apr 3, 2026
Comment thread tests/page-objects/Perps/PerpsTabView.ts
@sahar-fehri sahar-fehri enabled auto-merge April 3, 2026 10:20
@sahar-fehri sahar-fehri added this pull request to the merge queue Apr 3, 2026
Merged via the queue into main with commit af4d7ea Apr 3, 2026
165 of 166 checks passed
@sahar-fehri sahar-fehri deleted the fix/update-token-details-opened-event branch April 3, 2026 14:00
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 3, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants