-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
feat(core)!: Update requestDataIntegration
handling
#14806
Conversation
size-limit report 📦
|
Fixes #14847 After some digging, I figured out that the `req.user` handling on express is not working anymore, because apparently express does not mutate the actual http `request` object, but clones/forkes it (??) somehow. So since we now set the request in the SentryHttpInstrumentation generally, it would not pick up express-specific things anymore. IMHO this is not great and we do not want this anymore in v9 anyhow, but it was the behavior before. This PR fixes this by setting the express request again on the isolation scope in an express middleware, which is registered by `Sentry.setupExpressErrorHandler(app)`. Note that we plan to change this behavior here: #14806 but I figured it still makes sense to fix this on develop first, so we have a proper history/tests for this. I will backport this to v8 too. Then, in PR #14806 I will remove the middleware again.
Instead of picking this from the plain `request` in `requestDartaIntegration`. Extracted from #14806
Instead of picking this from the plain `request` in `requestDartaIntegration`. Extracted from #14806
This was an express-specific, rather undocumented behavior, and also conflicted with our privacy-by-default stance. Starting in v9, you'll need to manually call `Sentry.setUser()` e.g. in a middleware to set the user on Sentry events. Docs for this are already pending: getsentry/sentry-docs#12224 Extracted this out of #14806
4f9f9f7
to
72f6880
Compare
requestDataIntegration
handlingrequestDataIntegration
handling
} | ||
}); | ||
} catch { | ||
// just return the empty headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we used to log a debug message here, no we just continue.
} | ||
}); | ||
} catch { | ||
// just return the empty headers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we used to log a debug message here, no we just continue.
const protocol = request.protocol || (request.socket?.encrypted ? 'https' : 'http'); | ||
const url = request.url || ''; | ||
|
||
const absoluteUrl = getAbsoluteUrl({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously, we always built this from the host. However, the host could also be <no host>
as fallback, leading to (theoretically) urls like: http://<no host>/
which is weird. Now, we simply have no URL in such a case.
packages/core/src/utils/request.ts
Outdated
protocol, | ||
host, | ||
}: { url?: string; protocol: string; host?: string }): string | undefined { | ||
if (url && url.startsWith('http')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously, we checked here url.startsWith(protocol)
. Which should be generally fine, but there could be an edge case where you have url: http://example.com
and protocol: https
which would result in https://http://example.com
which seems bad.
72f6880
to
fd5d6ab
Compare
@@ -60,7 +59,6 @@ export interface SdkProcessingMetadata { | |||
requestSession?: { | |||
status: 'ok' | 'errored' | 'crashed'; | |||
}; | |||
request?: PolymorphicRequest; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bless
fd5d6ab
to
3d17c65
Compare
3d17c65
to
95fb966
Compare
This PR cleans up the behavior of
requestDataIntegration
. For this, there are a bunch of parts that come together:addNormalizedRequestDataToEvent
export, this does not really do much, you can just directly add the data to the event.RequestDataIntegrationOptions
typerequest
on SDK processing metadata, now only relying onnormalizedRequest
utils-hoist
. Now, all the code related directly to the requestDataIntegration is in that file, while the more general utils are in core/src/utils/request.tsCloses #14297