Skip to content

Instantly share code, notes, and snippets.

@lucasscariot
Created June 19, 2017 09:35
Show Gist options
  • Save lucasscariot/3e6c2f4172f0267ab317b2977c4a53d2 to your computer and use it in GitHub Desktop.
Save lucasscariot/3e6c2f4172f0267ab317b2977c4a53d2 to your computer and use it in GitHub Desktop.
Bugsnag and emberjs
'use strict';
import Ember from 'ember';
import config from '../config/environment';
export default {
name: 'bugsnag',
initialize: function(appInstance) {
const appController = appInstance.lookup('controller:application');
Bugsnag.apiKey = config.BUGSNAG.key;
Bugsnag.releaseStage = config.environment;
Bugsnag.notifyReleaseStages = ['staging', 'production'];
// Notify Routing Errors and edge cases
Ember.onerror = function(error) {
Bugsnag.context = appController.get('currentPath');
Bugsnag.notifyException(error);
console.error(error.stack);
};
// Notify Promises Errors
Ember.RSVP.on('error', function (error) {
Bugsnag.context = appController.get('currentPath');
Bugsnag.notifyException(error);
});
// Notify Ember Logger Errors
Ember.Logger.error = function (message, cause, stack) {
Bugsnag.context = appController.get('currentPath');
Bugsnag.notifyException(new Error(message), null, { cause: cause, stack: stack });
console.error(stack);
};
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment