Open machty opened 6 years ago
@machty We encountered the same issue where user data was not provided in Bugsnag. My solution was to report handled exceptions by explicitly calling Ember.onerror
. I'm not thrilled with this approach, so if anyone alternative solutions they would be much appreciated :)
// app/utils/bugsnag-exception.js
import Ember from 'ember';
/* Handled Exceptions can be reported as follows:
try {
// Some code which might throw an exception
} catch (error) {
bugsnagNotifyException(error, name);
}
*/
export default function bugsnagNotifyException(e, name) {
if (Ember.onerror) {
e.name = name || e.name;
Ember.onerror(e);
}
}
I'm reviewing some recent Bugsnags and realizing that the
user
andmetadata
tags are not always provided as part of the Bugsnag. I'm not 100% certain but I believe it's because there's some instances in our app where we recover from an error but still want to useBugsnag.notifyException
.The problem seems to be, from my understanding of that code, that
getUser()
andgetMetadata()
don't get called except from withinonerror
: https://github.com/binhums/ember-cli-bugsnag/blob/master/app/instance-initializers/bugsnag.js#L50The result of this seems to be that if the first Bugsnag report issued is a manual
notifyException
, it won't contain pull in your user data / metadata. But if an onerror occurred, it'll set these values for all futurenotifyException
s.I'm surprised no one's noticed this; it makes me wonder if I'm misusing the API somehow? Is it ok that I'm still using
Bugsnag.notifyException
to report handled exceptions? Or is there a better workflow?