Skip to content
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

Event delivery with an event with setUnhandled(true) should behave as an unhandled event delivery #1724

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

joshskeen
Copy link

@joshskeen joshskeen commented Jul 26, 2022

Goal

In the case where client.notify is called and the event is modified to be treated as unhandled:

client.notify(throwable, new OnErrorCallback() {
      @Override public boolean onError(@NonNull Event event) {
        event.setUnhandled(true);
       ...
      }
    });

we should cache the event, similar to how it is done for an unhandled exception. With an unhandled exception, the app's availability will cease - and if we are marking an event as unhandled, we are indicating this will be the case.

We use our own default exception handler which allows us to customize crash handling and send crashes to distinct destinations. Using the bugsnag client with client.notify with setUnhandled = true as part of that handler and being able to rely upon similar behavior as the bugsnag default exception handler rather than forward to the bugsnag exception handler would simplify the structure of our code, and remove the hacky bugsnag workarounds we've had to implement.

Design

Change delivery logic to view events marked as unhandled to behave as a typical unhandled exception in bugsnag.

Changeset

Testing

…ly to ExceptionHandler.uncaughtException's delivery

In the case where client.notify is called and the event is modified to be treated as unhandled:
```java
client.notify(throwable, new OnErrorCallback() {
      @OverRide public boolean onError(@nonnull Event event) {
        event.setUnhandled(true);
       ...
      }
    });
```
we should cache the event, similar to how it is done for an unhandled exception. With an unhandled exception, the app's availability will cease - and if we are marking an event as unhandled, we are indicating this will be the case.
@pyricau
Copy link
Contributor

pyricau commented Jul 26, 2022

(note: by "we" here @mutexkid is referring to Square)

@yousif-bugsnag
Copy link
Contributor

Hey @mutexkid, thanks for the PR. Have you considered making use of the delivery config option? That should allow you to easily override this behaviour in your own Delivery class: https://docs.bugsnag.com/platforms/android/configuration-options/#delivery

@yousif-bugsnag yousif-bugsnag added the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Jul 27, 2022
@joshskeen
Copy link
Author

joshskeen commented Aug 5, 2022

Thanks for pointing this possibility out. With a custom Delivery option, it seems like we'd need 2 clients: 1 using the DefaultDelivery class instance (which we would typically want to use), and another initialized with a custom Delivery option for this case. I don't see a way of extending the DefaultDelivery class to handle only this case. Does that match what you would recommend?

If that is the case, while having 2 clients might be an option , it still seems like it would be more ideal if we were simply treating an event marked as unhandled as how unhandled events are typically treated by DeliveryDelegate, to prevent adding an additional client or a custom Delivery. Thoughts?

@pyricau
Copy link
Contributor

pyricau commented Aug 8, 2022

@yousif-bugsnag this points to a core design flaw in the Bugsnag Android SDK: it should be fairly straightforward to adopt it without the default automatic crash reporting, and still report crashes at crash times with a pipeline identical to the default. That's not possible today. As @mutexkid pointed out, Delivery is set at the client level. We're not looking to change the default delivery, we just want to make sure unhandled crashes are uploaded the way they are with the automatic bugsnag upload.

The best option here would be to actually force the bugsnag uncaught exception handler to only use public APIs of a Bugsnag client instead of relying on internal details like it's doing today. Then all the needed APIs would actually surface.

@luke-belton luke-belton removed the awaiting feedback Awaiting a response from a customer. Will be automatically closed after approximately 2 weeks. label Aug 9, 2022
@luke-belton
Copy link
Member

Hi @mutexkid, @pyricau - thanks for the additional feedback. We're discussing this internally to see what improvements we could make here to help with your use case and will get back to you with an update as soon as possible 👍

@luke-belton luke-belton added the needs discussion Requires internal analysis/discussion label Aug 9, 2022
@luke-belton
Copy link
Member

Hi - just a quick update on this. We've added an item to our roadmap to look at some options here, including whether we could allow you to 'opt-in' via your Bugsnag config to persisting events you mark as unhandled. I don't have an ETA for this work, but will make sure we keep you updated on this thread 👍

@luke-belton luke-belton added feature request Request for a new feature backlog We hope to fix this feature/bug in the future and removed needs discussion Requires internal analysis/discussion labels Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog We hope to fix this feature/bug in the future feature request Request for a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants