feat(card): add balance properties on SpendingLimit Card Viewed screen#27981
Conversation
|
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:
SmokeCard is the primary tag as these changes are entirely within the Card feature's SpendingLimit view. Per SmokeCard's description, SmokeTrade and SmokeConfirmations are required dependent tags (Add Funds uses swaps which require transaction confirmations). No other features are affected - no shared components, no navigation changes, no controller changes, no Engine changes. Performance Test Selection: |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
|
|
✅ E2E Fixture Validation — Schema is up to date |




Description
Adds wallet balance context to the Card
CARD_VIEWEDevent when the user opens the Spending limit (or enable-token) flow, and aligns row affordance icons with a down chevron on the settings-style rows.Why: Product and analytics need to understand Linea mUSD exposure, which card-supported asset has the highest fiat balance for the current account, and which asset is top across the whole wallet (EVM networks plus Solana) at screen view time—without inferring this from other screens.
What changed:
useSpendingLimit.tsuseTokensWithBalancetwice: card chain IDs (CARD_CHAIN_IDS) forwalletTokens, and all configured EVM chain IDs plus Solana (viaselectEvmNetworkConfigurationsByChainIdandcardNetworkInfos.solana.caipChainId) forallWalletTokens.MetaMetricsEvents.CARD_VIEWED, adds:musd_linea_balance: fiat amount for mUSD on Linea on the selected account, or 0 if absent.top_card_chain_asset:network:symbol(e.g.linea:musd) for the highest fiat token among card-supported balances (allTokensintersection), ornullif none / unsupported-only (e.g. top balance not in card list).top_wallet_chain_asset/top_wallet_asset_balance: highest fiat token across all wallet tokens and its fiat value (ornull/ 0 when applicable). Network label usescaipChainIdToNetworkwhere mapped, otherwise the CAIP chain id string.toNetworkAssetto normalizenetwork:symbolfor analytics.SpendingLimit.tsx: Account, Token, and Spending limit row trailing iconsArrowRight→ArrowDownfor clearer expand/dropdown affordance.useSpendingLimit.test.ts: Tests formusd_linea_balance,top_card_chain_asset(including empty list, non-card-supported top token), andtop_wallet_chain_asset/top_wallet_asset_balance; clarifies default selector mock comment.Changelog
CHANGELOG entry: Card Spending limit screen analytics include Linea mUSD fiat balance, top card-supported asset by fiat, and top wallet-wide asset by fiat when the screen is viewed.
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Optional: capture the three rows showing down chevrons. For analytics, verify in debug/logs or analytics tooling that
CARD_VIEWEDpayloads include the new properties.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Adds new analytics properties derived from wallet token balances and network configuration, including multi-chain sorting logic and a one-time firing guard; mistakes could skew metrics or add minor performance overhead on screen mount.
Overview
Enriches the card Spending Limit/Enable flow
CARD_VIEWEDanalytics event with wallet balance context:musd_linea_balance, the highest-fiat card-supported asset (top_card_chain_asset), and the highest-fiat asset across all configured wallet chains plus Solana (top_wallet_chain_asset+top_wallet_asset_balance).Updates
useSpendingLimitto fetch balances viauseTokensWithBalancefor both card chains and all wallet chains, normalizesnetwork:symbolformatting, and delays/fires the screen-view event exactly once afterallTokensis non-empty to avoid unsupported/empty snapshots; adds unit tests covering these new metrics.Adjusts the Spending Limit settings rows’ trailing affordance icons from
ArrowRighttoArrowDownfor Account/Token/Spending limit rows.Written by Cursor Bugbot for commit f1b5724. This will update automatically on new commits. Configure here.