-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[firebase_crashlytics] runtime exceptions #1803
[firebase_crashlytics] runtime exceptions #1803
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
cd78021 to
c6a5aa0
Compare
| final dynamic result = await channel | ||
| .invokeMethod<dynamic>('Crashlytics#onError', <String, dynamic>{ | ||
| 'exception': "${exception.toString()}", | ||
| 'context': 'onRuntimeException', |
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.
I am not sure what to send here, because we do not have ErrorDescription.
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.
I think it's fine to just leave it out if there's nothing to say
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.
Ok, I double checked: The native method signatures the context gets send to are:
- (void)recordCustomExceptionName:(NSString *)name reason:(nullable NSString *)reason frameArray:(CLS_GENERIC_NSARRAY(CLSStackFrame *) *)frameArray; on iOS. In the end the context gets set on the reason parameter, which is nullable, so ✅.
On Android it looks like it does no get used at all, so ✅.
Will remove then.
| } | ||
| } | ||
|
|
||
| Future<void> onRuntimeException(dynamic exception, dynamic stack) async { |
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.
Naming is hard. I guess there are better names for this method?
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.
Thanks for the PR! We should land #1799 before this one. (Edit: Done!)
I think I'd like to rename onError to recordError to match other platforms, which will be a breaking change. This is a good opportunity to revisit the method signature as well.
It sounds like we need to support either a FlutterErrorDetails or an arbitrary error and stack, I'm debating whether to try to shoehorn them onto one method, or split it into two methods (recordFlutterError and recordError).
There's a bit of code duplication here, I think we should try to get more code re-use
| final dynamic result = await channel | ||
| .invokeMethod<dynamic>('Crashlytics#onError', <String, dynamic>{ | ||
| 'exception': "${exception.toString()}", | ||
| 'context': 'onRuntimeException', |
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.
I think it's fine to just leave it out if there's nothing to say
|
I signed it! |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
41ec823 to
a778d89
Compare
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
bb496fb to
4180e59
Compare
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Sure. Let me know if you would like to keep the 2 methods or funnel all through one.
I would start working on that, as soon as the API (one method vs two methods) decision is done. |
|
We've made a (tentative) decision to go with two methods: Example of usage: Let me know if you have any feedback, and if it looks good, I'd appreciate your help updating the PR. This is a breaking change, and we'll be making some other breaking changes at the same time, but I can handle that part. |
4180e59 to
845d000
Compare
|
@collinjackson I updated the PR with the new API and refactored the duplicated code. Let me know what you think. Before I started I rebased to the latest |
| 'keys': _prepareKeys(), | ||
| }); | ||
| } | ||
| /// Submits non-fatal crash report to Firebase Crashlytics. |
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.
I think we might work on this doc comment.
Don't worry about these failures, they're affecting master as well https://cirrus-ci.com/task/4801326419017728 |
| Crashlytics.instance.enableInDevMode = true; | ||
|
|
||
| // Pass all uncaught errors to Crashlytics. | ||
| FlutterError.onError = (FlutterErrorDetails details) { |
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.
Might be simpler here to just say FlutterError.onError = Crashlytics.instance.recordFlutterError;
|
|
||
| runZoned<Future<void>>(() async { | ||
| runApp(MyApp()); | ||
| }, onError: (dynamic error, dynamic stack) async { |
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.
Might be simpler here to just say onError: Crashlytics.instance.recordError
packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart
Outdated
Show resolved
Hide resolved
packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart
Outdated
Show resolved
Hide resolved
packages/firebase_crashlytics/lib/src/firebase_crashlytics.dart
Outdated
Show resolved
Hide resolved
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
Co-Authored-By: Collin Jackson <[email protected]>
8118c88 to
20480ba
Compare
|
Looks good. Thanks for the contribution. |
* update AUTHORS file * add new method recordError * rename onError to recordFlutterError Co-Authored-By: Collin Jackson <[email protected]>
* update AUTHORS file * add new method recordError * rename onError to recordFlutterError Co-Authored-By: Collin Jackson <[email protected]>
Description
This PR adds support to send non-
FlutterErrorDetailserrors to Crashlytics that have not been caught by theFlutter.onErrorhandler.When e.g. a exception is thrown in a
Future, then the error handler does not work and the crash will never be reported. By usingrunZonedand using itsonErrorhandler it is possible to catch those, but the current plugin only supports sendingFlutterErrorDetailserrors. I updated the example to make this point more clear.Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?