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
Copy file name to clipboardExpand all lines: includes/dart-integrations/dio.mdx
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,54 @@ await Sentry.init((options) {
67
67
});
68
68
```
69
69
70
+
### Failed Request Status Codes
71
+
72
+
You can customize which status codes should be considered as failed requests by setting the `failedRequestStatusCodes` option when calling `addSentry()`.
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 as 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