Skip to content

fix(browser): Keep the first element name captured for an interaction - #24272

Open
logaretm wants to merge 1 commit into
developfrom
awad/inp-element-name-first-write
Open

fix(browser): Keep the first element name captured for an interaction#24272
logaretm wants to merge 1 commit into
developfrom
awad/inp-element-name-first-write

Conversation

@logaretm

@logaretm logaretm commented Sep 9, 2026

Copy link
Copy Markdown
Member

I noticed this while writing tests for the soft navs in #24273 and this changes the logic to grab the first available name and doesn't overwrite it with other candidates. again this was all best effort from the get go, so this adjusts this a bit more.

This only reproduces on Chromium 151+. Older versions happen to round the follow-up events to a different millisecond, which is why nothing caught it so far.

In a follow up when 153 is released we can rely on targetSelector property to get us the element name reliably.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.81 kB - -
@sentry/browser - with treeshaking flags 27.12 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.01 kB - -
@sentry/browser (incl. Tracing) 50.21 kB +0.04% +20 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 50.23 kB +0.07% +31 B 🔺
@sentry/browser (incl. Tracing, Profiling) 53.2 kB +0.04% +16 B 🔺
@sentry/browser (incl. Tracing, Replay) 89.7 kB +0.03% +24 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 78.8 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 94.4 kB +0.03% +23 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 107.4 kB +0.02% +17 B 🔺
@sentry/browser (incl. Feedback) 46.3 kB - -
@sentry/browser (incl. sendFeedback) 33.87 kB - -
@sentry/browser (incl. FeedbackAsync) 38.99 kB - -
@sentry/browser (incl. Metrics) 29.84 kB - -
@sentry/browser (incl. Logs) 30.1 kB - -
@sentry/browser (incl. Metrics & Logs) 30.78 kB - -
@sentry/react 30.57 kB - -
@sentry/react (incl. Tracing) 52.54 kB +0.04% +20 B 🔺
@sentry/vue 36.07 kB - -
@sentry/vue (incl. Tracing) 52.45 kB +0.05% +24 B 🔺
@sentry/svelte 28.85 kB - -
CDN Bundle 30.56 kB - -
CDN Bundle (incl. Tracing) 50.7 kB +0.07% +32 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.83 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 52.66 kB +0.07% +32 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.53 kB - -
CDN Bundle (incl. Tracing, Replay) 88.24 kB +0.04% +34 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.2 kB +0.04% +29 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 94.27 kB +0.05% +41 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.28 kB +0.04% +29 B 🔺
CDN Bundle - uncompressed 90.47 kB - -
CDN Bundle (incl. Tracing) - uncompressed 151.38 kB +0.03% +31 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.04 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 157.35 kB +0.02% +31 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.45 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 270.95 kB +0.02% +31 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 276.9 kB +0.02% +31 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 284.65 kB +0.02% +31 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 290.59 kB +0.02% +31 B 🔺
@sentry/nextjs (client) 54.86 kB +0.04% +20 B 🔺
@sentry/sveltekit (client) 50.65 kB +0.05% +24 B 🔺
@sentry/core/server 36.99 kB - -
@sentry/core/browser 13.55 kB - -
@sentry/node 127.95 kB +0.02% +23 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.61 kB - -
@sentry/node - without tracing 88.73 kB +0.03% +21 B 🔺
@sentry/node - without channel injection 107.16 kB +0.02% +18 B 🔺
@sentry/aws-serverless 97.12 kB +0.03% +26 B 🔺
@sentry/cloudflare (withSentry) - minified 202.05 kB - -
@sentry/cloudflare (withSentry) 502.91 kB - -

View base workflow run

@logaretm
logaretm force-pushed the awad/inp-element-name-first-write branch from e5cf7e0 to f46520d Compare September 9, 2026 22:59
@logaretm
logaretm changed the base branch from awad/js-1019-soft-nav-web-vitals-spans to awad/bfcache-web-vitals September 9, 2026 22:59
@logaretm
logaretm force-pushed the awad/inp-element-name-first-write branch from f46520d to f1b239d Compare September 9, 2026 23:18
@logaretm
logaretm changed the base branch from awad/bfcache-web-vitals to develop September 9, 2026 23:18
@logaretm
logaretm added this pull request to stack #24274 September 9, 2026 23:18
The INP element-name cache is keyed by the rounded event timestamp and every event of one
interaction shares that timestamp, so the last write won. When a click handler swaps out the
element under the cursor, the browser then fires `pointerover`/`mouseover` for the new
element carrying that same timestamp, and those overwrote the cached name. An INP span for a
click that navigated away was named after the post-mutation DOM rather than the element that
was clicked.

The earliest name in the sequence is the one that describes the element actually interacted
with, so it wins. Names that describe nothing are not cached at all: not every event in a
sequence has a describable target, and one that doesn't would otherwise claim the timestamp
and leave the span named `<unknown>`.
@logaretm
logaretm force-pushed the awad/inp-element-name-first-write branch from f1b239d to 5e012d5 Compare September 10, 2026 03:29
@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5e012d5. Configure here.

@logaretm
logaretm marked this pull request as ready for review September 10, 2026 05:04
@logaretm
logaretm requested a review from a team as a code owner September 10, 2026 05:04
@logaretm
logaretm requested review from Lms24 and msonnb and removed request for a team September 10, 2026 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants