Skip to content

Commit b033a3c

Browse files
onurtemizkanlizokmLuca Forstner
authored
Add docs for JavaScript HttpClient Integration. (#6022)
Co-authored-by: Liza Mock <[email protected]> Co-authored-by: Luca Forstner <[email protected]>
1 parent 03f4e9f commit b033a3c

File tree

2 files changed

+83
-1
lines changed
  • src
    • platform-includes/configuration/http-client
    • platforms/javascript/common/configuration/integrations

2 files changed

+83
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
```javascript {tabTitle: JavaScript}
2+
import * as Sentry from "@sentry/browser";
3+
import { HttpClient as HttpClientIntegration } from "@sentry/integrations";
4+
5+
Sentry.init({
6+
dsn: "___PUBLIC_DSN___",
7+
integrations: [
8+
new HttpClientIntegration({
9+
// This array can contain tuples of `[begin, end]` (both inclusive),
10+
// single status codes, or a combination of both.
11+
// default: [[500, 599]]
12+
failedRequestStatusCodes: [[500, 505], 507],
13+
14+
// This array can contain Regexes, strings, or a combination of both.
15+
// default: [/.*/]
16+
failedRequestTargets: [
17+
"http://example.com/api/test",
18+
/(staging\.)?mypage\.com/,
19+
],
20+
}),
21+
],
22+
23+
// This option is required for capturing headers and cookies.
24+
sendDefaultPii: true,
25+
});
26+
```
27+
28+
```javascript {tabTitle: CDN}
29+
<script
30+
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.min.js"
31+
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.min.js', 'sha384-base64') }}"
32+
crossorigin="anonymous"
33+
></script>
34+
35+
<script
36+
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/httpclient.min.js"
37+
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'httpclient.min.js', 'sha384-base64') }}"
38+
crossorigin="anonymous"
39+
></script>
40+
41+
Sentry.init({
42+
dsn: "___PUBLIC_DSN___",
43+
integrations: [
44+
new HttpClientIntegration({
45+
// This array can contain tuples of `[begin, end]` (both inclusive),
46+
// single status codes, or a combination of both.
47+
// default: [[500, 599]]
48+
failedRequestStatusCodes: [[500, 505], 507],
49+
50+
// This array can contain Regexes, strings, or a combination of both.
51+
// default: [/.*/]
52+
failedRequestTargets: [
53+
"http://example.com/api/test",
54+
/(staging\.)?mypage\.com/,
55+
],
56+
}),
57+
],
58+
59+
// This option is required for capturing headers and cookies.
60+
sendDefaultPii: true,
61+
});
62+
```

src/platforms/javascript/common/configuration/integrations/plugin.mdx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Pluggable Integrations
3-
description: "Learn more about pluggable integrations ExtraErrorData, CaptureConsole, Debug, Offline, RewriteFrames, and ReportingObserver, which are snippets of code that augment functionality for specific applications and/or frameworks."
3+
description: "Learn more about pluggable integrations ExtraErrorData, CaptureConsole, Debug, HttpClient, Offline, RewriteFrames, and ReportingObserver, which are snippets of code that augment functionality for specific applications and/or frameworks."
44
redirect_from:
55
- /platforms/javascript/integrations/plugin/
66
- /platforms/javascript/pluggable-integrations/
@@ -50,6 +50,26 @@ Available options:
5050

5151
<PlatformContent includePath="configuration/debug" />
5252

53+
### HttpClient
54+
55+
_(New in version 7.30.0)_
56+
57+
_Import name: `Sentry.Integrations.HttpClient`_
58+
59+
This integration captures errors on failed requests from Fetch and XHR and attaches request and response information.
60+
61+
By default, error events will not contain header and cookie data. You can change this behavior by setting the `sendDefaultPii` option to `true`.
62+
63+
Available options:
64+
65+
<PlatformContent includePath="configuration/http-client" />
66+
67+
<Alert level="warning" title="Note">
68+
69+
Due to the limitations of both the Fetch and XHR API, the cookie and header collection for both requests and responses is based on best effort. Certain headers may be missing in the event created by the integration.
70+
71+
</Alert>
72+
5373
<PlatformSection notSupported={["javascript.electron"]}>
5474

5575
### Offline

0 commit comments

Comments
 (0)