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
@cldwalker 鈥撀爑sing showReportDialog
with uncaught exceptions is ... what it's for. Can you clarify?
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)
Technically it works for uncaught exceptions too. You could do the following:
```javascript
Raven.setDataCallback(function (data) {
// means an error was triggered
Raven.showReportDialog(); // uses last event id
});
That doesn't seem to work @benvinegar:
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);
@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.
@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.
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.
@friday thanks SO much for your assistance, very helpful!
@friday Thanks soo much! I was trying for hours to make this work! 馃帀
Seems to me that the solution above does not work anymore @3.26.4 :(
Raven.config('https://[email protected]/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 })
})
@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.
This is fixed in new SDK:
init({
dsn: '__DSN__',
beforeSend(event) {
// event.event_id is now always available
}
});
Most helpful comment
That doesn't seem to work @benvinegar:
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: