TL/DR
Catching Global Exception is not working due to the this.get('isRavenUsable') in ember-cli-sentry that does not have any dependent key. Needed to overwrite using the ember-cli-deploy-sentry RavenService.
I wasn't sure if should post this here, or in the ember-cli-sentry repo, but they are too much related imho to make a good choice :)
Background
I was running into problems where I would only see "Error Error" as the error message in Sentry for Uncaught Global Exceptions. The following setting was set to true for my environment:
// config/environment.js
/**
* If set to true, addon will try to have Ember.onerror
* and Ember.RSVP.on('error') captured by Raven.
*
* @type {Boolean}
* @default true
*/
globalErrorCatching: true,
enableGlobalErrorCatching() {
// This guy here 'isRavenUsable' was never flipping from false to true after isSetup was done.
if (this.get('isRavenUsable') && !this.get('globalErrorCatchingInitialized')) {
const _oldOnError = Ember.onerror;
Ember.onerror = (error) => {
if (this._ignoreError(error)) {
return;
}
.... etc ..
The Problem
After debugging I could work out why the following was always set to false: this.get('isRavenUsable') in the ember-cli-sentry code. It's a computed property that somehow never changes its value anymore (as it does not have any dependent keys).
My solution
Now, I made a solution for this is partly using the README of the ember-cli-sentry-deploy repo that suggest to use the 'RavenService' that comes with it, instead of the ember-cli-sentry raven service. So I made an app-initializer much like the one that looks like https://github.com/ember-cli-sentry/ember-cli-sentry/blob/v4.1.0/app/instance-initializers/raven-setup.js, but I've made some alterations here:
import { get, computed } from '@ember/object';
import Raven from 'raven';
import RavenService from 'ember-cli-deploy-sentry/services/raven';
import ENV from 'webapp/config/environment';
const UsableRavenService = RavenService.extend({
// Overwriting 'isRavenUsable' to have a dependent key 'ravenOptions', No fastbooth check is done here, is not needed for my
// use case.
isRavenUsable: computed('ravenOptions', function () {
return Raven.isSetup() === true;
})
});
export function initialize(container) {
const config = ENV;
if (get(config, 'sentry.development') === true) {
if (get(config, 'sentry.debug') === true) {
console.info('`sentry` is configured for development mode.');
}
return;
}
if (!config.sentry) {
throw new Error('`sentry` should be configured when not in development mode.');
}
const raven = UsableRavenService.create();
raven.setup(config);
container.register('service:raven', raven, { instantiate: false })
}
export default {
name: 'raven',
initialize: initialize
};
TODO
Setup Raven correctly as part of ember-cli-deploy-sentry or document on how to this correctly to capture global exceptions.
TL/DR Catching Global Exception is not working due to the
this.get('isRavenUsable')
inember-cli-sentry
that does not have any dependent key. Needed to overwrite using theember-cli-deploy-sentry
RavenService.I wasn't sure if should post this here, or in the
ember-cli-sentry
repo, but they are too much related imho to make a good choice :)Background I was running into problems where I would only see "Error Error" as the error message in Sentry for Uncaught Global Exceptions. The following setting was set to true for my environment:
The 'ember-cli-sentry' plugin has a function that is called after the plugin is initialized, namely: https://github.com/ember-cli-sentry/ember-cli-sentry/blob/v4.1.0/addon/services/raven.js#L175
The Problem After debugging I could work out why the following was always set to false:
this.get('isRavenUsable')
in theember-cli-sentry
code. It's a computed property that somehow never changes its value anymore (as it does not have any dependent keys).My solution Now, I made a solution for this is partly using the README of the
ember-cli-sentry-deploy
repo that suggest to use the 'RavenService' that comes with it, instead of theember-cli-sentry
raven service. So I made an app-initializer much like the one that looks likehttps://github.com/ember-cli-sentry/ember-cli-sentry/blob/v4.1.0/app/instance-initializers/raven-setup.js
, but I've made some alterations here:TODO Setup Raven correctly as part of
ember-cli-deploy-sentry
or document on how to this correctly to capture global exceptions.