Skip to content

release(runway): cherry-pick feat: analytics pref tracking for social onboarding cp-13.25.0#41388

Merged
chloeYue merged 2 commits into
release/13.25.0from
runway-cherry-pick-13.25.0-1774954278
Apr 1, 2026
Merged

release(runway): cherry-pick feat: analytics pref tracking for social onboarding cp-13.25.0#41388
chloeYue merged 2 commits into
release/13.25.0from
runway-cherry-pick-13.25.0-1774954278

Conversation

@runway-github

@runway-github runway-github Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Description

This PR closes a gap in Analytics Preference Selected tracking for
social login users and makes the event payload consistent across the
other consent surfaces.

Social login users do not go through the standard onboarding MetaMetrics
screen, so this adds tracking when they make that preference implicitly
during create-password onboarding and when returning social-login users
are rehydrated from backup. It also aligns the standard onboarding,
settings, and home consent flows to use the same MetaMetricsUserTrait
payload fields, and adds unit coverage for the social backup restore
path.

This PR also fixes ~

  • Fixed the real race in ui/contexts/metametrics.tsx:
    MetaMetricsProvider was treating participateInMetaMetrics === true as
    “ready to send”, even when metaMetricsId had not been created yet.
  • That mismatch caused Analytics Preference Selected to go down the
    immediate-send path and get dropped by the background layer before it
    could reach Segment.
  • Updated the provider so events are only sent immediately when both
    conditions are true:
    • metrics participation is enabled
    • metaMetricsId exists
  • If the ID is still missing, the provider now buffers the event through
    addEventBeforeMetricsOptIn, which matches the real onboarding flow
    better.

Changelog

CHANGELOG entry: null

Related issues

Fixes: #41378

Manual testing steps

  1. Go through the standard onboarding flow to the MetaMetrics screen,
    opt in, and verify Analytics Preference Selected fires with location: onboarding_metametrics and the expected consent values.
  2. Go through the social login onboarding flow to the create-password
    step with the consent checkbox checked and unchecked, and verify the
    event fires with location: onboarding_create_password and the correct
    has_marketing_consent value.
  3. Rehydrate an existing social-login user through the unlock/restore
    flow and verify the event fires with location: onboarding_social_login_rehydration after marketing consent is synced
    from background state.
  4. Toggle MetaMetrics / marketing consent from Settings and the home
    marketing consent modal and verify Analytics Preference Selected uses
    the standardized user trait fields and expected opt-in / consent values.

Pre-merge author checklist

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.

Note

Medium Risk
Changes MetaMetrics event dispatch conditions and adds new onboarding
tracking paths, which could affect when/if analytics events are sent
during critical onboarding flows. Test updates and new provider unit
coverage reduce risk but regressions could still drop or duplicate
events.

Overview
Adds missing AnalyticsPreferenceSelected tracking for social login
users during create-password and during social-backup rehydration, and
wires trackEvent through restoreSocialBackupAndGetSeedPhrase to emit
the event after marketing-consent sync.

Fixes a metrics dispatch race by making MetaMetricsProvider only
send events immediately when both participateInMetaMetrics is
enabled and a metaMetricsId exists; otherwise events are buffered via
addEventBeforeMetricsOptIn (except MetricsOptOut).

Standardizes consent-related event properties across onboarding, Home,
and Settings to use MetaMetricsUserTrait keys, and updates/extends
tests (new ui/contexts/metametrics.test.tsx, integration/e2e fixtures,
and additional API nocks) plus console baselines accordingly.

Written by Cursor
Bugbot
for commit
1223d6d. This will update automatically
on new commits. Configure
here.

[efb4de3](https://github.com/MetaMask/metamask-extension/commit/efb4de30cb5d8da7bfac17924b4e4abd3940a002)

… onboarding cp-13.25.0 (#41343)

<!--
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**

This PR closes a gap in `Analytics Preference Selected` tracking for
social login users and makes the event payload consistent across the
other consent surfaces.

Social login users do not go through the standard onboarding MetaMetrics
screen, so this adds tracking when they make that preference implicitly
during create-password onboarding and when returning social-login users
are rehydrated from backup. It also aligns the standard onboarding,
settings, and home consent flows to use the same `MetaMetricsUserTrait`
payload fields, and adds unit coverage for the social backup restore
path.

This PR also fixes ~
- Fixed the real race in ui/contexts/metametrics.tsx:
MetaMetricsProvider was treating `participateInMetaMetrics === true` as
“ready to send”, even when metaMetricsId had not been created yet.
- That mismatch caused `Analytics Preference Selected` to go down the
immediate-send path and get dropped by the background layer before it
could reach Segment.
- Updated the provider so events are only sent immediately when both
conditions are true:
   - metrics participation is enabled
   - metaMetricsId exists
- If the ID is still missing, the provider now buffers the event through
`addEventBeforeMetricsOptIn`, which matches the real onboarding flow
better.



## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: #41378

## **Manual testing steps**

1. Go through the standard onboarding flow to the MetaMetrics screen,
opt in, and verify `Analytics Preference Selected` fires with `location:
onboarding_metametrics` and the expected consent values.
2. Go through the social login onboarding flow to the create-password
step with the consent checkbox checked and unchecked, and verify the
event fires with `location: onboarding_create_password` and the correct
`has_marketing_consent` value.
3. Rehydrate an existing social-login user through the unlock/restore
flow and verify the event fires with `location:
onboarding_social_login_rehydration` after marketing consent is synced
from background state.
4. Toggle MetaMetrics / marketing consent from Settings and the home
marketing consent modal and verify `Analytics Preference Selected` uses
the standardized user trait fields and expected opt-in / consent values.

<!--
## **Screenshots/Recordings**
### **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.



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes MetaMetrics event dispatch conditions and adds new onboarding
tracking paths, which could affect when/if analytics events are sent
during critical onboarding flows. Test updates and new provider unit
coverage reduce risk but regressions could still drop or duplicate
events.
> 
> **Overview**
> Adds missing `AnalyticsPreferenceSelected` tracking for *social login*
users during `create-password` and during social-backup rehydration, and
wires `trackEvent` through `restoreSocialBackupAndGetSeedPhrase` to emit
the event after marketing-consent sync.
> 
> Fixes a metrics dispatch race by making `MetaMetricsProvider` only
send events immediately when **both** `participateInMetaMetrics` is
enabled and a `metaMetricsId` exists; otherwise events are buffered via
`addEventBeforeMetricsOptIn` (except `MetricsOptOut`).
> 
> Standardizes consent-related event properties across onboarding, Home,
and Settings to use `MetaMetricsUserTrait` keys, and updates/extends
tests (new `ui/contexts/metametrics.test.tsx`, integration/e2e fixtures,
and additional API nocks) plus console baselines accordingly.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
1223d6d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github Bot requested review from a team as code owners March 31, 2026 10:51
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Mar 31, 2026
@metamaskbotv2

metamaskbotv2 Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/core-extension-ux (1 files, +3 -2)
  • 📁 ui/
    • 📁 pages/
      • 📁 home/
        • 📄 home.component.js +3 -2

🔐 @MetaMask/web3auth (3 files, +25 -11)
  • 📁 ui/
    • 📁 pages/
      • 📁 onboarding-flow/
        • 📁 create-password/
          • 📄 create-password.tsx +13 -0
        • 📁 metametrics/
          • 📄 metametrics.tsx +10 -9
          • 📄 onboarding-flow.tsx +2 -2

@metamaskbotv2

metamaskbotv2 Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor
Builds ready [1d64c2e]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account86454611201989881120
total86454611201989881120
Confirm Txconfirm_tx6051603260762060756076
total6051603260762060756076
Bridge User Actionsbridge_load_page27223830724290307
bridge_load_asset_picker22115529653252296
bridge_search_token891709102714010071027
total13841116158217015251582
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Chrome Browserify Startup Standard HomeuiStartup14961273186110315481645
load1232103714928612781391
domContentLoaded1223102214648712701382
domInteractive27175382944
firstPaint216751474203266317
backgroundConnect21119325311217228
firstReactRender21145062336
initialActions108114
loadScripts102883312618310701169
setupStore1363461722
numNetworkReqs34316163745
Chrome Browserify Startup Power User HomeuiStartup51131993146642658571312632
load13311163184011913681589
domContentLoaded13031146181910613481478
domInteractive3321142133747
firstPaint2741121440177316384
backgroundConnect204328511374246428958120
firstReactRender27195573045
initialActions109114
loadScripts1090957157410211341273
setupStore1664981936
numNetworkReqs2489339865289342
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192182222220222
srpButtonToSrpForm98979919999
confirmSrpToPwForm23222302323
pwFormToMetricsScreen15151601616
metricsToWalletReadyScreen301846103646
doneButtonToHomeScreen640525775106762775
openAccountMenuToAccountListLoaded30142906312510531123125
total39393637410017440594100
Onboarding New WalletcreateWalletToSocialScreen2222202241223224
srpButtonToPwForm1251191304128130
createPwToRecoveryScreen10101111111
skipBackupToMetricsScreen44434404444
agreeButtonToOnboardingSuccess25203052930
doneButtonToAssetList52550455117527551
total9609519707964970
Asset DetailsassetClickToPriceChart756190107990
total756190107990
Solana Asset DetailsassetClickToPriceChart60486876568
total60486876568
Import Srp HomeloginToHomeScreen2089206521392920832139
openAccountMenuAfterLogin55535725757
homeAfterImportWithNewWallet11412762370100323662370
total33412405456297344884562
Send TransactionsopenSendPageFromHome30293113131
selectTokenToSendFormLoaded372854104054
reviewTransactionToConfirmationPage13581192157814314281578
total14301275163814015131638
SwapopenSwapPageFromHome1028412118120121
fetchAndDisplaySwapQuotes269726842705727032705
total2816278228693128232869
🌐 Dapp Page Load Benchmarks

Current Commit: 1d64c2e | Date: 3/31/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±72ms) 🟡 | historical mean value: 1.02s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 751ms (±86ms) 🟢 | historical mean value: 720ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 91ms (±43ms) 🟢 | historical mean value: 85ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 72ms 1.01s 1.36s 1.30s 1.36s
domContentLoaded 751ms 86ms 704ms 1.32s 976ms 1.32s
firstPaint 91ms 43ms 72ms 512ms 100ms 512ms
firstContentfulPaint 91ms 43ms 72ms 512ms 100ms 512ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 6.84 MiB (100%)
  • ui: 8.35 MiB (100%)
  • common: 11.34 MiB (100%)

@sonarqubecloud

sonarqubecloud Bot commented Apr 1, 2026

Copy link
Copy Markdown

@metamaskbotv2

metamaskbotv2 Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor
Builds ready [bf8aa5b]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account661291112638211241126
total661291112638211241126
Confirm Txconfirm_tx6132608162064661536206
total6132608162064661536206
Bridge User Actionsbridge_load_page27724832027295320
bridge_load_asset_picker29524933230304332
bridge_search_token89374210271159661027
total14971262177718915901777
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Chrome Browserify Startup Standard HomeuiStartup1498123318729815381658
load1229102414568712741404
domContentLoaded1220101514488712621379
domInteractive2817106123049
firstPaint223741279198256323
backgroundConnect21118726515216244
firstReactRender2412219202432
initialActions108225
loadScripts102683212728510681183
setupStore14688101723
numNetworkReqs35316473845
Chrome Browserify Startup Power User HomeuiStartup53352250141362695575013524
load14091215192312614521667
domContentLoaded13821201189510614161570
domInteractive3822193194158
firstPaint2539443999345385
backgroundConnect229228910682233026909358
firstReactRender301983103148
initialActions107124
loadScripts11561004161610011851353
setupStore19868102137
numNetworkReqs3059658783334432
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2192162232219223
srpButtonToSrpForm95929829798
confirmSrpToPwForm24222622526
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen18162221822
doneButtonToHomeScreen63152276795682767
openAccountMenuToAccountListLoaded291729102929929292929
total39273804415712839624157
Onboarding New WalletcreateWalletToSocialScreen2202192200220220
srpButtonToPwForm1131091163115116
createPwToRecoveryScreen99100910
skipBackupToMetricsScreen41394424244
agreeButtonToOnboardingSuccess21172332323
doneButtonToAssetList57149867471597674
total9799021088739991088
Asset DetailsassetClickToPriceChart68637247172
total68637247172
Solana Asset DetailsassetClickToPriceChart61606216262
total61606216262
Import Srp HomeloginToHomeScreen21311955225210322142252
openAccountMenuAfterLogin66597356773
homeAfterImportWithNewWallet23912215250210924572502
total4540452645641745644564
Send TransactionsopenSendPageFromHome28272912929
selectTokenToSendFormLoaded36264364143
reviewTransactionToConfirmationPage1141731143827913731438
total1209801150327414431503
SwapopenSwapPageFromHome1118613218123132
fetchAndDisplaySwapQuotes268426812686226842686
total281228062819628182819
🌐 Dapp Page Load Benchmarks

Current Commit: bf8aa5b | Date: 4/1/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±70ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 740ms (±69ms) 🟢 | historical mean value: 729ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 85ms (±10ms) 🟢 | historical mean value: 87ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 70ms 1.01s 1.33s 1.26s 1.33s
domContentLoaded 740ms 69ms 700ms 1.01s 944ms 1.01s
firstPaint 85ms 10ms 68ms 156ms 96ms 156ms
firstContentfulPaint 85ms 10ms 68ms 156ms 96ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 6.84 MiB (100%)
  • ui: 8.35 MiB (100%)
  • common: 11.34 MiB (100%)

@chloeYue chloeYue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chloeYue chloeYue merged commit e1e66b2 into release/13.25.0 Apr 1, 2026
378 of 384 checks passed
@chloeYue chloeYue deleted the runway-cherry-pick-13.25.0-1774954278 branch April 1, 2026 08:22
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants