fix: derive mm_pay_* metrics from controller state for reliable Transaction Finalized tracking#28164
fix: derive mm_pay_* metrics from controller state for reliable Transaction Finalized tracking#28164
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. |
app/components/Views/confirmations/hooks/pay/useTransactionPayMetrics.ts
Show resolved
Hide resolved
app/components/Views/confirmations/hooks/pay/useTransactionPayMetrics.ts
Show resolved
Hide resolved
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.
app/core/Engine/controllers/transaction-controller/metrics_properties/metamask-pay.ts
Show resolved
Hide resolved
…action Finalized tracking Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Key changes:
These are analytics-only changes with no functional transaction flow modifications. However, they affect the metrics emitted during Perps and Predictions transaction flows, which warrants running those smoke tests to verify the flows still work correctly end-to-end. Tag selection rationale:
Performance Test Selection: |
|
|
✅ E2E Fixture Validation — Schema is up to date |




Description
MM Pay analytics properties (
mm_pay_*) on theTransaction Finalizedevent were intermittently missing forpredict_deposit,perps_depositand forpredict_withdrawtransactions.The properties were set by a React hook (
useTransactionPayMetrics) that dispatches to Redux viauseEffect. When the confirmation screen unmounted before the effect fired, the data was lost.This PR moves core
mm_pay_*derivation into thegetMetaMaskPayPropertiesmetrics builder, reading directly fromtransactionMeta.metamaskPayandTransactionPayController.transactionData— controller state that persists regardless of UI lifecycle. The hook now only dispatches UI-specific properties (e.g.,mm_pay_token_presented,mm_pay_quote_loaded).Changelog
CHANGELOG entry: fix: derive mm_pay_* metrics from controller state for reliable Transaction Finalized tracking
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1102
Manual testing steps
Screenshots/Recordings
Before
mm_pay_*properties intermittently missing on predict_withdraw Transaction Finalized events.After
All core
mm_pay_*properties reliably present, derived from controller state.Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Touches analytics metric composition for MetaMask Pay transactions and changes the source of truth for fee/value/strategy fields; mistakes could silently regress tracking correctness across pay flows.
Overview
Ensures
Transaction Finalizedanalytics consistently include coremm_pay_*properties by deriving them ingetMetaMaskPayPropertiesfromtransactionMeta.metamaskPayandTransactionPayController.transactionData, rather than relying on confirmation-screen lifecycle.useTransactionPayMetricsis reduced to dispatching UI-only fields (e.g.,mm_pay_token_presented, quote loaded/requested, token list size, highest-balance chain) and now explicitly avoids emitting builder-owned properties like token/chain selected, use case, fees, strategy, dust, and step counts.Tests are updated accordingly: hook tests assert only UI-scoped metrics are dispatched, and
metamask-paybuilder tests now validate fee/value/strategy/use-case/step/dust derivation from controller state (including preference forpaymentToken.symbolover token lookup).Written by Cursor Bugbot for commit 1bbf16b. This will update automatically on new commits. Configure here.