sentry-java
sentry-java copied to clipboard
Add the ability to attach on hard crash only
Users have the use case of attaching files only when a hard crash happens (i.e: UncaughtExceptionHandler).
For example: User throws ParseException which has the path to a file that failed parsing.
Currently there's no way to hook into processing that exception in a way that we can add that file as an attachment.
Is there any update on this? I still need it, but of course can look into alternative solutions if it's not going to be implemented. I am just not sure if I should wait or not.
@Nohus we intend to work on it and it's in our backlog, but it's not prioritized yet.
Suggestion for implementation that would have to be discussed with Client Infra TSC as this might be something all SDKs should do. If so the SDKs should do it in a similar manner.
Add a new method to EventProcessor that allows people to extract attachments from an exception.
public List<Attachment> extractAttachments(SentryEvent event)
Default implementation could be added to return an empty list.
@adinauer Should we move this issue to In progress and add to v6? or the hints improvements won't automatically fix this? Thanks.
Closing as use case is supported by #2046
Closing as use case is supported by #2046
:tada: Amazing. I just wish I knew it was possible since May. :smile:
@Nohus sorry, forgot to update the issue after merging the PR(s). This test shows how you can add an attachment in beforeSend:
https://github.com/getsentry/sentry-java/blob/b3704c88d4b10a7c1cfbd922ba75811e484b6b8a/sentry/src/test/java/io/sentry/SentryClientTest.kt#L1724-L1728