Skip to content

Commit

Permalink
Better context for Bugsnag
Browse files Browse the repository at this point in the history
  • Loading branch information
twokul committed Mar 17, 2015
1 parent 2c2a6cd commit 044b9dc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
28 changes: 18 additions & 10 deletions blueprints/ember-cli-bugsnag/files/app/initializers/bugsnag.js
Original file line number Diff line number Diff line change
@@ -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 });
};
}
}
};
3 changes: 0 additions & 3 deletions blueprints/ember-cli-bugsnag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ module.exports = {
},

afterInstall: function() {

this.addBowerPackageToProject('bugsnag', '~2.4.7');

this.insertIntoFile('.jshintrc', ' "Bugsnag",', {
after: '"predef": [\n'
});
Expand Down
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ module.exports = {
var content = '';
var bugsnagConfig;

if (type === 'head' && config.environment !== 'test') {
if (type === 'head') {
bugsnagConfig = readConfig();

content = [
'<script ',
'src="//d2wy8f7a9ursnm.cloudfront.net/bugsnag-2.min.js" ',
'data-appversion="' + config.currentRevision + '" ',
'data-apikey="' + bugsnagConfig.apiKey + '">',
'</script>',
'<script>',
'Bugsnag.apiKey = "' + bugsnagConfig.apiKey + '";',
'Bugsnag.appVersion = "' + config.curentRevision + '";',
'Bugsnag.releaseStage = "' + config.environment + '";',
'Bugsnag.notifyReleaseStages = ["' + config.environment + '"];',
'Bugsnag.notifyReleaseStages = ["' + bugsnagConfig.notifyReleaseStages.join('","') + '"];',
'</script>'
];
}
Expand Down

0 comments on commit 044b9dc

Please sign in to comment.