Commit 7df1453
committed
chore(runway): cherry-pick feat: add metrics opt In event (#27846)
<!--
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**
* Add Metrics Opt In event in Onboarding, Optinmetrics and
MetaMetricsAndDataCollectionSection screen
<!--
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?
-->
## **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: null
## **Related issues**
Fixes:
## **Manual testing steps**
```gherkin
Feature: METRICS_OPT_IN analytics on user opt-in
Scenario: User opts in from onboarding MetaMetrics screen
Given the user is on the onboarding MetaMetrics / data collection screen with basic usage enabled by default
When the user continues without turning off basic usage
Then the app completes onboarding as before and analytics pipelines receive a "Metrics Opt In" event with onboarding location and expected properties in addition to "Analytics Preference Selected"
Scenario: User enables MetaMetrics from Settings
Given the user is logged in and MetaMetrics is currently off
When the user opens Settings > Security & privacy and turns the MetaMetrics switch on
Then the app opts in successfully and emits "Metrics Opt In" with settings location and updated_after_onboarding before the preference-selected event
Scenario: User enables marketing which requires MetaMetrics
Given MetaMetrics is off and marketing data collection is off
When the user turns marketing data collection on (which enables MetaMetrics)
Then MetaMetrics turns on and "Metrics Opt In" is recorded before the subsequent preference events
```
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<img width="702" height="94" alt="Screenshot 2026-03-24 at 3 35 19 PM"
src="https://github.com/user-attachments/assets/e5177be9-8c93-413b-ae76-8e10c3e50352"
/>
<img width="703" height="50" alt="Screenshot 2026-03-24 at 3 36 30 PM"
src="https://github.com/user-attachments/assets/6da0d4cb-f660-49b9-818e-bb45fe1e413e"
/>
<img width="695" height="91" alt="Screenshot 2026-03-24 at 3 40 10 PM"
src="https://github.com/user-attachments/assets/229e4a2d-80c3-469e-b1a9-639df7068c17"
/>
<!-- [screenshots/recordings] -->
## **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**
> Low risk analytics-only change that adds an additional tracking call
when users enable metrics (onboarding, social login, and settings). Main
risk is event ordering/duplication affecting downstream dashboards
rather than app behavior.
>
> **Overview**
> Adds a new `MetaMetricsEvents.METRICS_OPT_IN` event and emits it
whenever users enable metrics, including the onboarding opt-in screen
(`location: onboarding_metametrics`), social login onboarding flow
(`location: onboarding_social_login`), and the settings MetaMetrics
toggle (`location: settings` / `onboarding_default_settings`).
>
> Updates tests to assert the new opt-in event is sent (and in
settings/onboarding cases is sent *before*
`ANALYTICS_PREFERENCE_SELECTED`), including verifying
`updated_after_onboarding` and optional `account_type` properties.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
9968f73. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent b4f3655 commit 7df1453
7 files changed
Lines changed: 124 additions & 18 deletions
File tree
- app
- components
- UI/OptinMetrics
- Views
- Onboarding
- Settings/SecuritySettings/Sections/MetaMetricsAndDataCollectionSection
- core/Analytics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
149 | 159 | | |
150 | 160 | | |
151 | 161 | | |
| |||
177 | 187 | | |
178 | 188 | | |
179 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
180 | 200 | | |
181 | 201 | | |
182 | 202 | | |
| |||
212 | 232 | | |
213 | 233 | | |
214 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
215 | 245 | | |
216 | 246 | | |
217 | 247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| |||
1990 | 1991 | | |
1991 | 1992 | | |
1992 | 1993 | | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
1993 | 2001 | | |
1994 | 2002 | | |
1995 | 2003 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
736 | 748 | | |
737 | 749 | | |
738 | 750 | | |
739 | 751 | | |
740 | 752 | | |
741 | 753 | | |
742 | 754 | | |
743 | | - | |
744 | 755 | | |
745 | 756 | | |
746 | 757 | | |
| |||
Lines changed: 46 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
381 | 392 | | |
382 | 393 | | |
383 | 394 | | |
| |||
407 | 418 | | |
408 | 419 | | |
409 | 420 | | |
410 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
411 | 433 | | |
412 | 434 | | |
413 | 435 | | |
| |||
467 | 489 | | |
468 | 490 | | |
469 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
470 | 502 | | |
471 | 503 | | |
472 | 504 | | |
| |||
808 | 840 | | |
809 | 841 | | |
810 | 842 | | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
811 | 853 | | |
812 | 854 | | |
813 | 855 | | |
| |||
827 | 869 | | |
828 | 870 | | |
829 | 871 | | |
830 | | - | |
831 | | - | |
| 872 | + | |
| 873 | + | |
832 | 874 | | |
833 | 875 | | |
834 | 876 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
117 | 128 | | |
118 | 129 | | |
119 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
829 | 830 | | |
830 | 831 | | |
831 | 832 | | |
| 833 | + | |
832 | 834 | | |
833 | 835 | | |
834 | 836 | | |
| |||
0 commit comments