Skip to content

Commit e2d4936

Browse files
authored
Merge branch 'main' into main
2 parents c7fe9bf + c32f612 commit e2d4936

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
### Fixes
2222

23+
* Add request instead of response data to `SentryRequest` in `DioEventProcessor` [#933](https://github.com/getsentry/sentry-dart/pull/933)
2324
* Context Escape with ScopeCallback ([#925](https://github.com/getsentry/sentry-dart/pull/925))
2425

2526
## 6.6.2

dio/lib/src/dio_event_processor.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:sentry/sentry.dart';
66
import 'package:sentry/src/sentry_exception_factory.dart';
77

88
/// This is an [EventProcessor], which improves crash reports of [DioError]s.
9-
/// It adds information about [DioError.response] if present and also about
9+
/// It adds information about [DioError.requestOptions] if present and also about
1010
/// the inner exceptions.
1111
class DioEventProcessor implements EventProcessor {
1212
// Because of obfuscation, we need to dynamically get the name
@@ -120,12 +120,11 @@ class DioEventProcessor implements EventProcessor {
120120
cookies: _options.sendDefaultPii
121121
? options.headers['Cookie']?.toString()
122122
: null,
123-
data: _getRequestData(dioError.response?.data),
123+
data: _getRequestData(dioError.requestOptions.data),
124124
);
125125
}
126126

127127
/// Returns the request data, if possible according to the users settings.
128-
/// Type checks are based on DIOs [ResponseType].
129128
Object? _getRequestData(dynamic data) {
130129
if (!_options.sendDefaultPii) {
131130
return null;

dio/test/dio_event_processor_test.dart

+7-4
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,22 @@ void main() {
4242
test('$DioEventProcessor adds request', () {
4343
final sut = fixture.getSut(sendDefaultPii: true);
4444

45+
final request = requestOptions.copyWith(
46+
method: 'POST',
47+
data: 'foobar',
48+
);
4549
final event = SentryEvent(
4650
throwable: DioError(
47-
requestOptions: requestOptions,
51+
requestOptions: request,
4852
response: Response<dynamic>(
49-
requestOptions: requestOptions,
50-
data: 'foobar',
53+
requestOptions: request,
5154
),
5255
),
5356
);
5457
final processedEvent = sut.apply(event) as SentryEvent;
5558

5659
expect(processedEvent.throwable, event.throwable);
57-
expect(processedEvent.request?.method, 'GET');
60+
expect(processedEvent.request?.method, 'POST');
5861
expect(processedEvent.request?.queryString, 'foo=bar');
5962
expect(processedEvent.request?.headers, <String, String>{
6063
'foo': 'bar',

0 commit comments

Comments
 (0)