Commit 4e83735
feat: add metrics for shield-rewards integration (#38567)
<!--
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**
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
[](https://codespaces.new/MetaMask/metamask-extension/pull/38567?quickstart=1)
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: add metrics for shield-rewards integration
## **Related issues**
Fixes:
## **Manual testing steps**
1. Go to this page...
2.
3.
## **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**
- [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**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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]
> Adds Shield "Opt In Rewards" metric and wires
rewardPoints/subscriptionId through plan/settings/onboarding to track on
subscription creation or linking; updates service, actions, types, UI,
and tests accordingly.
>
> - **Shield metrics & service**:
> - Add `MetaMetricsEventName.ShieldOptInRewards` and
`#trackShieldOptInRewardsEvent` to emit metrics with `rewards_point` and
`rewards_opt_in_type`.
> - Track on card subscription completion (`create_new_subscription`)
and when linking rewards (`link_existing_subscription`).
> - Change `linkRewardToExistingSubscription` to
`linkRewardToExistingSubscription(subscriptionId, rewardPoints)` and
call `SubscriptionController:linkRewards`.
> - **Types & state**:
> - Extend `ShieldSubscriptionMetricsPropsFromUI` with optional
`rewardPoints` and forward via `setShieldSubscriptionMetricsProps`.
> - **UI wiring**:
> - `OnboardingModal`/`OnboardingStep4` accept `rewardPoints` and
`shieldSubscriptionId`; `useOptIn` optionally dispatches
`linkRewardToShieldSubscription` after opt-in.
> - `useHandleSubscription` accepts `rewardPoints` and sets it in
background metrics props.
> - `transaction-shield.tsx` and `shield-plan.tsx`: compute
`claimedRewardsPoints`, display text, and pass to
onboarding/modal/handlers; minor hook var rename for opt-in status.
> - **Actions**:
> - Add `linkRewardToShieldSubscription(subscriptionId, rewardPoints)`
thunk.
> - **Tests**:
> - Update `subscription-service.test.ts` to cover new `rewardPoints`
param and behaviors.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f0cac6a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: MetaMask Bot <[email protected]>1 parent 85f4650 commit 4e83735
File tree
12 files changed
+162
-25
lines changed- app/scripts/services/subscription
- ui
- components/app/rewards/onboarding
- hooks
- rewards
- shield/metrics
- subscription
- pages
- settings/transaction-shield-tab
- shield-plan
- store
12 files changed
+162
-25
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
484 | 484 | | |
485 | 485 | | |
486 | 486 | | |
| 487 | + | |
487 | 488 | | |
488 | 489 | | |
489 | 490 | | |
| |||
518 | 519 | | |
519 | 520 | | |
520 | 521 | | |
| 522 | + | |
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
| |||
539 | 541 | | |
540 | 542 | | |
541 | 543 | | |
| 544 | + | |
542 | 545 | | |
543 | 546 | | |
544 | 547 | | |
| |||
550 | 553 | | |
551 | 554 | | |
552 | 555 | | |
| 556 | + | |
553 | 557 | | |
554 | 558 | | |
555 | 559 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
176 | 181 | | |
177 | 182 | | |
178 | 183 | | |
| |||
244 | 249 | | |
245 | 250 | | |
246 | 251 | | |
| 252 | + | |
247 | 253 | | |
248 | 254 | | |
249 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
250 | 259 | | |
251 | 260 | | |
252 | 261 | | |
| |||
257 | 266 | | |
258 | 267 | | |
259 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
260 | 276 | | |
261 | 277 | | |
262 | 278 | | |
| |||
596 | 612 | | |
597 | 613 | | |
598 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
599 | 651 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1003 | 1003 | | |
1004 | 1004 | | |
1005 | 1005 | | |
| 1006 | + | |
1006 | 1007 | | |
1007 | 1008 | | |
1008 | 1009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
37 | 51 | | |
38 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
39 | 57 | | |
40 | 58 | | |
41 | 59 | | |
| |||
77 | 95 | | |
78 | 96 | | |
79 | 97 | | |
80 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
81 | 104 | | |
82 | 105 | | |
83 | 106 | | |
84 | 107 | | |
85 | 108 | | |
86 | 109 | | |
87 | 110 | | |
| 111 | + | |
| 112 | + | |
88 | 113 | | |
89 | 114 | | |
90 | 115 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
38 | 46 | | |
39 | 47 | | |
40 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
160 | 180 | | |
161 | 181 | | |
162 | 182 | | |
| |||
182 | 202 | | |
183 | 203 | | |
184 | 204 | | |
| 205 | + | |
| 206 | + | |
185 | 207 | | |
186 | 208 | | |
187 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
| 474 | + | |
474 | 475 | | |
475 | 476 | | |
476 | 477 | | |
| |||
480 | 481 | | |
481 | 482 | | |
482 | 483 | | |
| 484 | + | |
483 | 485 | | |
484 | 486 | | |
485 | 487 | | |
| |||
488 | 490 | | |
489 | 491 | | |
490 | 492 | | |
| 493 | + | |
491 | 494 | | |
492 | 495 | | |
493 | 496 | | |
| |||
550 | 553 | | |
551 | 554 | | |
552 | 555 | | |
| 556 | + | |
553 | 557 | | |
554 | 558 | | |
555 | 559 | | |
| |||
619 | 623 | | |
620 | 624 | | |
621 | 625 | | |
| 626 | + | |
622 | 627 | | |
623 | 628 | | |
624 | 629 | | |
| |||
779 | 784 | | |
780 | 785 | | |
781 | 786 | | |
782 | | - | |
| 787 | + | |
783 | 788 | | |
784 | 789 | | |
785 | 790 | | |
786 | 791 | | |
787 | 792 | | |
788 | 793 | | |
789 | | - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
790 | 798 | | |
791 | 799 | | |
792 | 800 | | |
| |||
861 | 869 | | |
862 | 870 | | |
863 | 871 | | |
| 872 | + | |
864 | 873 | | |
865 | 874 | | |
866 | 875 | | |
| |||
875 | 884 | | |
876 | 885 | | |
877 | 886 | | |
878 | | - | |
| 887 | + | |
879 | 888 | | |
880 | 889 | | |
Lines changed: 11 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| 253 | + | |
| 254 | + | |
253 | 255 | | |
254 | | - | |
| 256 | + | |
| 257 | + | |
255 | 258 | | |
256 | 259 | | |
257 | 260 | | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
| 261 | + | |
| 262 | + | |
266 | 263 | | |
267 | 264 | | |
268 | 265 | | |
| |||
849 | 846 | | |
850 | 847 | | |
851 | 848 | | |
852 | | - | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
853 | 853 | | |
854 | 854 | | |
855 | 855 | | |
| |||
0 commit comments