@@ -70,7 +70,12 @@ void main() {
70
70
expect (eventCall.contexts.response, isNull);
71
71
});
72
72
73
- test ('event not reported if disabled' , () async {
73
+ test (
74
+ 'exception does not gets reported if client throws but override disables capture' ,
75
+ () async {
76
+ fixture._hub.options.captureFailedRequests = true ;
77
+ fixture._hub.options.sendDefaultPii = true ;
78
+
74
79
final sut = fixture.getSut (
75
80
client: createThrowingClient (),
76
81
captureFailedRequests: false ,
@@ -84,10 +89,42 @@ void main() {
84
89
expect (fixture.transport.calls, 0 );
85
90
});
86
91
92
+ test ('event not reported if disabled' , () async {
93
+ fixture._hub.options.captureFailedRequests = false ;
94
+
95
+ final sut = fixture.getSut (
96
+ client: createThrowingClient (),
97
+ );
98
+
99
+ await expectLater (
100
+ () async => await sut.get (requestUri, headers: {'Cookie' : 'foo=bar' }),
101
+ throwsException,
102
+ );
103
+
104
+ expect (fixture.transport.calls, 0 );
105
+ });
106
+
107
+ test ('event reported if disabled but overridden' , () async {
108
+ fixture._hub.options.captureFailedRequests = false ;
109
+
110
+ final sut = fixture.getSut (
111
+ client: createThrowingClient (),
112
+ captureFailedRequests: true ,
113
+ );
114
+
115
+ await expectLater (
116
+ () async => await sut.get (requestUri, headers: {'Cookie' : 'foo=bar' }),
117
+ throwsException,
118
+ );
119
+
120
+ expect (fixture.transport.calls, 1 );
121
+ });
122
+
87
123
test ('event not reported if not within the targets' , () async {
124
+ fixture._hub.options.captureFailedRequests = true ;
125
+
88
126
final sut = fixture.getSut (
89
127
client: fixture.getClient (statusCode: 500 ),
90
- captureFailedRequests: true ,
91
128
failedRequestTargets: const ["myapi.com" ]);
92
129
93
130
final response = await sut.get (requestUri);
@@ -335,17 +372,16 @@ class Fixture {
335
372
List <SentryStatusCode > failedRequestStatusCodes = const [
336
373
SentryStatusCode .defaultRange ()
337
374
],
338
- bool captureFailedRequests = true ,
339
375
List <String > failedRequestTargets = const [".*" ],
376
+ bool ? captureFailedRequests,
340
377
}) {
341
378
final mc = client ?? getClient ();
342
- _hub.options.captureFailedRequests = captureFailedRequests;
343
379
return FailedRequestClient (
344
- client: mc,
345
- hub: _hub,
346
- failedRequestStatusCodes: failedRequestStatusCodes,
347
- failedRequestTargets: failedRequestTargets,
348
- );
380
+ client: mc,
381
+ hub: _hub,
382
+ failedRequestStatusCodes: failedRequestStatusCodes,
383
+ failedRequestTargets: failedRequestTargets,
384
+ captureFailedRequests : captureFailedRequests );
349
385
}
350
386
351
387
MockClient getClient (
0 commit comments