Skip to content

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Oct 14, 2025

Update: Removed browser functionality (see below for reasons)

As a follow-up of an incident (quite a while ago, but this unfortunately slipped through), SDKs were asked to send a user-agent Http header to determine by just looking at incoming request headers which SDK the request is coming from. See develop specification.

This PR makes the following changes to sending user agent HTTP headers with envelope requests made by the transport:

  • Send user-agent in all server-runtime SDKs
  • Extract the headers option from individual transport options to BaseTransportOptions. This allows us to type-safely add the user agent header to the SDKs transport options which is the easiest way to pass a header to the transport without having to modify or extend any of the existing transport APIs. I checked and every transport implementation we currently export exposed a headers option anyway, so this just unifies it. Given this is an optional property, custom transport implementations extending BaseTransportOptions won't break either. The problem here is only that they might not actually support this option which all things considered I think is fine. If reviewers have different opinions, I'm happy to revisit this.
  • Unit and integration/e2e tests for node and cloudflare

This PR makes no change to the sdk envelope header which carries the same (more detailed) information (but in the request body)

Why not in Browser SDKs?

  1. Relay infers the user's browser information based on user-agent, so we cannot set a custom user agent name that overwrites it.
  2. We also cannot add a custom header (something like x-sentry-user-agent) because then the SDK would send a non-standard header which could block all requests to Sentry, depending on the CORS setup of the application the SDK is added to. This is especially relvant for users who use tunnel and forward the SDK requests to a proxy server.

ref: https://linear.app/getsentry/project/chore-alignextend-user-agents-795bfddfa217/overview

@Lms24 Lms24 self-assigned this Oct 14, 2025
@Lms24 Lms24 requested a review from AbhiPrasad October 14, 2025 15:07
@Lms24 Lms24 changed the title feat(core): Send user-agent header with envelope requests feat(core): Send user agent header with envelope requests Oct 14, 2025
@Lms24 Lms24 requested review from a team, chargome and cleptric and removed request for a team October 14, 2025 15:12
@Lms24 Lms24 force-pushed the lms/feat-core-send-user-agent-envelope-requests branch from 0c5731c to 8b51d2e Compare October 14, 2025 15:17
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

github-actions bot commented Oct 14, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.64 kB - -
@sentry/browser - with treeshaking flags 23.14 kB - -
@sentry/browser (incl. Tracing) 40.85 kB - -
@sentry/browser (incl. Tracing, Replay) 79.21 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 68.92 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 83.91 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.08 kB - -
@sentry/browser (incl. Feedback) 41.33 kB - -
@sentry/browser (incl. sendFeedback) 29.3 kB - -
@sentry/browser (incl. FeedbackAsync) 34.26 kB - -
@sentry/react 26.35 kB - -
@sentry/react (incl. Tracing) 42.84 kB - -
@sentry/vue 29.13 kB - -
@sentry/vue (incl. Tracing) 42.64 kB - -
@sentry/svelte 24.66 kB - -
CDN Bundle 26.94 kB - -
CDN Bundle (incl. Tracing) 41.53 kB - -
CDN Bundle (incl. Tracing, Replay) 77.8 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.28 kB - -
CDN Bundle - uncompressed 78.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 123.07 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 238.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251 kB - -
@sentry/nextjs (client) 44.9 kB - -
@sentry/sveltekit (client) 41.27 kB - -
@sentry/node-core 50.84 kB +0.13% +61 B 🔺
@sentry/node 154.47 kB +0.05% +63 B 🔺
@sentry/node - without tracing 92.71 kB +0.07% +59 B 🔺
@sentry/aws-serverless 106.41 kB +0.07% +65 B 🔺

View base workflow run

Copy link
Contributor

github-actions bot commented Oct 14, 2025

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,118 - 9,065 +1%
GET With Sentry 1,444 16% 1,339 +8%
GET With Sentry (error only) 6,241 68% 6,068 +3%
POST Baseline 1,222 - 1,170 +4%
POST With Sentry 524 43% 481 +9%
POST With Sentry (error only) 1,085 89% 1,029 +5%
MYSQL Baseline 3,374 - 3,244 +4%
MYSQL With Sentry 447 13% 471 -5%
MYSQL With Sentry (error only) 2,780 82% 2,657 +5%

View base workflow run

@Lms24 Lms24 changed the title feat(core): Send user agent header with envelope requests feat(core): Send user agent header with envelope requests in server SDKs Oct 15, 2025
@Lms24 Lms24 changed the title feat(core): Send user agent header with envelope requests in server SDKs feat(core): Send user-agent header with envelope requests in server SDKs Oct 15, 2025
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.

1 participant