-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.dart
please also pass thehub
:
interceptors.insert(
0,
FailedRequestInterceptor(
hub: hub,
failedRequestStatusCodes: failedRequestStatusCodes,
failedRequestTargets: failedRequestTargets,
captureFailedRequests: captureFailedRequests,
),
);
- In
sentry_dio_extension.test
replace theaddSentry adds $FailedRequestInterceptor if override true
with 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! 🙇♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, if CI is successful we can merge.
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
sendDefaultPii
is enabled