Repository navigation
feat(browser): Make span error handlers, HTTP timings and background tab detection tree-shakeable - #26143
feat(browser): Make span error handlers, HTTP timings and background tab detection tree-shakeable#26143sentry-junior[bot] wants to merge 1 commit into
Conversation
…tab detection tree-shakeable Bundlers can define `__SENTRY_EXCLUDE_SPAN_ERROR_INSTRUMENTATION__`, `__SENTRY_EXCLUDE_HTTP_TIMINGS__` or `__SENTRY_EXCLUDE_BACKGROUND_TAB_DETECTION__` as `true` to drop the matching browserTracingIntegration code. Defaults are unchanged. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bb57783. Configure here.
size-limit report 📦Compared: 5b2dab5 (PR test merge using develop at c054e7a) Against: c054e7a (develop) · base run #65086 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 1 not successful, 24 successful. See the run.
Successful checks
|
|
Similar to my comment in #26144, but unlike that PR I think we can solve this another way since we were already thinking about doing this pre-v11. The problem with flags means:
So for this PR here, I believe we can split the Feel free to talk to us more about this if there are strong opinions about this. |

Why: Three smaller default-on
browserTracingIntegration()features are gated only at runtime, so they always ship. This adds one build-time flag for each, following the__SENTRY_EXCLUDE_REPLAY_WORKER__/__RRWEB_EXCLUDE_*__pattern:__SENTRY_EXCLUDE_SPAN_ERROR_INSTRUMENTATION__skipsregisterSpanErrorInstrumentation(). Global errors then no longer mark the active root spaninternal_error.__SENTRY_EXCLUDE_HTTP_TIMINGS__skipsaddHTTPTimings, the same asenableHTTPTimings: false.__SENTRY_EXCLUDE_BACKGROUND_TAB_DETECTION__skipsregisterBackgroundTabDetection(), the same asmarkBackgroundSpan: false.If a flag isn't defined, nothing changes, and no public options change. The guards sit at the call sites because an early return inside the callee doesn't let esbuild drop the body. This is one of a set of PRs (#26134, #26137, #26141) that use the same
__SENTRY_EXCLUDE_*__mechanism. This PR touchesrequest.tsandbrowserTracingIntegration.tsnext to lines those PRs change. I checked that all four merge into develop in sequence without conflicts.Measured with a tracing-only setup (
BrowserClient+browserTracingIntegration(), esbuild 0.27, minified ESM,__SENTRY_DEBUG__: false):Compared with flags unset, the savings are 769 / 228, 714 / 210 and 433 / 65 (raw / br). All three together save 1,916 B raw / 540 B br, or 1,544 / 437 compared with develop. Without any flag set, the guards cost 372 B raw / 103 B br. Locally, size-limit
@sentry/browser (incl. Tracing)went from 52,727 B to 52,836 B gzip.Unsure about: The background tab flag barely pays for itself: it saves 65 B br, and its guard costs about 35 B for everyone. I'm happy to drop it. The same bundler-plugin and docs follow-up as in the other PRs applies here.
Closes #26139
via @BYK.
--
View Session in Sentry