fix(pay): always emit mm_pay_payment_token_list_size on confirmation events - #33253
Conversation
…events Move mm_pay_payment_token_list_size outside the if(payToken) guard so it is written regardless of whether a payment token was selected. Previously the property was only set when payToken was truthy, causing it to be absent from Transaction Rejected (and other outcome events) when no eligible ERC-20 tokens existed. Mixpanel could not distinguish 'user had zero tokens' from 'property was never written'. Now the property is always present with the actual count of available (non-disabled) tokens, defaulting to 0 when none are eligible.
|
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. |
…ns with incomplete metamaskPay When a money_account_deposit (or other PAY_TYPE) transaction fails before the pay flow populates metamaskPay with chainId/tokenAddress, addPayTypeProperties returned early without setting any mm_pay_* properties. This caused mm_pay_payment_method_selected to be absent from 18.5% of Transaction Finalized events for money_account_deposit. Add addPayTypeBaselineProperties fallback for PAY_TYPE transactions when metamaskPay is incomplete. Derives what it can from the transaction type and TransactionPayController state: - mm_pay, mm_pay_use_case, mm_pay_payment_method_selected (always) - mm_pay_chain_selected (when metamaskPay.chainId exists) - mm_pay_token_selected (when controller has paymentToken) - fiat method override (when controller has fiatPayment data) Non-PAY_TYPE transactions without metamaskPay still return empty properties (unchanged).
🧪 Flaky unit test detectionRun history flaky detectionHistorical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow. Failures / runs sampled per window:
AI-detected flaky patterns
|
| * selection). Derives what it can from the transaction type and | ||
| * TransactionPayController state without requiring chainId/tokenAddress. | ||
| */ | ||
| function addPayTypeBaselineProperties( |
There was a problem hiding this comment.
Rather than duplicating lots of identical logic, could we support this inline above by removing the early return?
There was a problem hiding this comment.
PR is updated to address this.
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.
Reviewed by Cursor Bugbot for commit f5e3701. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These are metrics-only changes with no impact on transaction execution, UI rendering, or user-facing behavior. However, they affect the analytics events fired during:
Per tag descriptions: SmokePerps, SmokePredictions, and SmokeMoney all require SmokeConfirmations (on-chain transactions). SmokePerps also requires SmokeWalletPlatform (Trending section). SmokePredictions also requires SmokeWalletPlatform. Risk is LOW because:
Performance Test Selection: |
|




Description
Changelog
CHANGELOG entry:
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1636
Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1634
Manual testing steps
NA
Screenshots/Recordings
NA
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Changes are limited to analytics property assembly and UI metric hooks; no payment execution or auth paths are modified.
Overview
MetaMask Pay confirmation and finalized-transaction analytics are tightened so key properties are present even when the user has not picked a pay token or when controller metadata is incomplete.
On the confirmation UI hook,
mm_pay_payment_token_list_sizeis now set whenever payment-method metrics are updated (alongsidemm_pay_payment_method_available), instead of only when a pay token is already selected. Tests assert list sizes of 5 and 0 in the scenarios that previously omitted the field.In
addPayTypeProperties(transaction-controller metrics), baselinemm_pay,mm_pay_payment_method_selected, andmm_pay_use_caseare derived for recognized Pay transaction types even whenmetamaskPaylacks bothchainIdandtokenAddress, with optionalmm_pay_chain_selected/mm_pay_token_selectedfrom controller state or token lookup. Non–Pay-type transactions still emit no Pay properties unless fullmetamaskPaymetadata is present. This addresses missingmm_pay_payment_method_selectedon a slice of Transaction Finalized events (e.g.money_account_deposit).Reviewed by Cursor Bugbot for commit 1ef0205. Bugbot is set up for automated code reviews on this repo. Configure here.