From 044b9dc5b8bacf8d6b53b0ea8d0c765b13a4d099 Mon Sep 17 00:00:00 2001 From: Alex Navasardyan Date: Mon, 16 Mar 2015 18:59:46 -0700 Subject: [PATCH] Better context for Bugsnag --- .../files/app/initializers/bugsnag.js | 28 ++++++++++++------- blueprints/ember-cli-bugsnag/index.js | 3 -- index.js | 11 +++++--- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/blueprints/ember-cli-bugsnag/files/app/initializers/bugsnag.js b/blueprints/ember-cli-bugsnag/files/app/initializers/bugsnag.js index e88e98c..f9626ee 100644 --- a/blueprints/ember-cli-bugsnag/files/app/initializers/bugsnag.js +++ b/blueprints/ember-cli-bugsnag/files/app/initializers/bugsnag.js @@ -1,19 +1,27 @@ -import Ember from 'ember'; +import Ember from 'ember'; +import config from '../config/environment'; + +var currentEnv = config.environment; export default { name: 'bugsnag-error-service', initialize: function() { - Ember.onerror = function (error) { - Bugsnag.notifyException(error); - }; + if (Bugsnag.notifyReleaseStages.indexOf(currentEnv) !== -1) { + Ember.onerror = function (error) { + Bugsnag.context = container.lookup('router:main').get('location').getURL(); + Bugsnag.notifyException(error); + }; - Ember.RSVP.on('error', function(error) { - Bugsnag.notifyException(error); - }); + Ember.RSVP.on('error', function(error) { + Bugsnag.context = container.lookup('router:main').get('location').getURL(); + Bugsnag.notifyException(error); + }); - Ember.Logger.error = function (message, cause, stack) { - Bugsnag.notifyException(new Error(message), null, { cause: cause, stack: stack }); - }; + Ember.Logger.error = function (message, cause, stack) { + Bugsnag.context = container.lookup('router:main').get('location').getURL(); + Bugsnag.notifyException(new Error(message), null, { cause: cause, stack: stack }); + }; + } } }; diff --git a/blueprints/ember-cli-bugsnag/index.js b/blueprints/ember-cli-bugsnag/index.js index b7b3b20..0a4ebe6 100644 --- a/blueprints/ember-cli-bugsnag/index.js +++ b/blueprints/ember-cli-bugsnag/index.js @@ -10,9 +10,6 @@ module.exports = { }, afterInstall: function() { - - this.addBowerPackageToProject('bugsnag', '~2.4.7'); - this.insertIntoFile('.jshintrc', ' "Bugsnag",', { after: '"predef": [\n' }); diff --git a/index.js b/index.js index ef8901b..a13414e 100644 --- a/index.js +++ b/index.js @@ -10,15 +10,18 @@ module.exports = { var content = ''; var bugsnagConfig; - if (type === 'head' && config.environment !== 'test') { + if (type === 'head') { bugsnagConfig = readConfig(); content = [ + '', '' ]; }