Repository navigation
Commit f47f2f6
authored
test(confirmations): cover deposit_limit in alert metrics (#47580)
## **Description**
Counterpart to the Mobile work in
[CONF-2194](https://consensyssoftware.atlassian.net/browse/CONF-2194)
([metamask-mobile#38715](MetaMask/metamask-mobile#38715)),
where the `deposit_limit` alert was **completely absent** from Mixpanel
— zero `Transaction Added` / `Submitted` / `Rejected` / `Finalized`
events carried it between 2025-01-01 and 2026-10-26.
**The headline result: that bug does not reproduce here, so this PR
contains no production code change.**
I verified each of the three Mobile defects against this codebase:
| Mobile defect | Extension status |
|---|---|
| Alert never registered in `useConfirmationAlerts` | Already registered
— `useConfirmationAlerts.ts:58` |
| Hook only read an explicit `pendingAmount` arg, so bare calls saw `0`
| Already falls back to `primaryRequiredToken.amountFiat ?? amountUsd` —
`useTransactionDepositLimitAlert.ts:42-54` |
| `trackAlertMetrics` lived in a `Footer` that early-returns `null` for
money-account deposits | Mounted in the `ConfirmAlerts` **provider** at
`confirm.tsx:32`, above `<Footer />` at `confirm.tsx:48` |
That third point is the important one. The Footer here *does* diverge
for money-account deposits — `isSingleActionFooterConfirmation`
(`footer.tsx:94-124`) routes `moneyAccountDeposit`,
`moneyAccountWithdraw`, `musdConversion`, `perpsDeposit`,
`perpsWithdraw` to a `SingleActionFooter`, which is the same failure
shape as Mobile. But because the metrics hook sits two levels up in a
pass-through provider with **no early returns, no conditionals**
(`confirm-alerts.tsx:8-28`), the Footer's divergence cannot suppress the
metric.
There is also a structural reason the Mobile "uncommitted amount"
problem can't occur: Mobile gates the commit behind a Done button that
the cap itself disables, so an over-cap amount is never persisted. Here
`useTransactionCustomAmount` auto-commits on a debounce (`:198-221`)
with no blocking gate, so the over-cap value does reach
`primaryRequiredToken` and the committed fallback sees it.
### What this PR actually does
The one real gap was **test coverage**: nothing pinned
`AlertsName.DepositLimit` to its `'deposit_limit'` metrics name, or
asserted it survives the per-transaction-type exclusion filter. So a
future edit to `ALERTS_NAME_METRICS`
(`useConfirmationAlertMetrics.ts:28`), to
`EXCLUDED_ALERT_KEYS_BY_TRANSACTION_TYPE` (`:53-58`), or to where
`ConfirmAlerts` is mounted could silently reintroduce the Mobile
regression with nothing failing.
Three tests added to `useConfirmationAlertMetrics.test.ts`:
1. an over-cap money-account deposit reports `alert_triggered:
['deposit_limit']`
2. the alert is **not** swept up by the exclusion that drops
`hexDataWhileInteractingWithNonContractAddress` for this transaction
type
3. it is reported in `alert_resolved` once confirmed
These pass against current `main`, which is the evidence that the
pipeline already works end to end rather than an assertion that it
should.
### Two differences from Mobile worth noting for reviewers
- **Property names differ.** Extension emits `alert_triggered` /
`alert_triggered_count`; Mobile emits `alert_trigger_name` /
`alert_trigger_count`. Anyone querying both clients needs both names.
- **`fiat_buy_amount_limit` does not exist here at all** — no
`useFiatBuyLimitAlert`, no `AlertsName` member. On Mobile that alert was
*also* dark and got fixed incidentally. Nothing to port.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes:
[CONF-2222](https://consensyssoftware.atlassian.net/browse/CONF-2222)
Refs:
[CONF-2194](https://consensyssoftware.atlassian.net/browse/CONF-2194) ·
[metamask-mobile#38715](MetaMask/metamask-mobile#38715)
## **Manual testing steps**
No user-facing change; the production behaviour is already correct. To
confirm the instrumentation by hand:
1. Set `confirmations_pay_extended.depositLimit.moneyAccountDeposit` to
a low value (e.g. `100`).
2. Open a Money account deposit confirmation.
3. Enter an amount above that limit.
4. Confirm the blocking "Max deposit: $X" alert appears on the amount
row and Confirm is disabled.
5. Inspect the transaction event fragment / Segment payload and confirm
`alert_triggered` contains `deposit_limit`.
6. Back out of the confirmation and confirm the resulting rejected event
still carries the property.
Automated: `yarn jest
ui/pages/confirmations/hooks/useConfirmationAlertMetrics.test.ts` — 16
passed.
## **Screenshots/Recordings**
N/A — test-only change, no UI impact.
### **Before**
N/A
### **After**
N/A
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **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.
[CONF-2194]:
https://consensyssoftware.atlassian.net/browse/CONF-2194?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[CONF-2222]:
https://consensyssoftware.atlassian.net/browse/CONF-2222?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Test-only change with no runtime or analytics pipeline modifications.
>
> **Overview**
> This PR adds **test-only** coverage for the money-account **deposit
limit** alert in `useConfirmationAlertMetrics` — no production code
changes.
>
> A new **`deposit limit`** describe block adds three cases: over-cap
money-account deposits emit **`alert_triggered: ['deposit_limit']`**,
**`deposit_limit` is not filtered** by the same per-type exclusion that
drops **`hexDataWhileInteractingWithNonContractAddress`**, and a
user-confirmed deposit limit alert appears in **`alert_resolved`**.
Together they lock the existing **`AlertsName.DepositLimit` →
`deposit_limit`** mapping and behavior so future edits to metrics naming
or exclusion rules cannot silently drop the alert (as happened on
Mobile).
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
cc3c76a. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 387f2ac commit f47f2f6
1 file changed
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
361 | 431 | | |
0 commit comments