Skip to content

feat: analytics pref tracking for social onboarding cp-13.25.0#41343

Merged
lwin-kyaw merged 11 commits into
mainfrom
feat/analytics-pref-tracking-for-social-users
Mar 31, 2026
Merged

feat: analytics pref tracking for social onboarding cp-13.25.0#41343
lwin-kyaw merged 11 commits into
mainfrom
feat/analytics-pref-tracking-for-social-users

Conversation

@lwin-kyaw

@lwin-kyaw lwin-kyaw commented Mar 30, 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.

@lwin-kyaw lwin-kyaw requested review from a team as code owners March 30, 2026 04:31
@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-onboarding Onboarding team label Mar 30, 2026
@metamaskbotv2

metamaskbotv2 Bot commented Mar 30, 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

Comment thread ui/store/actions.ts
@metamaskbotv2

metamaskbotv2 Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor
Builds ready [e126531]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account586273912275909912
total586273912275909912
Confirm Txconfirm_tx6056603260731560696073
total6056603260731560696073
Bridge User Actionsbridge_load_page26724029523294295
bridge_load_asset_picker27320436255304362
bridge_search_token79075983032828830
total13291231148610614271486
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Startup Standard HomeuiStartup1516129016999615721676
load1243104814078512931386
domContentLoaded1235104313968312861380
domInteractive28176293050
firstPaint1777733178250301
backgroundConnect21818828216225247
firstReactRender22144362436
initialActions209224
loadScripts103385711847910821159
setupStore1564171730
numNetworkReqs34315663745
Startup Power User HomeuiStartup4587180211432185254458061
load12771140159310413181513
domContentLoaded1253112015669212931432
domInteractive3617125213489
firstPaint295901305211309375
backgroundConnect19442909263170327734640
firstReactRender26174362936
initialActions106113
loadScripts104690213608610801212
setupStore176204201732
numNetworkReqs17110029347189282
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2182182190219219
srpButtonToSrpForm93909529395
confirmSrpToPwForm23212412424
pwFormToMetricsScreen15151501515
metricsToWalletReadyScreen20152332223
doneButtonToHomeScreen5285195356532535
openAccountMenuToAccountListLoaded310731033111331093111
total4008399540231240234023
Onboarding New WalletcreateWalletToSocialScreen2192182211219221
srpButtonToPwForm1151141161116116
createPwToRecoveryScreen999099
skipBackupToMetricsScreen44424514545
agreeButtonToOnboardingSuccess18171801818
doneButtonToAssetList53851456018549560
total94492096718955967
Asset DetailsassetClickToPriceChart64586946669
total64586946669
Solana Asset DetailsassetClickToPriceChart604571107171
total604571107171
Import Srp HomeloginToHomeScreen2147213221752021752175
openAccountMenuAfterLogin54505625556
homeAfterImportWithNewWallet32327235734350357
total25942413292019425442920
Send TransactionsopenSendPageFromHome25193042730
selectTokenToSendFormLoaded33244063840
reviewTransactionToConfirmationPage1014767137123011971371
total1078854142222512661422
SwapopenSwapPageFromHome1101081122112112
fetchAndDisplaySwapQuotes2692267927181527012718
total2800276728302128092830
🌐 Dapp Page Load Benchmarks

Current Commit: e126531 | Date: 3/30/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±38ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 723ms (±35ms) 🟢 | historical mean value: 727ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 84ms (±11ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 38ms 1.00s 1.31s 1.08s 1.31s
domContentLoaded 723ms 35ms 699ms 983ms 750ms 983ms
firstPaint 84ms 11ms 72ms 180ms 92ms 180ms
firstContentfulPaint 84ms 11ms 72ms 180ms 92ms 180ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -49.06 KiB (-0.7%)
  • ui: -74.34 KiB (-0.87%)
  • common: -15.02 KiB (-0.13%)

Comment thread ui/pages/onboarding-flow/metametrics/metametrics.tsx
@metamaskbotv2

metamaskbotv2 Bot commented Mar 30, 2026

Copy link
Copy Markdown
Contributor
Builds ready [4cd8e8b]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account79238911332769551133
total79238911332769551133
Confirm Txconfirm_tx6043600860933260616093
total6043600860933260616093
Bridge User Actionsbridge_load_page2952863006300300
bridge_load_asset_picker31027934430335344
bridge_search_token90577610319710021031
total14911310166612315811666
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Startup Standard HomeuiStartup1509130519179715601656
load1233104614638612871363
domContentLoaded1223104014228312691353
domInteractive281895132856
firstPaint186811326137246317
backgroundConnect21518725113222241
firstReactRender21144762233
initialActions107113
loadScripts102584312198110671153
setupStore1475061724
numNetworkReqs36316273951
Startup Power User HomeuiStartup49532138158723201551713295
load12991143209213413231540
domContentLoaded12801132207412413121505
domInteractive3621262283656
firstPaint2741061533212307408
backgroundConnect2127277124652922288910118
firstReactRender26176692742
initialActions106113
loadScripts1071918176411410881279
setupStore1665781930
numNetworkReqs2178743676246374
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2212182222221222
srpButtonToSrpForm96949719797
confirmSrpToPwForm23222412424
pwFormToMetricsScreen16151601616
metricsToWalletReadyScreen18171801818
doneButtonToHomeScreen108798711827411361182
openAccountMenuToAccountListLoaded269826942705527052705
total4141401142519041954251
Onboarding New WalletcreateWalletToSocialScreen2192192201220220
srpButtonToPwForm1141111152115115
createPwToRecoveryScreen989099
skipBackupToMetricsScreen46415555055
agreeButtonToOnboardingSuccess18172111821
doneButtonToAssetList1136100612427911821242
total1545141816427916121642
Asset DetailsassetClickToPriceChart896811318106113
total896811318106113
Solana Asset DetailsassetClickToPriceChart68568297282
total68568297282
Import Srp HomeloginToHomeScreen2146213621631021432163
openAccountMenuAfterLogin43394524445
homeAfterImportWithNewWallet91368822975634292339756
total1116911010114191621120411419
Send TransactionsopenSendPageFromHome21152642226
selectTokenToSendFormLoaded24242502525
reviewTransactionToConfirmationPage87784891829905918
total92789497530944975
SwapopenSwapPageFromHome61381002368100
fetchAndDisplaySwapQuotes269226802706926962706
total2753271827882727742788
🌐 Dapp Page Load Benchmarks

Current Commit: 4cd8e8b | Date: 3/30/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±52ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 736ms (±49ms) 🟢 | historical mean value: 728ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 85ms (±11ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 52ms 1.01s 1.35s 1.09s 1.35s
domContentLoaded 736ms 49ms 706ms 1.01s 782ms 1.01s
firstPaint 85ms 11ms 68ms 180ms 96ms 180ms
firstContentfulPaint 85ms 11ms 68ms 180ms 96ms 180ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 7.08 KiB (0.1%)
  • ui: 719 Bytes (0.01%)
  • common: 5.78 KiB (0.05%)

@lwin-kyaw lwin-kyaw changed the title feat: analytics pref tracking for social onboarding feat: analytics pref tracking for social onboarding cp-13.25.0 Mar 31, 2026
Comment thread test/e2e/tests/metrics/wallet-imported.spec.ts Outdated
@metamaskbotv2

metamaskbotv2 Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor
Builds ready [4bc52dd]
⚡ Performance Benchmarks (Total: 🟢 18 pass · 🟡 0 warn · 🔴 0 fail)

Baseline (latest main): 7a99d2d | Date: 12/19/58214 | Pipeline: 23776150669 | Baseline logs

Interaction Benchmarks
Benchmarkchrome-browserify
loadNewAccount🟢 [Show logs]
confirmTx🟢 [Show logs]
bridgeUserActions🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: +32%
  • loadNewAccount/total: +32%
  • bridgeUserActions/bridge_load_asset_picker: +14%
Startup Benchmarks
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/initialActions: +43%
  • startupPowerUserHome/domInteractive: -16%
  • startupPowerUserHome/backgroundConnect: +10%
  • startupPowerUserHome/firstReactRender: -13%
  • startupPowerUserHome/initialActions: -17%
  • startupPowerUserHome/setupStore: -10%
  • startupPowerUserHome/numNetworkReqs: -29%
  • startupPowerUserHome/numNetworkReqs: +17%
  • startupStandardHome/domInteractive: +13%
  • startupStandardHome/initialActions: -17%
  • startupPowerUserHome/domInteractive: +23%
  • startupPowerUserHome/firstReactRender: +12%
  • startupPowerUserHome/setupStore: -32%
  • startupStandardHome/initialActions: +43%
  • startupStandardHome/setupStore: +21%
  • startupPowerUserHome/domInteractive: -27%
  • startupPowerUserHome/setupStore: -33%
User Journey Benchmarks
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟢 [Show logs]
solanaAssetDetails🟢 [Show logs]
importSrpHome🟢 [Show logs]
sendTransactions🟢 [Show logs]
swap🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/metricsToWalletReadyScreen: +39%
  • onboardingImportWallet/doneButtonToHomeScreen: -77%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +167%
  • onboardingImportWallet/total: -33%
  • onboardingNewWallet/doneButtonToAssetList: -36%
  • onboardingNewWallet/total: -25%
  • assetDetails/assetClickToPriceChart: -38%
  • assetDetails/total: -38%
  • importSrpHome/openAccountMenuAfterLogin: -26%
  • importSrpHome/homeAfterImportWithNewWallet: -27%
  • importSrpHome/total: -24%
  • swap/openSwapPageFromHome: -89%
  • swap/fetchAndDisplaySwapQuotes: +30%
🌐 Dapp Page Load Benchmarks

Current Commit: 4bc52dd | Date: 3/31/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±40ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 722ms (±38ms) 🟢 | historical mean value: 729ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 85ms (±10ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 40ms 1.01s 1.34s 1.06s 1.34s
domContentLoaded 722ms 38ms 701ms 1.02s 745ms 1.02s
firstPaint 85ms 10ms 64ms 156ms 92ms 156ms
firstContentfulPaint 85ms 10ms 64ms 156ms 92ms 156ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 7.52 KiB (0.11%)
  • ui: -22.1 KiB (-0.26%)
  • common: 3.84 KiB (0.03%)

Comment thread ui/pages/onboarding-flow/metametrics/metametrics.tsx
Comment thread ui/pages/onboarding-flow/metametrics/metametrics.tsx

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@sonarqubecloud

Copy link
Copy Markdown

@metamaskbotv2

metamaskbotv2 Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor
Builds ready [1223d6d]
⚡ Performance Benchmarks (Total: 🟢 17 pass · 🟡 0 warn · 🔴 1 fail)

Baseline (latest main): d87952d | Date: 1/31/58215 | Pipeline: 23780816187 | Baseline logs

Metricschrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupPowerUserHome🟢 [logs]🟢 [logs]🔴 [logs]🟢 [logs]

Regressions (🔴 1 failure)

  • startupPowerUserHome · firefox-browserify — loadScripts(p95) [Show logs]
Interaction Benchmarks
Benchmarkchrome-browserify
loadNewAccount🟢 [Show logs]
confirmTx🟢 [Show logs]
bridgeUserActions🟢 [Show logs]
Startup Benchmarks 🔴 1
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟢 [Show logs]🟢 [Show logs]
🟡 load
[Show logs]
🔴 loadScripts
[Show logs]
🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/initialActions: -38%
  • startupPowerUserHome/backgroundConnect: +21%
  • startupPowerUserHome/initialActions: -17%
  • startupPowerUserHome/numNetworkReqs: -52%
  • startupPowerUserHome/uiStartup: +15%
  • startupPowerUserHome/firstPaint: +21%
  • startupPowerUserHome/numNetworkReqs: -28%
  • startupStandardHome/initialActions: -17%
  • startupPowerUserHome/loadScripts: +13%
  • startupStandardHome/firstReactRender: +13%
  • startupStandardHome/initialActions: +43%
  • startupStandardHome/setupStore: +18%
  • startupPowerUserHome/domInteractive: +11%
  • startupPowerUserHome/firstReactRender: +11%
  • startupPowerUserHome/setupStore: -20%
User Journey Benchmarks
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟢 [Show logs]
solanaAssetDetails🟢 [Show logs]
importSrpHome🟢 [Show logs]
sendTransactions🟢 [Show logs]
swap🟢 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/metricsToWalletReadyScreen: +86%
  • onboardingImportWallet/doneButtonToHomeScreen: -77%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +172%
  • onboardingImportWallet/total: -34%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: +12%
  • onboardingNewWallet/doneButtonToAssetList: -30%
  • onboardingNewWallet/total: -25%
  • importSrpHome/openAccountMenuAfterLogin: -24%
  • importSrpHome/homeAfterImportWithNewWallet: -39%
  • importSrpHome/total: -35%
  • swap/openSwapPageFromHome: -88%
  • swap/fetchAndDisplaySwapQuotes: +35%
🌐 Dapp Page Load Benchmarks

Current Commit: 1223d6d | Date: 3/31/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±38ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 724ms (±36ms) 🟢 | historical mean value: 730ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 85ms (±8ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 38ms 1.00s 1.32s 1.05s 1.32s
domContentLoaded 724ms 36ms 700ms 1.01s 747ms 1.01s
firstPaint 85ms 8ms 72ms 148ms 92ms 148ms
firstContentfulPaint 85ms 8ms 72ms 148ms 92ms 148ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 592 Bytes (0.01%)
  • common: 296 Bytes (0%)

@smgv smgv 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!

@lwin-kyaw lwin-kyaw enabled auto-merge March 31, 2026 09:51
@lwin-kyaw lwin-kyaw added this pull request to the merge queue Mar 31, 2026
Merged via the queue into main with commit efb4de3 Mar 31, 2026
207 of 208 checks passed
@lwin-kyaw lwin-kyaw deleted the feat/analytics-pref-tracking-for-social-users branch March 31, 2026 10:49
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
@metamaskbot metamaskbot added the release-13.26.0 Issue or pull request that will be included in release 13.26.0 label Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.26.0 Issue or pull request that will be included in release 13.26.0 size-L team-onboarding Onboarding team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Analytics Preference Selected segment not working during onboarding

4 participants