Content-Length: 312570 | pFad | https://github.com/getsentry/sentry-javascript/pull/16710

C3 feat(browser): Add CLS sources to span attributes by AbhiPrasad · Pull Request #16710 · getsentry/sentry-javascript · GitHub
Skip to content

feat(browser): Add CLS sources to span attributes #16710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

AbhiPrasad
Copy link
Member

resolves #16707

The session focused on enhancing CLS (Cumulative Layout Shift) spans by adding attributes detailing the elements that caused layout shifts.

  • In packages/browser-utils/src/metrics/cls.ts, the sendStandaloneClsSpan function was updated. It now iterates over LayoutShift entry sources and adds them as cls.source.N attributes to the span, converting DOM nodes to readable CSS selectors using htmlTreeAsString(). This aligns standalone CLS spans with the existing implementation for regular pageload spans.
  • Test expectations in dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/test.ts were updated to assert the presence of these new cls.source.N attributes on the captured CLS spans.
  • yarn.lock was updated to reflect changes in dependency resolutions, likely due to package installations during the session.

@AbhiPrasad AbhiPrasad requested review from bcoe and a team June 23, 2025 22:04
@AbhiPrasad AbhiPrasad self-assigned this Jun 23, 2025
@AbhiPrasad AbhiPrasad requested review from stephanie-anderson and andreiborza and removed request for a team June 23, 2025 22:04
@AbhiPrasad AbhiPrasad changed the title Add CLS sources to span attributes feat(browser): Add CLS sources to span attributes Jun 23, 2025
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.99 kB - -
@sentry/browser - with treeshaking flags 23.76 kB - -
@sentry/browser (incl. Tracing) 38.84 kB +0.12% +43 B 🔺
@sentry/browser (incl. Tracing, Replay) 76.98 kB +0.06% +46 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.07 kB +0.07% +43 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 81.74 kB +0.06% +45 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 93.83 kB +0.05% +42 B 🔺
@sentry/browser (incl. Feedback) 40.74 kB - -
@sentry/browser (incl. sendFeedback) 28.7 kB - -
@sentry/browser (incl. FeedbackAsync) 33.59 kB - -
@sentry/react 25.76 kB - -
@sentry/react (incl. Tracing) 40.84 kB +0.12% +45 B 🔺
@sentry/vue 28.36 kB - -
@sentry/vue (incl. Tracing) 40.7 kB +0.1% +38 B 🔺
@sentry/svelte 24.01 kB - -
CDN Bundle 25.5 kB - -
CDN Bundle (incl. Tracing) 38.92 kB +0.11% +39 B 🔺
CDN Bundle (incl. Tracing, Replay) 74.83 kB +0.06% +44 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 80.29 kB +0.05% +37 B 🔺
CDN Bundle - uncompressed 74.5 kB - -
CDN Bundle (incl. Tracing) - uncompressed 115.42 kB +0.08% +89 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 229.47 kB +0.04% +89 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 242.3 kB +0.04% +89 B 🔺
@sentry/nextjs (client) 42.47 kB +0.1% +39 B 🔺
@sentry/sveltekit (client) 39.33 kB +0.11% +40 B 🔺
@sentry/node 150.89 kB - -
@sentry/node - without tracing 98.64 kB +0.01% +2 B 🔺
@sentry/aws-serverless 124.4 kB - -

View base workflow run

Copy link
Member

@s1gr1d s1gr1d left a comment

Choose a reason for hiding this comment

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

Nice!

@andreiborza
Copy link
Member

Mhm, are we ok with that bundle-size increase?

@AbhiPrasad
Copy link
Member Author

I think we are.

When span streaming comes we'll drop attaching CLS as measurements in favour of only using standalone spans, so I think this is the right direction to go down.

@AbhiPrasad AbhiPrasad merged commit 4d8581a into develop Jun 24, 2025
168 checks passed
@AbhiPrasad AbhiPrasad deleted the cursor/add-cls-sources-to-span-attributes-a18f branch June 24, 2025 14:21
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.

feature: include CLS sources on ui.webvitals.cls span
4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/getsentry/sentry-javascript/pull/16710

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy