Commit 06877a8
authored
feat(ramps): add analytics events for token unavailable modal (MetaMask#27287)
## **Description**
Adds analytics tracking for all user interactions with the
`TokenNotAvailableModal` — the bottom sheet shown in Unified Buy v2 when
the selected token is not supported by the selected provider.
Previously only the "Change Provider" button was tracked. This PR adds:
- `Ramps Screen Viewed` on modal mount (`location: 'Token Unavailable
Modal'`)
- `Ramps Change Token Button Clicked` (new event) when user taps "Change
Token"
- `Ramps Close Button Clicked` when user taps X to dismiss
This gives full funnel visibility into what users do when they hit a
token-unavailability state.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3311
## **Manual testing steps**
```gherkin
Feature: Token unavailable modal analytics
Scenario: user sees the modal and taps Change Token
Given the user is on the Amount Input screen with a provider selected
And the selected token is not supported by that provider
When the token unavailable modal appears
Then a "Ramps Screen Viewed" event fires with location "Token Unavailable Modal"
When user taps "Change Token"
Then a "Ramps Change Token Button Clicked" event fires with current_provider set
Scenario: user dismisses the modal
Given the token unavailable modal is visible
When user taps the X close button
Then a "Ramps Close Button Clicked" event fires with location "Token Unavailable Modal"
Scenario: user taps Change Provider (no regression)
Given the token unavailable modal is visible
When user taps "Change Provider"
Then a "Ramps Change Provider Button Clicked" event fires (unchanged behaviour)
```
## **Screenshots/Recordings**
### **Before**
Only `Ramps Change Provider Button Clicked` fired from this modal.
### **After**
All four interaction surfaces tracked. Verify via Segment debugger or
analytics logs.
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Analytics-only changes plus a small close-button behavior tweak (close
vs navigate) confined to a single modal and covered by updated tests.
>
> **Overview**
> Adds MetaMetrics tracking to the Unified Buy v2
`TokenNotAvailableModal`, firing `RAMPS_SCREEN_VIEWED` on mount and
logging button interactions for **Change token** and the modal **close
(X)**.
>
> Introduces a new analytics event constant
`RAMPS_CHANGE_TOKEN_BUTTON_CLICKED` in `MetaMetrics.events.ts`, wires
the close button to a new `handleClose` (close only, no navigation), and
updates/extends tests to mock `useAnalytics` and assert the new event
payloads.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
cb0455f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 0696104 commit 06877a8
3 files changed
Lines changed: 107 additions & 8 deletions
File tree
- app
- components/UI/Ramp/Views/Modals/TokenNotAvailableModal
- core/Analytics
Lines changed: 68 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
7 | 23 | | |
8 | 24 | | |
9 | 25 | | |
| |||
143 | 159 | | |
144 | 160 | | |
145 | 161 | | |
146 | | - | |
| 162 | + | |
147 | 163 | | |
148 | 164 | | |
149 | 165 | | |
150 | 166 | | |
151 | 167 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 168 | + | |
156 | 169 | | |
157 | 170 | | |
158 | 171 | | |
| |||
181 | 194 | | |
182 | 195 | | |
183 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
184 | 247 | | |
Lines changed: 35 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
52 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
53 | 73 | | |
54 | 74 | | |
55 | 75 | | |
56 | 76 | | |
57 | 77 | | |
58 | | - | |
| 78 | + | |
59 | 79 | | |
60 | 80 | | |
61 | 81 | | |
| |||
83 | 103 | | |
84 | 104 | | |
85 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
86 | 118 | | |
87 | 119 | | |
88 | 120 | | |
| |||
102 | 134 | | |
103 | 135 | | |
104 | 136 | | |
105 | | - | |
| 137 | + | |
106 | 138 | | |
107 | 139 | | |
108 | 140 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| 321 | + | |
321 | 322 | | |
322 | 323 | | |
323 | 324 | | |
| |||
1117 | 1118 | | |
1118 | 1119 | | |
1119 | 1120 | | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
1120 | 1124 | | |
1121 | 1125 | | |
1122 | 1126 | | |
| |||
0 commit comments