Repository navigation
Commit e8b9146
authored
chore: track token table sort metrics (#47845)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
Clicking a token table sort header in widescreen view now sends the
existing `Token Sort Preference Updated` event. The sort menu sends the
same event with `location: Sort Menu`.
`token_sort_preference` stays `title` or `tokenFiatAmount` for the name
and balance sorts, and is `price` or `percentChange` for the new header
sorts. Those values live on `MetaMetricsTokenSortPreference`. The saved
sort keys are unchanged.
On the wide table, the sort menu button is now hidden because the column
headers are the sort control.
## **Changelog**
CHANGELOG entry: null
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/CEUX-1373
## **Manual testing steps**
1. Open the wallet wide enough to show the token table.
2. Confirm the sort menu button is not shown next to the network filter.
3. Click Token, Price, 24h change, and Balance, including a second click
on the same header.
4. In the MetaMetrics debugger, confirm each click sends `Token Sort
Preference Updated` with `location` `Token Column Header` and
`token_sort_preference` of `title`, `price`, `percentChange`, or
`tokenFiatAmount`.
5. Narrow the wallet until the token list replaces the table.
6. Open the sort menu and choose Alphabetically, then Declining balance.
7. Confirm those events use `location` `Sort Menu` and
`token_sort_preference` of `title` or `tokenFiatAmount`, and that the
saved sort updates.
Example new event
```
{
"category": "Settings",
"token_sort_preference": "title",
"location": "Token Column Header",
"environment_type": "fullscreen",
"locale": "en",
"chain_id": "0x1",
"profile_id": "be2ccf24-a244-45d1-b3b5-c5ae833c8702",
"canonical_profile_id": "3ad7e304-c059-4d3d-a349-5fb7f9c15e3a"
}
```
Updated existing event with location
```
{
"category": "Settings",
"token_sort_preference": "title",
"location": "Sort Menu",
"environment_type": "fullscreen",
"locale": "en",
"chain_id": "0x1",
"profile_id": "be2ccf24-a244-45d1-b3b5-c5ae833c8702",
"canonical_profile_id": "3ad7e304-c059-4d3d-a349-5fb7f9c15e3a"
}
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Analytics and UI-only changes; no auth, persistence, or transaction
logic affected.
>
> **Overview**
> **Token sort analytics** now distinguish **where** sorting happened
and use typed preference values. New enums
`MetaMetricsTokenSortLocation` (`Sort Menu`, `Token Column Header`) and
`MetaMetricsTokenSortPreference` (`title`, `tokenFiatAmount`, `price`,
`percentChange`) standardize the existing `Token Sort Preference
Updated` event.
>
> Clicking a **token table column header** emits that event with
`location: Token Column Header` and the column-mapped
`token_sort_preference`. The **sort menu** still updates saved
preferences but now sends the same event with `location: Sort Menu` and
enum-backed values instead of raw sort keys.
>
> On **wide/table layout**, the separate **Sort** control is hidden
because headers handle sorting (header sorts remain session-only;
persisted config is unchanged). Tests cover analytics for both surfaces.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
6123ddb. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 19c4052 commit e8b9146
6 files changed
Lines changed: 116 additions & 13 deletions
File tree
- ui/components/app/assets
- asset-list
- sort-control
- token-table
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
492 | | - | |
| 492 | + | |
| 493 | + | |
493 | 494 | | |
494 | 495 | | |
495 | 496 | | |
| |||
1402 | 1403 | | |
1403 | 1404 | | |
1404 | 1405 | | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
1405 | 1424 | | |
1406 | 1425 | | |
1407 | 1426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
130 | | - | |
| 132 | + | |
| 133 | + | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
| |||
156 | 159 | | |
157 | 160 | | |
158 | 161 | | |
159 | | - | |
| 162 | + | |
| 163 | + | |
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
| |||
83 | 95 | | |
84 | 96 | | |
85 | 97 | | |
86 | | - | |
87 | 98 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 99 | + | |
93 | 100 | | |
94 | 101 | | |
95 | 102 | | |
| |||
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
104 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
105 | 114 | | |
106 | 115 | | |
107 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
13 | 38 | | |
14 | 39 | | |
15 | 40 | | |
| |||
144 | 169 | | |
145 | 170 | | |
146 | 171 | | |
| 172 | + | |
147 | 173 | | |
148 | 174 | | |
149 | 175 | | |
150 | 176 | | |
151 | 177 | | |
152 | 178 | | |
| 179 | + | |
153 | 180 | | |
154 | 181 | | |
155 | 182 | | |
156 | 183 | | |
157 | 184 | | |
158 | 185 | | |
| 186 | + | |
159 | 187 | | |
160 | 188 | | |
161 | 189 | | |
162 | 190 | | |
163 | 191 | | |
164 | 192 | | |
| 193 | + | |
165 | 194 | | |
166 | 195 | | |
167 | 196 | | |
168 | 197 | | |
169 | 198 | | |
170 | 199 | | |
171 | 200 | | |
172 | | - | |
| 201 | + | |
| 202 | + | |
173 | 203 | | |
174 | 204 | | |
175 | 205 | | |
| |||
212 | 242 | | |
213 | 243 | | |
214 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
215 | 257 | | |
216 | 258 | | |
217 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
| |||
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
69 | 87 | | |
70 | 88 | | |
71 | 89 | | |
| |||
274 | 292 | | |
275 | 293 | | |
276 | 294 | | |
| 295 | + | |
277 | 296 | | |
278 | 297 | | |
279 | 298 | | |
| |||
293 | 312 | | |
294 | 313 | | |
295 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
296 | 325 | | |
297 | | - | |
| 326 | + | |
298 | 327 | | |
299 | 328 | | |
300 | 329 | | |
| |||
0 commit comments