Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propose a way to ignore current unwanted TransitionAborted raised by Ember 2.X #1

Merged
merged 1 commit into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions addon/instance-initializers/new-relic.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ export function initialize() {
return;
}

function mustIgnoreError(error) {
// Ember 2.X seems to not catch `TransitionAborted` errors caused by regular redirects. We don't want these errors to show up in NewRelic so we have to filter them ourselfs.
// Once the issue https://github.com/emberjs/ember.js/issues/12505 is resolved we can remove this ignored error.
return (error.name === 'TransitionAborted');
}

function handleError(error) {
if (mustIgnoreError(error)) {
return;
}

try {
NREUM.noticeError(error);
} catch(e) {
Expand Down
8 changes: 7 additions & 1 deletion tests/acceptance/new-relic-browser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('Loading New Relic Browser', function(assert) {
andThen(function() {
var newRelic = window.NREUM;

assert.expect(6);
assert.expect(8);

assert.ok(newRelic,
'The New Relic object (NREUM) should be added to the window');
Expand All @@ -29,10 +29,16 @@ test('Loading New Relic Browser', function(assert) {
assert.ok(error instanceof Error,
'noticeError should receive an error object');

assert.ok(error.name !== 'TransitionAborted',
'noticeError should not be called by Ember.onerror on TransitionAborted errors.');
};

Ember.onerror(new Error('Awh crap'));

const transitionError = new Error('Ember Transition Aborted Test');
transitionError.name = "TransitionAborted";
Ember.onerror(transitionError);

Ember.Logger.error('Whoops', 'We done messed up', {});

});
Expand Down