Skip to content

Feature request: showReportDialog for uncaught exceptions #796

Description

@cldwalker

Hi,
The report dialogs look great and it would be great to display it with uncaught exceptions. I don't currently see a config option to allow this and haven't seen discussion of this in your forum or github. Keep up the great work!
Cheers

Activity

  1. benvinegar commented on Dec 14, 2016

    @benvinegar
    Contributor

    @cldwalker – using showReportDialog with uncaught exceptions is ... what it's for. Can you clarify?

  2. cldwalker commented on Dec 14, 2016

    @cldwalker
    Author

    Sure. The JS example shows an example of caught exception usage. It seems there isn't a way clien-tside for an uncaught exception to automatically trigger showReportDialog. I searched the forum but haven't seen anyone attempt to use it in that way. Perhaps I could override some internal sentry uncaughtException handler but that seems brittle from a usage and perhaps even a timing perspective (having the right eventid)

  3. benvinegar commented on Dec 16, 2016

    @benvinegar
    Contributor

    Technically it works for uncaught exceptions too. You could do the following:

    Raven.setDataCallback(function (data) {
      // means an error was triggered
      Raven.showReportDialog(); // uses last event id
    });
  4. friday commented on Jan 15, 2017

    @friday

    That doesn't seem to work @benvinegar:

    screen shot 2017-01-15 at 02 00 53

    Raven.setDataCallback() is triggered before the event id is created (which I'm assuming is happening on the server)

    By reading the source I figured out another way though.

    document.addEventListener('ravenSuccess', function () {
    Raven.showReportDialog();
    }, false);

    Edit: Although that^ works, this should be safer, to make sure you have the right event id:

    document.addEventListener('ravenSuccess', function (event) {
      Raven.showReportDialog({eventId: event.data.event_id});
    }, false);
  5. mpj commented on Aug 8, 2017

    @mpj

    @benvinegar @friday I am having this problem too. However, I'm sceptical of the solution that @friday posted - partly because it's not obvious what ravenSuccess entails as an event, and also, I cannot seem to locate that string anywhere in the raven-js source.

  6. friday commented on Aug 8, 2017

    @friday

    @mpj: The "success" part of ravenSuccess refers to the request for the error report. It's not documented, but you can see how it works here (and why you couldn't search for it): https://github.com/getsentry/raven-js/blob/d88422c2e5409bef914975b3dbd858e09d866f27/src/raven.js#L730
    (called from here: https://github.com/getsentry/raven-js/blob/d88422c2e5409bef914975b3dbd858e09d866f27/src/raven.js#L1636).

    It could be potentially dangerous if they removed the event or started using it differently, so you're probably right to be sceptical. Also: I stopped using showReportDialog (for other reasons), so I don't know the status of the code I posted.

  7. friday commented on Aug 8, 2017

    @friday

    Update: I tested this and it still works. I also updated the code above to use the actual event id rather than the last one.

  8. mpj commented on Aug 9, 2017

    @mpj

    @friday thanks SO much for your assistance, very helpful!

  9. cpoetter commented on Sep 7, 2017

    @cpoetter

    @friday Thanks soo much! I was trying for hours to make this work! 🎉

  10. esbenvb commented on Jul 21, 2018

    @esbenvb

    Seems to me that the solution above does not work anymore @3.26.4 :(

    Raven.config('https://be0af717412a423f84c9f8a7ab6a43a0@sentry.io/1245111').install()
    
    document.addEventListener(
      'ravenSuccess',
      event => {
        console.log(event) && Raven.showReportDialog({ eventId: event.data.event_id })
      },
      false
    )

    I don't get the event in my console and I see no dialog. The events are reported properly to Sentry though.

    I also tried the other approach, like

    Raven.setDataCallback(function (data) {
      // means an error was triggered
      Raven.showReportDialog(); // uses last event id
    });

    I get an error: RavenConfigError: Missing eventId

    Then I tried

    Raven.setDataCallback(data => {
      // means an error was triggered
      Raven.showReportDialog({ eventId: data.event_id }) // uses last event id
    })

    Which gives me the same error message

    That's strange, because if I don't call the showReportDialog, I can get the event ID from the data.

    I get undefined when reading the property directly, but if I log the data object, the event_id is there. BUT As soon as I add the showReportDialog it's not there anymore.

    Raven.setDataCallback(data => {
      console.log({ eventId: data.event_id }) // {eventId: undefined}
      console.log({ data }) // {data: {.... event_id: 12345}}
    })
    Raven.setDataCallback(data => {
      console.log({ eventId: data.event_id }) // {eventId: undefined}
      console.log({ data }) // {data: {.... }}     <---- no event-ID in object
      Raven.showReportDialog({ eventId: data.event_id })
    })
  11. friday commented on Jul 21, 2018

    @friday

    @esbenvb: console.log() doesn't return anything, so that's why it won't work.

    My example may still be broken though. I'm not using this any more, as mentioned, and it's internal undocumented API so using it is risky.

  12. kamilogorek commented on Sep 11, 2018

    @kamilogorek
    Contributor

    This is fixed in new SDK:

    init({
      dsn: '__DSN__',
      beforeSend(event) {
        // event.event_id is now always available
      }
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions