Issue
My JavaScript error events show which request failed, but they do not include the request body or response body. I want that payload data on the event.
Applies To
All SaaS Customers and Self-Hosted Users
Browser JavaScript SDKs (
httpClientIntegration)Node.js and other server JavaScript SDKs (
httpIntegration)Error Monitoring
Resolution
Yes, in part. What you can capture depends on browser vs Node, and on whether you need full body content or only HTTP metadata.
Browser (failed Fetch / XHR)
Add
Sentry.httpClientIntegration()inSentry.init. Do not install a separate@sentry/integrationspackage on current SDK versions.To include headers and cookies on those events, set
dataCollection(or the deprecatedsendDefaultPii: true) inSentry.init.
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.httpClientIntegration()],
dataCollection: {
httpHeaders: true,
cookies: true,
},
});
httpClientIntegration captures failed client requests and attaches request/response information such as URL, method, status code, headers/cookies, and response body size. It does not attach the full request or response body content to the error event.
If you need browser request/response bodies in Session Replay, configure networkDetailAllowUrls in Replay. That is Replay network detail, not the error event payload.
Node.js (incoming server requests)
Incoming request bodies can be attached to events through the default httpIntegration. Control size with maxIncomingRequestBodySize (none, small, medium, or always). Default is medium. Bodies over 1 MB are never attached.
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
Sentry.httpIntegration({
maxIncomingRequestBodySize: "medium",
}),
],
});
dataCollection.httpBodies (SDK 10.57.0+)
From @sentry/* 10.57.0, use dataCollection.httpBodies to choose which body types to collect: incomingRequest, outgoingRequest, incomingResponse, and outgoingResponse. Omit the option to use the defaults for your platform. Set httpBodies: [] to disable body collection. See the dataCollection options.
This does not change the browser httpClientIntegration behavior above. That integration still does not put full body content on the error event.
Manual option
If you need specific body fields on an error, capture them yourself in beforeSend or with Sentry.setContext / attachments. Scrub secrets and PII before sending.
See the HttpClient integration, Node Http integration, and dataCollection options.
