Skip to content

fix(sentry): defer breadcrumb scrubbing to send time cp-13.36.0#43600

Merged
gauthierpetetin merged 2 commits into
mainfrom
fix/sentry-defer-breadcrumb-scrubbing
Jun 16, 2026
Merged

fix(sentry): defer breadcrumb scrubbing to send time cp-13.36.0#43600
gauthierpetetin merged 2 commits into
mainfrom
fix/sentry-defer-breadcrumb-scrubbing

Conversation

@gauthierpetetin

@gauthierpetetin gauthierpetetin commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

We've noticed an important performance regression (especially on Firefox) after #43337 was merged (see Slack thread). That PR expanded address sanitization beyond EVM account addresses (Bitcoin, Solana, Tron, etc.). The fact that it resulted in a performance regression showed that the breadcrumb scrubbing function was being executed not only before sending error events to Sentry, but also on every fetch/console event when analytics was on.

In reality, we're not interested in scrubbing breadcrumbs at capture time, only at send time.

This PR fixes it by:

  • Stopping breadcrumb scrubbing at capture time (beforeBreadcrumb only filters, it no longer deep-scrubs)
  • Deep-scrubbing breadcrumbs only when events are sent: errors via rewriteReport (beforeSend), and transactions via rewriteTransactionReport (beforeSendTransaction)

Also, this PR avoids logging the full Rive runtime object on the wallet-ready screen, which Sentry's console integration would otherwise capture into breadcrumbs, thus slowing down the app.

Changelog

CHANGELOG entry: Fixes a performance issue that was slowing down the app

Related issues

Fixes: None

Manual testing steps

  1. Create a Firefox build with yarn start:mv2 --sentry
  2. Go through the onboarding and confirm performance regression is gone
  3. Confirm manual testing steps defined in this PR still work as expected

Screenshots/Recordings

None

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.

Deep address sanitization in beforeBreadcrumb blocked the main thread
during onboarding when MetaMetrics was enabled. Scrub breadcrumbs when
errors and transactions are sent instead, and stop logging the Rive
runtime object on the wallet-ready screen.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gauthierpetetin gauthierpetetin self-assigned this Jun 16, 2026
@gauthierpetetin gauthierpetetin requested a review from a team as a code owner June 16, 2026 10:07
@gauthierpetetin gauthierpetetin added the team-extension-platform Extension Platform team label Jun 16, 2026
@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.

@mm-token-exchange-service

Copy link
Copy Markdown

✨ Files requiring CODEOWNER review ✨

🔐 @MetaMask/web3auth (1 files, +1 -1)
  • 📁 ui/
    • 📁 pages/
      • 📁 onboarding-flow/
        • 📁 creation-successful/
          • 📄 wallet-ready-animation.tsx +1 -1

Copilot AI 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.

Pull request overview

This PR addresses a Sentry-related performance regression by deferring deep breadcrumb scrubbing until events are actually sent to Sentry, rather than doing heavy sanitization work at breadcrumb capture time (which can run for every fetch/console breadcrumb when analytics is enabled).

Changes:

  • Stop deep-scrubbing in beforeBreadcrumb and instead sanitize breadcrumb payloads at send time for both errors (beforeSend) and transactions (beforeSendTransaction).
  • Add rewriteTransactionReport and expand test coverage to assert breadcrumb scrubbing for both error and transaction events.
  • Prevent Sentry console breadcrumbs from capturing a large Rive runtime object by removing it from a console.log.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ui/pages/onboarding-flow/creation-successful/wallet-ready-animation.tsx Avoids logging the full Rive runtime object so Sentry’s console breadcrumb capture is lighter.
app/scripts/lib/setupSentry.js Moves breadcrumb deep-scrubbing to send-time hooks and adds transaction send-time scrubbing.
app/scripts/lib/setupSentry.test.js Adds unit tests for breadcrumb address/url scrubbing on both error and transaction reports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/scripts/lib/setupSentry.js
Comment thread app/scripts/lib/setupSentry.js
Comment thread app/scripts/lib/setupSentry.js
Remove per-breadcrumb cloneDeep now that beforeSend already clones the
report, fix JSDoc wording, and add a test that live breadcrumb sources
are not mutated during rewriteReport.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mm-token-exchange-service

Copy link
Copy Markdown
Builds ready [68fefa2]
Deprecated Browserify fallback builds
⚡ Performance Benchmarks (Total: 🟢 16 pass · 🟡 8 warn · 🔴 1 fail)

Baseline (latest main): 7663b65 | Date: 6/16/2026 | Pipeline: 27610878569 | Baseline logs

Metricschrome-webpackfirefox-webpack
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 1 failure)

Interaction Benchmarks · Samples: 5
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
confirmTx
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
bridgeUserActions
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/inp: -29%
  • bridgeUserActions/bridge_load_page: +28%
  • bridgeUserActions/bridge_load_asset_picker: -17%
  • bridgeUserActions/tbt: +11%
  • bridgeUserActions/inp: -29%
  • loadNewAccount/load_new_account: +63%
  • loadNewAccount/total: +63%
  • loadNewAccount/inp: +43%
  • loadNewAccount/fcp: -49%
  • loadNewAccount/lcp: +1193%
  • confirmTx/confirm_tx: +12%
  • confirmTx/longTaskCount: -100%
  • confirmTx/longTaskTotalDuration: -100%
  • confirmTx/longTaskMaxDuration: -100%
  • confirmTx/tbt: -100%
  • confirmTx/total: +12%
  • confirmTx/lcp: +1119%
  • bridgeUserActions/bridge_load_page: +130%
  • bridgeUserActions/bridge_load_asset_picker: +50%
  • bridgeUserActions/longTaskCount: -100%
  • bridgeUserActions/longTaskTotalDuration: -100%
  • bridgeUserActions/longTaskMaxDuration: -100%
  • bridgeUserActions/tbt: -100%
  • bridgeUserActions/total: +16%
  • bridgeUserActions/inp: -21%
  • bridgeUserActions/lcp: +1197%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 1.9s
  • 🟡 confirmTx/FCP: p75 1.9s
  • 🟡 bridgeUserActions/FCP: p75 1.8s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
startupPowerUserHome
[Sentry log · main/release]
🟡 [CI log]🟡 [CI log]

📈 Results compared to the previous 5 runs on main

  • startupPowerUserHome/inp: -12%
  • startupStandardHome/inp: -29%
  • startupPowerUserHome/backgroundConnect: -26%
  • startupPowerUserHome/firstReactRender: +13%
  • startupPowerUserHome/setupStore: -13%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 startupPowerUserHome/INP: p75 496ms
  • 🟡 startupPowerUserHome/LCP: p75 2.7s
User Journey Benchmarks · Samples: 5 · mock API 🔴 1
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
🔴 total
assetDetails
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
solanaAssetDetails
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]
importSrpHome
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
sendTransactions
[Sentry log · main/release]
🟡 [CI log]🟢 [CI log]
swap
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/metricsToWalletReadyScreen: -25%
  • onboardingImportWallet/doneButtonToHomeScreen: -88%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: -97%
  • onboardingImportWallet/longTaskCount: -80%
  • onboardingImportWallet/longTaskTotalDuration: -94%
  • onboardingImportWallet/longTaskMaxDuration: -92%
  • onboardingImportWallet/tbt: -98%
  • onboardingImportWallet/total: -87%
  • onboardingNewWallet/skipBackupToMetricsScreen: +11%
  • onboardingNewWallet/doneButtonToAssetList: -13%
  • onboardingNewWallet/longTaskTotalDuration: -27%
  • onboardingNewWallet/longTaskMaxDuration: -17%
  • onboardingNewWallet/tbt: -68%
  • solanaAssetDetails/assetClickToPriceChart: -36%
  • solanaAssetDetails/longTaskCount: -100%
  • solanaAssetDetails/longTaskTotalDuration: -100%
  • solanaAssetDetails/longTaskMaxDuration: -100%
  • solanaAssetDetails/tbt: -100%
  • solanaAssetDetails/total: -36%
  • solanaAssetDetails/inp: +34%
  • solanaAssetDetails/lcp: +12%
  • solanaAssetDetails/cls: -89%
  • importSrpHome/openAccountMenuAfterLogin: +21%
  • importSrpHome/homeAfterImportWithNewWallet: -38%
  • importSrpHome/longTaskCount: -25%
  • importSrpHome/longTaskTotalDuration: -30%
  • importSrpHome/longTaskMaxDuration: -17%
  • importSrpHome/tbt: -37%
  • importSrpHome/total: -33%
  • importSrpHome/inp: -39%
  • importSrpHome/lcp: +11%
  • sendTransactions/openSendPageFromHome: +23%
  • sendTransactions/selectTokenToSendFormLoaded: -58%
  • sendTransactions/inp: -16%
  • sendTransactions/lcp: -17%
  • sendTransactions/cls: -85%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/FCP: p75 1.9s
  • 🟡 sendTransactions/INP: p75 208ms
  • 🟡 importSrpHome/FCP: p75 1.9s
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-webpack
dappPageLoad
[Sentry log · main/release]
🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • dappPageLoad/pageLoadTime: +10%
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -555 Bytes (-0.01%)
  • ui: -164 Bytes (0%)
  • common: -13.82 KiB (-0.1%)

@DDDDDanica

Copy link
Copy Markdown
Contributor

Tested locally in FF and the regression is gone ✅

@MajorLift MajorLift 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.

  • Doesn't affect any existing instrumentation. Everything in beforeSend is still happening.
  • No additions to beforeSendTransaction necessary to avoid breaking changes other than removeUrlsFromBreadCrumb (moved out of beforeBreadcrumb).
  • The Rive object causing a performance error should be documented. I'll note that in MetaMask/skills#41
  • Firefox UI freezing non-reproable on local branch.

@gauthierpetetin gauthierpetetin added regression-RC-13.36.0 Regression bug that was found in release candidate (RC) for release 13.36.0 release-blocker This bug is blocking the next release labels Jun 16, 2026
@gauthierpetetin gauthierpetetin added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit 8aba81c Jun 16, 2026
203 of 204 checks passed
@gauthierpetetin gauthierpetetin deleted the fix/sentry-defer-breadcrumb-scrubbing branch June 16, 2026 14:35
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 16, 2026
@metamaskbot metamaskbot added the release-13.37.0 Issue or pull request that will be included in release 13.37.0 label Jun 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

regression-RC-13.36.0 Regression bug that was found in release candidate (RC) for release 13.36.0 release-13.37.0 Issue or pull request that will be included in release 13.37.0 release-blocker This bug is blocking the next release risk:medium size-M team-extension-platform Extension Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants