You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(dart): Update dio and http integrations to include failedRequestTargets option (#15300)
<!-- Use this checklist to make sure your PR is ready for merge. You may
delete any sections you don't need. -->
## DESCRIBE YOUR PR
Closes#15264
## IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs
to go live.
- [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE -->
- [ ] Other deadline: <!-- ENTER DATE HERE -->
- [x] None: Not urgent, can wait up to 1 week+
## SLA
- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!
## PRE-MERGE CHECKLIST
*Make sure you've checked the following before merging your changes:*
- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)
## EXTRA RESOURCES
- [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
---------
Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>
By default, `failedRequestStatusCodes` is set to `[SentryStatusCode.range(500, 599)]`, which captures server errors (status codes 500-599).
90
+
91
+
### Failed Request Targets
92
+
93
+
To control which URLs should have failed requests captured, use the `failedRequestTargets` option. This is useful when you only want to capture errors from specific APIs or domains.
94
+
95
+
The SDK will only capture HTTP client errors if the request URL matches one of the provided targets. Targets can be:
96
+
97
+
- Strings that appear anywhere in the URL
98
+
- Regular expression patterns
99
+
100
+
```dart
101
+
import 'package:sentry_dio/sentry_dio.dart';
102
+
103
+
final dio = Dio();
104
+
105
+
// Capture failed requests only from specific domains
106
+
dio.addSentry(
107
+
failedRequestTargets: [
108
+
'api.example.com', // Matches any URL containing this string
109
+
'myapi.com', // Another domain to track
110
+
],
111
+
);
112
+
```
113
+
114
+
**Default Behavior:**
115
+
116
+
By default, `failedRequestTargets` is set to `['.*']`, which matches all URLs. This means all failed requests are captured (subject to `failedRequestStatusCodes`).
117
+
70
118
## Tracing for HTTP Requests
71
119
72
120
The Dio integration also provides insight into tracing for your HTTP requests done with Dio.
Copy file name to clipboardExpand all lines: includes/dart-integrations/http-integration.mdx
+61Lines changed: 61 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,67 @@ try {
115
115
}
116
116
```
117
117
118
+
### Failed Request Status Codes
119
+
120
+
You can customize which status codes should be considered failed requests by setting the `failedRequestStatusCodes` option when calling `SentryHttpClient()`.
By default, `failedRequestStatusCodes` is set to `[SentryStatusCode.range(500, 599)]`, which captures server errors (status codes 500-599).
144
+
145
+
### Failed Request Targets
146
+
147
+
To control which URLs should have failed requests captured, use the `failedRequestTargets` option. This is useful when you only want to capture errors from specific APIs or domains.
148
+
149
+
The SDK will only capture HTTP client errors if the request URL matches one of the provided targets. Targets can be:
150
+
151
+
- Strings that appear anywhere in the URL
152
+
- Regular expression patterns
153
+
154
+
```dart
155
+
import 'package:sentry/sentry.dart';
156
+
157
+
// Capture failed requests only from specific domains
158
+
var client = SentryHttpClient(
159
+
failedRequestTargets: [
160
+
'api.example.com', // Matches any URL containing this string
161
+
'myapi.com', // Another domain to track
162
+
],
163
+
);
164
+
165
+
try {
166
+
var uriResponse = await client.post('https://api.example.com/whatsit/create',
By default, `failedRequestTargets` is set to `['.*']`, which matches all URLs. This means all failed requests are captured (subject to `failedRequestStatusCodes`).
0 commit comments