Skip to content

feat(telemetry): add msSinceLastUiInteraction to sampled state writes - #47490

Merged
gauthierpetetin merged 2 commits into
mainfrom
feat/telemetry-ms-since-last-ui-interaction
Nov 5, 2026
Merged

gauthierpetetin merged 2 commits into
mainfrom
feat/telemetry-ms-since-last-ui-interaction

Conversation

@gauthierpetetin

@gauthierpetetin gauthierpetetin commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Stacked on #47455 (feat/telemetry-last-activity-state-writes).

Adds the ADR 0068 Option C msSinceLastUiInteraction signal to sampled State Persist writes.

Trusted pointerdown and keydown events in MetaMask UI surfaces are throttled to once per second and forwarded to the background through a new AppStateController:recordUiInteraction messenger action. The background stamps lastUiInteractionAt in storage.session and sampled writes expose state.write.ms_since_ui_interaction.

It's on purpose that this path is separate from setLastActiveTime, which only runs while auto-lock is enabled and uses a broader idle-timer event set.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

  1. Reproduce manual testing steps detailed in this PR: feat(persistence): add sampled split-state write telemetry #46286
  2. Confirm ms_since_ui_interaction property is now added to state.write metdata of State Persist traces in Sentry.
Screenshot 2026-11-03 at 15 33 37

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.

Made with Cursor


Note

Low Risk
Observability-only changes with throttled listeners, ignored failures, and no auth or persistence logic changes beyond existing session last-activity fields.

Reviewed by Cursor Bugbot for commit 1d66f4e. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

🟡 Changes recommended

The interaction throttle can suppress trusted activity after the system clock moves backward, leaving the activity signal stale until wall time catches up.

1 open issue
What changed in this PR

Extends the last-activity telemetry introduced in #47455 with time since the last trusted UI interaction, helping analysts interpret sampled state writes independently of auto-lock settings.

Changes:

  • Captures trusted pointer and keyboard events, throttled to one report per second per UI surface.
  • Records interaction timestamps in background session storage so they survive UI closure and service-worker restarts.
  • Adds state.write.ms_since_ui_interaction to sampled telemetry, with unit coverage across the reporting path.
File Description
ui/​store/​actions.ts Adds best-effort forwarding of UI interactions to the background.
ui/​store/​actions.test.js Tests forwarding and swallowed background errors.
ui/​pages/​routes/​routes.component.tsx Mounts the interaction reporter independently of auto-lock.
ui/​hooks/​useUiInteractionReporter.ts Captures and throttles trusted interaction events.
ui/​hooks/​useUiInteractionReporter.test.ts Tests throttling, event filtering, and listener cleanup.
shared/​lib/​telemetry/​state-write-reporter.ts Includes interaction elapsed time in sampled telemetry.
shared/​lib/​telemetry/​state-write-reporter.test.ts Tests inclusion and omission of the new attribute.
shared/​lib/​telemetry/​last-activity.ts Records, persists, restores, and exposes interaction timestamps.
shared/​lib/​telemetry/​last-activity.test.ts Tests persistence, UI closure, and hydration behavior.
app/​scripts/​controllers/​app-state-controller.ts Exposes the background interaction-recording method.
app/​scripts/​controllers/​app-state-controller.test.ts Tests delegation to last-activity tracking.
app/​scripts/​controllers/​app-state-controller-method-action-types.ts Defines and registers the messenger action type.

Review effort: Balanced

Comment thread ui/hooks/useUiInteractionReporter.ts Resolved
@metamask-ci

metamask-ci Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor
Builds ready [9eba56a]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 3 warn · 🔴 2 fail)

Baseline (latest main): 171ed20 | Date: 7/28/2026 | Pipeline: 40883940264 | Baseline logs

Metricschrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 load_new_account(p95) [CI log]🔴 load_new_account(p95) [CI log]

Regressions (🔴 2 failures)

Interaction Benchmarks · Samples: 5 🔴 2
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 [CI log]
🔴 load_new_account
🔴 [CI log]
🔴 load_new_account
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/load_new_account: +420%
  • ↑ loadNewAccount/total: +420%
  • ↑ loadNewAccount/fcp: +11%
  • ↑ loadNewAccount/lcp: +23%
  • ↑ confirmTx/longTaskCount: +33%
  • ↑ confirmTx/longTaskTotalDuration: +71%
  • ↑ confirmTx/longTaskMaxDuration: +98%
  • ↑ confirmTx/tbt: +115%
  • ↓ confirmTx/inp: -17%
  • ↑ confirmTx/fcp: +11%
  • ↑ confirmTx/lcp: +18%
  • ↑ bridgeUserActions/bridge_load_page: +102%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +34%
  • ↑ bridgeUserActions/longTaskCount: +122%
  • ↑ bridgeUserActions/longTaskTotalDuration: +180%
  • ↑ bridgeUserActions/longTaskMaxDuration: +65%
  • ↑ bridgeUserActions/tbt: +325%
  • ↑ bridgeUserActions/total: +14%
  • ↑ bridgeUserActions/inp: +15%
  • ↑ bridgeUserActions/fcp: +10%
  • ↑ loadNewAccount/load_new_account: +417%
  • ↑ loadNewAccount/total: +417%
  • ↓ loadNewAccount/fcp: -34%
  • ↑ loadNewAccount/lcp: +1294%
  • ↓ confirmTx/longTaskCount: -100%
  • ↓ confirmTx/longTaskTotalDuration: -100%
  • ↓ confirmTx/longTaskMaxDuration: -100%
  • ↓ confirmTx/tbt: -100%
  • ↓ confirmTx/inp: -24%
  • ↓ confirmTx/fcp: -32%
  • ↑ confirmTx/lcp: +1367%
  • ↑ bridgeUserActions/bridge_load_page: +306%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +225%
  • ↓ bridgeUserActions/longTaskCount: -100%
  • ↓ bridgeUserActions/longTaskTotalDuration: -100%
  • ↓ bridgeUserActions/longTaskMaxDuration: -100%
  • ↓ bridgeUserActions/tbt: -100%
  • ↑ bridgeUserActions/total: +66%
  • ↑ bridgeUserActions/inp: +54%
  • ↓ bridgeUserActions/fcp: -37%
  • ↑ bridgeUserActions/lcp: +1279%

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

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

📈 Results compared to the previous 5 runs on main

  • ↑ startupStandardHome/domInteractive: +19%
  • ↓ startupStandardHome/firstReactRender: -99%
  • ↓ startupStandardHome/initialActions: -33%
  • ↑ startupStandardHome/setupStore: +188%
  • ↓ startupStandardHome/longTaskCount: -33%
  • ↓ startupStandardHome/domInteractive: -37%
  • ↓ startupStandardHome/firstReactRender: -98%
  • ↓ startupStandardHome/initialActions: -50%
  • ↑ startupStandardHome/setupStore: +131%
  • ↓ startupStandardHome/fcp: -34%
User Journey Benchmarks · Samples: 5 · mock API
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 total
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🟢 [CI log]

📈 Results compared to the previous 5 runs on main

  • ↑ onboardingImportWallet/confirmSrpToPwForm: +11%
  • ↓ onboardingImportWallet/doneButtonToHomeScreen: -94%
  • ↓ onboardingImportWallet/openAccountMenuToAccountListLoaded: -75%
  • ↓ onboardingImportWallet/longTaskCount: -100%
  • ↓ onboardingImportWallet/longTaskTotalDuration: -100%
  • ↓ onboardingImportWallet/longTaskMaxDuration: -100%
  • ↓ onboardingImportWallet/tbt: -100%
  • ↓ onboardingImportWallet/total: -89%
  • ↓ onboardingNewWallet/agreeButtonToOnboardingSuccess: -12%
  • ↓ onboardingNewWallet/doneButtonToAssetList: -83%
  • ↓ onboardingNewWallet/longTaskCount: -100%
  • ↓ onboardingNewWallet/longTaskTotalDuration: -100%
  • ↓ onboardingNewWallet/longTaskMaxDuration: -100%
  • ↓ onboardingNewWallet/tbt: -100%
  • ↓ onboardingNewWallet/total: -80%
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: -53%
  • ↓ dappPageLoad/firstPaint: -32%
  • ↓ dappPageLoad/firstContentfulPaint: -32%
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
Status Bundle Total Diff Change
🚨 background 15.41 MiB +3.57 KiB +0.02%
🚨 ui 19.27 MiB +4.08 KiB +0.02%
✅ common 0 Bytes 0 Bytes 0.00%
✅ other 4.44 MiB +19 Bytes 0.00%
✅ content scripts 3.23 MiB +38 Bytes 0.00%
🚨 unzipped 79.76 MiB +7.71 KiB +0.01%
🚨 zip 24.04 MiB +2.02 KiB +0.01%

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

@gauthierpetetin gauthierpetetin self-assigned this Oct 29, 2026
@gauthierpetetin
gauthierpetetin marked this pull request as ready for review October 29, 2026 16:01
Base automatically changed from feat/telemetry-last-activity-state-writes to main November 2, 2026 21:27
Co-authored-by: Cursor <cursoragent@cursor.com>
@metamask-ci

metamask-ci Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor
Builds ready [90a8c6f]
⚡ Performance Benchmarks (Total: 🟢 4 pass · 🟡 5 warn · 🔴 4 fail)

Baseline (latest main): 171ed20 | Date: 7/28/2026 | Pipeline: 41528559110 | Baseline logs

Metricschrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 load_new_account(p95) [CI log]🔴 load_new_account(p95) [CI log]
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 4 failures)

Interaction Benchmarks · Samples: 5 🔴 2
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 [CI log]
🔴 load_new_account
🔴 [CI log]
🔴 load_new_account
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/load_new_account: +418%
  • ↑ loadNewAccount/total: +418%
  • ↑ loadNewAccount/fcp: +12%
  • ↑ loadNewAccount/cls: +1181%
  • ↑ confirmTx/confirm_tx: +11%
  • ↑ confirmTx/longTaskTotalDuration: +90%
  • ↑ confirmTx/longTaskMaxDuration: +100%
  • ↑ confirmTx/tbt: +129%
  • ↑ confirmTx/total: +11%
  • ↑ confirmTx/fcp: +14%
  • ↑ confirmTx/lcp: +17%
  • ↑ confirmTx/cls: +12%
  • ↑ bridgeUserActions/bridge_load_page: +116%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +114%
  • ↑ bridgeUserActions/longTaskCount: +67%
  • ↑ bridgeUserActions/longTaskTotalDuration: +93%
  • ↑ bridgeUserActions/longTaskMaxDuration: +22%
  • ↑ bridgeUserActions/tbt: +152%
  • ↑ bridgeUserActions/total: +22%
  • ↑ bridgeUserActions/inp: +15%
  • ↑ bridgeUserActions/fcp: +13%
  • ↑ bridgeUserActions/lcp: +11%
  • ↑ bridgeUserActions/cls: +1181%
  • ↑ loadNewAccount/load_new_account: +418%
  • ↑ loadNewAccount/total: +418%
  • ↓ loadNewAccount/inp: -24%
  • ↑ loadNewAccount/fcp: +20%
  • ↑ loadNewAccount/lcp: +1321%
  • ↓ confirmTx/longTaskCount: -100%
  • ↓ confirmTx/longTaskTotalDuration: -100%
  • ↓ confirmTx/longTaskMaxDuration: -100%
  • ↓ confirmTx/tbt: -100%
  • ↑ confirmTx/fcp: +26%
  • ↑ confirmTx/lcp: +1372%
  • ↑ bridgeUserActions/bridge_load_page: +414%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +215%
  • ↓ bridgeUserActions/longTaskCount: -100%
  • ↓ bridgeUserActions/longTaskTotalDuration: -100%
  • ↓ bridgeUserActions/longTaskMaxDuration: -100%
  • ↓ bridgeUserActions/tbt: -100%
  • ↑ bridgeUserActions/total: +60%
  • ↑ bridgeUserActions/inp: +62%
  • ↑ bridgeUserActions/fcp: +24%
  • ↑ bridgeUserActions/lcp: +1344%

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

  • 🟡 loadNewAccount/FCP: p75 1.9s
  • 🟡 confirmTx/FCP: p75 2.0s
  • 🟡 bridgeUserActions/FCP: p75 2.0s
  • 🟡 loadNewAccount/FCP: p75 2.1s
  • 🟡 confirmTx/FCP: p75 2.2s
  • 🟡 bridgeUserActions/FCP: p75 2.2s
  • 🟡 bridgeUserActions/LCP: p75 2.5s
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpackfirefox-webpack
startupStandardHome
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 loadScripts

📈 Results compared to the previous 5 runs on main

  • ↓ startupStandardHome/uiStartup: -26%
  • ↓ startupStandardHome/load: -29%
  • ↓ startupStandardHome/domContentLoaded: -29%
  • ↓ startupStandardHome/domInteractive: -19%
  • ↓ startupStandardHome/firstPaint: -17%
  • ↓ startupStandardHome/backgroundConnect: -33%
  • ↓ startupStandardHome/firstReactRender: -99%
  • ↓ startupStandardHome/initialActions: -33%
  • ↓ startupStandardHome/loadScripts: -29%
  • ↑ startupStandardHome/setupStore: +74%
  • ↓ startupStandardHome/longTaskCount: -33%
  • ↓ startupStandardHome/longTaskTotalDuration: -38%
  • ↓ startupStandardHome/longTaskMaxDuration: -35%
  • ↓ startupStandardHome/tbt: -39%
  • ↓ startupStandardHome/inp: -24%
  • ↓ startupStandardHome/fcp: -30%
  • ↓ startupStandardHome/lcp: -13%
  • ↑ startupStandardHome/domInteractive: +42%
  • ↓ startupStandardHome/firstReactRender: -99%
  • ↓ startupStandardHome/initialActions: -50%
  • ↑ startupStandardHome/setupStore: +137%
  • ↑ startupStandardHome/fcp: +46%
User Journey Benchmarks · Samples: 5 · mock API 🔴 2
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
🔴 total
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
🔴 total

📈 Results compared to the previous 5 runs on main

  • ↑ onboardingImportWallet/srpButtonToSrpForm: +14%
  • ↑ onboardingImportWallet/confirmSrpToPwForm: +13%
  • ↓ onboardingImportWallet/doneButtonToHomeScreen: -94%
  • ↓ onboardingImportWallet/openAccountMenuToAccountListLoaded: -75%
  • ↓ onboardingImportWallet/longTaskCount: -100%
  • ↓ onboardingImportWallet/longTaskTotalDuration: -100%
  • ↓ onboardingImportWallet/longTaskMaxDuration: -100%
  • ↓ onboardingImportWallet/tbt: -100%
  • ↓ onboardingImportWallet/total: -89%
  • ↑ onboardingNewWallet/srpButtonToPwForm: +41%
  • ↑ onboardingNewWallet/createPwToRecoveryScreen: +23%
  • ↑ onboardingNewWallet/skipBackupToMetricsScreen: +16%
  • ↑ onboardingNewWallet/agreeButtonToOnboardingSuccess: +23%
  • ↓ onboardingNewWallet/doneButtonToAssetList: -78%
  • ↓ onboardingNewWallet/longTaskCount: -69%
  • ↓ onboardingNewWallet/longTaskTotalDuration: -79%
  • ↓ onboardingNewWallet/longTaskMaxDuration: -50%
  • ↓ onboardingNewWallet/tbt: -99%
  • ↓ onboardingNewWallet/total: -74%
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: -54%
  • ↓ dappPageLoad/firstPaint: -37%
  • ↓ dappPageLoad/firstContentfulPaint: -37%
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
Status Bundle Total Diff Change
✅ background 15.26 MiB +483 Bytes 0.00%
🚨 ui 19.33 MiB +1.36 KiB +0.01%
✅ common 0 Bytes 0 Bytes 0.00%
✅ other 4.44 MiB +7 Bytes 0.00%
✅ content scripts 3.23 MiB +14 Bytes 0.00%
🚨 unzipped 79.89 MiB +1.86 KiB 0.00%
✅ zip 24.07 MiB +495 Bytes 0.00%

@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue Nov 3, 2026
@gauthierpetetin
gauthierpetetin enabled stacked auto-merge November 3, 2026 15:17

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

Sentry span volume from the new interaction reports. The inline change keeps msSinceLastUiInteraction as it is and drops the spans these reports add: up to about 1M a month in the production metamask project, by the estimate below.

How the estimate was made

Production metamask, 2026-10-29 to 2026-11-05 (transactions by name, rpc.handler spans):

Transactions Users
Background RPC: setLastActiveTime 1,344 833
Background RPC: messengerCall 158,079
State Persist 89,331
All rpc.handler spans 3,424,090 73,343

setLastActiveTime goes through the same wrapper gate with the same one-second throttle, and fires on every input this hook forwards except pen, but only for users with auto-lock on, which is off by default. Scaling it to every user with a sampled background call gives 1,344 × 73,343 / 833 ≈ 118,000 sampled calls a week, each sent as two single-span transactions.

That adds up to 75% to that week's messengerCall bucket, and about 236,000 transactions in all, more than twice the State Persist writes the new field labels. It's an upper bound, and it assumes users with auto-lock on interact about as often as everyone else.

Comment thread ui/store/actions.ts Outdated
> {
return async () => {
try {
await submitRequestToBackground('AppStateController:recordUiInteraction');

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.

Sending this call without trace context keeps the timestamp and stops sampled clicks from becoming Sentry transactions.

A click or keypress forwarded while a UI span is active carries that span's context to the background. When the call passes the shared 0.5% wrapper gate, it becomes two single-span transactions in that trace, Background RPC: messengerCall and Messenger Call: AppStateController:recordUiInteraction. The background continues the trace as sampled, so tracesSampler's per-name rates never apply, and sentry.wrapperSampleRate can lower this only by lowering every background-call span with it.

Nothing runs under this call in the background, so dropping the context loses no nested span, and msSinceLastUiInteraction still reaches State Persist.

The helper runs the callback inside a void wrapper because Sentry keeps the forked scope until a returned promise settles. Returning the promise from withActiveSpan would hide the active span from other UI work until the background replies, which the second test catches.

Here's a diff if it helps:

diff --git a/shared/lib/trace.ts b/shared/lib/trace.ts
index 8c4e5687937..6a80fd7a805 100644
--- a/shared/lib/trace.ts
+++ b/shared/lib/trace.ts
@@ -565,6 +565,30 @@ export function getSerializedTraceContext():
   }
 }
 
+/**
+ * Run the callback with no active span, so a `submitRequestToBackground` call
+ * inside it carries no trace context and the background emits no wrapper spans
+ * for it. The callback runs inside a void wrapper because Sentry keeps the
+ * forked scope until a returned promise settles, which would hide the active
+ * span from unrelated UI work in the meantime.
+ *
+ * @param callback - Code whose background calls should not join the active trace.
+ * @returns The callback's return value.
+ */
+export function withoutTraceContext<ReturnValue>(
+  callback: () => ReturnValue,
+): ReturnValue {
+  const withActiveSpan = globalThis.sentry?.withActiveSpan;
+  if (!withActiveSpan) {
+    return callback();
+  }
+  let result: ReturnValue | undefined;
+  withActiveSpan(null, () => {
+    result = callback();
+  });
+  return result as ReturnValue;
+}
+
 /**
  * Extract trace context appended by submitRequestToBackground from RPC params.
  * Returns the clean params (without trace context) and the trace context if present.
diff --git a/ui/store/actions.test.js b/ui/store/actions.test.js
index 25e726db32d..d1004e019d5 100644
--- a/ui/store/actions.test.js
+++ b/ui/store/actions.test.js
@@ -13,6 +13,7 @@ import { TransactionStatus } from '@metamask/transaction-controller';
 import { NotificationServicesController } from '@metamask/notification-services-controller';
 import { BACKUPANDSYNC_FEATURES } from '@metamask/profile-sync-controller/user-storage';
 import { SubscriptionUserEvent } from '@metamask/subscription-controller';
+import * as Sentry from '@sentry/browser';
 // TODO: Remove restricted import
 // eslint-disable-next-line import-x/no-restricted-paths
 import enLocale from '../../app/_locales/en/messages.json';
@@ -6639,5 +6640,50 @@ describe('Actions', () => {
         store.dispatch(actions.recordUiInteraction()),
       ).resolves.toBeUndefined();
     });
+
+    describe('while a UI span is active', () => {
+      beforeEach(() => {
+        globalThis.sentry = { ...Sentry };
+      });
+
+      afterEach(() => {
+        globalThis.sentry = undefined;
+      });
+
+      it('sends no trace context', async () => {
+        const store = mockStore();
+        const messengerCallStub = sinon.stub().resolves();
+        setBackgroundConnection({ messengerCall: messengerCallStub });
+
+        await Sentry.startSpan({ name: 'ui' }, () =>
+          store.dispatch(actions.recordUiInteraction()),
+        );
+
+        expect(
+          messengerCallStub.calledOnceWithExactly(
+            'AppStateController:recordUiInteraction',
+            [],
+          ),
+        ).toBe(true);
+      });
+
+      it('keeps the span active while the call is pending', async () => {
+        const store = mockStore();
+        let resolveCall;
+        setBackgroundConnection({
+          messengerCall: () =>
+            new Promise((resolve) => {
+              resolveCall = resolve;
+            }),
+        });
+
+        await Sentry.startSpan({ name: 'ui' }, async (span) => {
+          const pending = store.dispatch(actions.recordUiInteraction());
+          expect(Sentry.getActiveSpan()).toBe(span);
+          resolveCall();
+          await pending;
+        });
+      });
+    });
   });
 });
diff --git a/ui/store/actions.ts b/ui/store/actions.ts
index 636b90e5da8..24acd8c1276 100644
--- a/ui/store/actions.ts
+++ b/ui/store/actions.ts
@@ -198,6 +198,7 @@ import {
   TraceName,
   TraceOperation,
   TraceRequest,
+  withoutTraceContext,
 } from '../../shared/lib/trace';
 import type { SerializedTraceContext } from '../../shared/lib/trace';
 import { SortCriteria } from '../components/app/assets/util/sort';
@@ -5757,7 +5758,9 @@ export function recordUiInteraction(): ThunkAction<
 > {
   return async () => {
     try {
-      await submitRequestToBackground('AppStateController:recordUiInteraction');
+      await withoutTraceContext(() =>
+        submitRequestToBackground('AppStateController:recordUiInteraction'),
+      );
     } catch {
       // Telemetry must not surface background failures in the UI.
     }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, it's updated in this commit: 1d66f4e

Co-authored-by: Cursor <cursoragent@cursor.com>
@metamask-ci

metamask-ci Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor
Builds ready [1d66f4e]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 4 warn · 🔴 3 fail)

Baseline (latest main): f693520 | Date: 11/3/2026 | Pipeline: 42058229302 | Baseline logs

Metricschrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 load_new_account(p95) [CI log]🔴 load_new_account(p95) [CI log]
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]

Regressions (🔴 3 failures)

Interaction Benchmarks · Samples: 5 🔴 2
Benchmarkchrome-webpackfirefox-webpack
loadNewAccount
[Sentry log · main/release]
🔴 [CI log]
🔴 load_new_account
🔴 [CI log]
🔴 load_new_account
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/load_new_account: +182%
  • ↑ loadNewAccount/total: +182%
  • ↓ loadNewAccount/inp: -18%
  • ↑ loadNewAccount/lcp: +956%
  • ↑ loadNewAccount/cls: +241%
  • ↑ confirmTx/longTaskTotalDuration: +34%
  • ↑ confirmTx/longTaskMaxDuration: +46%
  • ↑ confirmTx/tbt: +58%
  • ↓ confirmTx/inp: -13%
  • ↑ confirmTx/fcp: +11%
  • ↑ confirmTx/lcp: +1010%
  • ↓ confirmTx/cls: -12%
  • ↑ bridgeUserActions/bridge_load_page: +151%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +29%
  • ↑ bridgeUserActions/longTaskTotalDuration: +40%
  • ↑ bridgeUserActions/longTaskMaxDuration: +60%
  • ↑ bridgeUserActions/tbt: +117%
  • ↑ bridgeUserActions/total: +18%
  • ↑ bridgeUserActions/inp: +10%
  • ↑ bridgeUserActions/lcp: +986%
  • ↑ bridgeUserActions/cls: +570%
  • ↑ loadNewAccount/load_new_account: +183%
  • ↑ loadNewAccount/total: +183%
  • ↓ loadNewAccount/inp: -18%
  • ↑ loadNewAccount/fcp: +21%
  • ↑ loadNewAccount/lcp: +1239%
  • ↓ confirmTx/longTaskCount: -100%
  • ↓ confirmTx/longTaskTotalDuration: -100%
  • ↓ confirmTx/longTaskMaxDuration: -100%
  • ↓ confirmTx/tbt: -100%
  • ↓ confirmTx/inp: -21%
  • ↓ confirmTx/fcp: -33%
  • ↑ confirmTx/lcp: +1322%
  • ↑ bridgeUserActions/bridge_load_page: +267%
  • ↑ bridgeUserActions/bridge_load_asset_picker: +122%
  • ↓ bridgeUserActions/longTaskCount: -100%
  • ↓ bridgeUserActions/longTaskTotalDuration: -100%
  • ↓ bridgeUserActions/longTaskMaxDuration: -100%
  • ↓ bridgeUserActions/tbt: -100%
  • ↑ bridgeUserActions/total: +48%
  • ↑ bridgeUserActions/inp: +54%
  • ↓ bridgeUserActions/fcp: -35%
  • ↑ bridgeUserActions/lcp: +1268%

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

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

📈 Results compared to the previous 5 runs on main

  • ↑ startupStandardHome/uiStartup: +23%
  • ↑ startupStandardHome/load: +47%
  • ↑ startupStandardHome/domContentLoaded: +46%
  • ↓ startupStandardHome/firstPaint: -43%
  • ↓ startupStandardHome/backgroundConnect: -24%
  • ↓ startupStandardHome/firstReactRender: -98%
  • ↓ startupStandardHome/initialActions: -64%
  • ↑ startupStandardHome/loadScripts: +45%
  • ↑ startupStandardHome/setupStore: +62%
  • ↑ startupStandardHome/longTaskCount: +43%
  • ↑ startupStandardHome/longTaskTotalDuration: +40%
  • ↑ startupStandardHome/longTaskMaxDuration: +62%
  • ↑ startupStandardHome/tbt: +49%
  • ↓ startupStandardHome/inp: -30%
  • ↑ startupStandardHome/fcp: +38%
  • ↑ startupStandardHome/lcp: +518%
  • ↓ startupStandardHome/cls: -72%
  • ↑ startupStandardHome/load: +13%
  • ↑ startupStandardHome/domInteractive: +48%
  • ↑ startupStandardHome/backgroundConnect: +15%
  • ↓ startupStandardHome/firstReactRender: -98%
  • ↓ startupStandardHome/initialActions: -50%
  • ↑ startupStandardHome/loadScripts: +12%
  • ↑ startupStandardHome/fcp: +51%
  • ↑ startupStandardHome/lcp: +15%
User Journey Benchmarks · Samples: 5 · mock API 🔴 1
Benchmarkchrome-webpackfirefox-webpack
onboardingImportWallet
[Sentry log · main/release]
🟢 [CI log]🟡 [CI log]
🟡 total
onboardingNewWallet
[Sentry log · main/release]
🟢 [CI log]🔴 [CI log]
🔴 total

📈 Results compared to the previous 5 runs on main

  • ↑ onboardingImportWallet/confirmSrpToPwForm: +11%
  • ↑ onboardingImportWallet/pwFormToMetricsScreen: +16%
  • ↑ onboardingImportWallet/metricsToWalletReadyScreen: +11%
  • ↓ onboardingImportWallet/doneButtonToHomeScreen: -92%
  • ↓ onboardingImportWallet/openAccountMenuToAccountListLoaded: -74%
  • ↓ onboardingImportWallet/longTaskCount: -100%
  • ↓ onboardingImportWallet/longTaskTotalDuration: -100%
  • ↓ onboardingImportWallet/longTaskMaxDuration: -100%
  • ↓ onboardingImportWallet/tbt: -100%
  • ↓ onboardingImportWallet/total: -85%
  • ↑ onboardingNewWallet/srpButtonToPwForm: +21%
  • ↑ onboardingNewWallet/createPwToRecoveryScreen: +26%
  • ↑ onboardingNewWallet/skipBackupToMetricsScreen: +19%
  • ↓ onboardingNewWallet/doneButtonToAssetList: -70%
  • ↓ onboardingNewWallet/longTaskCount: -62%
  • ↓ onboardingNewWallet/longTaskTotalDuration: -73%
  • ↓ onboardingNewWallet/longTaskMaxDuration: -36%
  • ↓ onboardingNewWallet/tbt: -96%
  • ↓ onboardingNewWallet/total: -66%
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: -49%
  • ↓ dappPageLoad/firstPaint: -33%
  • ↓ dappPageLoad/firstContentfulPaint: -33%
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
Status Bundle Total Diff Change
✅ background 15.25 MiB -7.6 KiB -0.05%
🚨 ui 19.39 MiB +63.52 KiB +0.32%
✅ common 0 Bytes 0 Bytes 0.00%
✅ other 4.44 MiB -520 Bytes -0.01%
✅ content scripts 3.23 MiB -1.05 KiB -0.03%
✅ unzipped 79.72 MiB -174.23 KiB -0.21%
✅ zip 23.83 MiB -245.43 KiB -1.00%

@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Nov 5, 2026
@gauthierpetetin
gauthierpetetin added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit c19a81a Nov 5, 2026
259 of 261 checks passed
@gauthierpetetin
gauthierpetetin deleted the feat/telemetry-ms-since-last-ui-interaction branch November 5, 2026 20:47
@github-project-automation github-project-automation Bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Nov 5, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
@metamaskbot metamaskbot added the release-13.58.0 Issue or pull request that will be included in release 13.58.0 label Nov 16, 2026
@gauthierpetetin

Copy link
Copy Markdown
Contributor Author

No release label on PR. Adding release label release-13.58.0 on PR, as PR was added to branch 13.58.0 when release was cut.

This branch had an error being deployed

1 failed (outdated) and 1 inactive deployments
pr-comment — 1d66f4ee Deployed Nov 5, 2026 by gauthierpetetin via Publish prerelease / Publish prerelease #173048
segment-schema — 90a8c6fc Deployed Nov 2, 2026 by gauthierpetetin via propose #2318
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.58.0 Issue or pull request that will be included in release 13.58.0 size-L team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants