HttpClient
This integration captures errors on failed requests from Fetch and XHR and attaches request and response information.
By default, error events don't contain header or cookie data. You can change this behavior by setting sendDefaultPii: true
in your root Sentry.init({})
config.
This integration requires you to install @sentry/integrations
next to your main SDK package.
import * as Sentry from "@sentry/browser";
import { HttpClient } from "@sentry/integrations";
Sentry.init({
dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
integrations: [new HttpClient()],
// This option is required for capturing headers and cookies.
sendDefaultPii: true,
});
Note
Due to the limitations of the Fetch and XHR API, the cookie and header collection for requests and responses is based on best effort. This means that certain headers may be missing in the event created by the integration.
Options
failedRequestStatusCodes
Type: (number|[number, number])[]
This array can contain tuples of [begin, end]
(both inclusive),
single status codes, or a combination of the two.
Default: [[500, 599]]
failedRequestTargets
Type: (string|RegExp)[]
An array of request targets that should be considered, for example ['http://example.com/api/test']
would interpret any request to this URL as a failure. This array can contain Regexes, strings, or a combination of the two.
Default: [/.*/]
sendDefaultPii
Type: boolean
This option is required for capturing headers and cookies.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
- Package:
- npm:@sentry/nextjs
- Version:
- 7.83.0
- Repository:
- https://github.com/getsentry/sentry-javascript