Skip to content
Snippets Groups Projects
Unverified Commit 1771777d authored by Marcelo Schmidt's avatar Marcelo Schmidt
Browse files

Add version and RocketChat.Info to Bugsnag notifications

parent d67774ee
No related branches found
No related tags found
No related merge requests found
......@@ -8,20 +8,22 @@ RocketChat.settings.get('Bugsnag_api_key', (key, value) => {
}
});
const bindEnvironment = Meteor.bindEnvironment;
Meteor.bindEnvironment = function(func, onException, _this) {
if (typeof(onException) !== 'function') {
if (!onException || typeof(onException) === 'string') {
var description = onException || 'callback of async function';
onException = function(error) {
RocketChat.bugsnag.notify(error);
Meteor._debug(
'Exception in ' + description + ':',
error && error.stack || error
);
};
}
const notify = function(message, stack) {
if (typeof stack === 'string') {
message += ' ' + stack;
}
const options = { app: { version: RocketChat.Info.version, info: RocketChat.Info } };
const error = new Error(message);
error.stack = stack;
RocketChat.bugsnag.notify(error, options);
};
process.on('uncaughtException', Meteor.bindEnvironment((error) => {
notify(error.message, error.stack);
}));
return bindEnvironment(func, onException, _this);
let originalMeteorDebug = Meteor._debug;
Meteor._debug = function() {
notify(...arguments);
return originalMeteorDebug(...arguments);
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment