Pass missing captureFailedRequests param to FailedRequestInterceptor#2744
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2744 +/- ##
==========================================
+ Coverage 88.96% 94.55% +5.59%
==========================================
Files 263 9 -254
Lines 8925 202 -8723
==========================================
- Hits 7940 191 -7749
+ Misses 985 11 -974 ☔ View full report in Codecov by Sentry. |
|
Should I add the changelog entry like the failing job suggests? |
|
Hi @Maatteogekko, Yes, please, add a changelog entry. |
There was a problem hiding this comment.
Hey @Maatteogekko ! Thank you for contributing!
Code looks good, I took the liberty to write a test locally which you could just paste in addition to syncing with main. After that we can merge.
- In
sentry_dio_extension.dartplease also pass thehub:
interceptors.insert(
0,
FailedRequestInterceptor(
hub: hub,
failedRequestStatusCodes: failedRequestStatusCodes,
failedRequestTargets: failedRequestTargets,
captureFailedRequests: captureFailedRequests,
),
);- In
sentry_dio_extension.testreplace theaddSentry adds $FailedRequestInterceptor if override truewith the following:
test('addSentry adds $FailedRequestInterceptor if override true', () {
final dio = fixture.getSut();
fixture.hub.options.captureFailedRequests = false;
dio.addSentry(hub: fixture.hub, captureFailedRequests: true);
expect(
dio.interceptors.whereType<FailedRequestInterceptor>().length,
1,
);
final interceptor = dio.interceptors.whereType<FailedRequestInterceptor>().first;
final requestOptions = RequestOptions(path: 'https://example.com');
final error = DioError(
requestOptions: requestOptions,
response: Response(statusCode: 500, requestOptions: requestOptions),
);
interceptor.onError(error, fixture.errorInterceptorHandler);
expect(fixture.hub.captureExceptionCalls.length, 1);
});and fixure:
class Fixture {
final MockHub hub = MockHub();
final errorInterceptorHandler = MockedErrorInterceptorHandler();
Dio getSut() {
return Dio();
}
}That way we have covered your contribution by a test case. Thank you! 🙇♂️
|
Ok, looks like auto-merge is ignoring CI. 🤦♂️ @kahest I'm gonna check out main and fix if needed. |
📜 Description
dio.addSentry() captureFailedRequest param passed through to FailedRequestInterceptor.
💡 Motivation and Context
Fixes #2737.
💚 How did you test it?
I have run the fix in my app and it works as expected.
📝 Checklist
sendDefaultPiiis enabled