Skip to content

Add the ability to attach on hard crash only #1467

Closed

Description

@bruno-garcia

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.

Request came from Discord.

Activity

  1. Nohus commented on Sep 7, 2021

    @Nohus

    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.

  2. marandaneto commented on Sep 8, 2021

    @marandaneto
    Contributor

    @Nohus we intend to work on it and it's in our backlog, but it's not prioritized yet.

  3. adinauer commented on Apr 28, 2022

    @adinauer
    Member

    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.

  4. added this to the 6.0.0 milestone on May 11, 2022
  5. marandaneto commented on May 11, 2022

    @marandaneto
    Contributor

    @adinauer Should we move this issue to In progress and add to v6? or the hints improvements won't automatically fix this? Thanks.

  6. removed this from the 6.0.0 milestone on May 11, 2022
  7. self-assigned this
    on May 11, 2022
  8. adinauer commented on Dec 28, 2022

    @adinauer
    Member

    Closing as use case is supported by #2046

  9. Nohus commented on Dec 28, 2022

    @Nohus

    Closing as use case is supported by #2046

    🎉 Amazing. I just wish I knew it was possible since May. 😄

  10. adinauer commented on Dec 29, 2022

    @adinauer
    Member

    @Nohus sorry, forgot to update the issue after merging the PR(s). This test shows how you can add an attachment in beforeSend:

    options.setBeforeSend { event, hints ->
    assertEquals(listOf(fixture.attachment, fixture.attachment2), hints.attachments)
    hints.addAttachment(fixture.attachment3)
    event
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions