Skip to content

Commit

Permalink
Merge pull request #224 from skovhus/script-error-filter
Browse files Browse the repository at this point in the history
Updated ignore errors
  • Loading branch information
mattrobenolt committed Jul 7, 2014
2 parents c34acf7 + 7384ce4 commit 9b901a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ var Raven = {
globalOptions.ignoreErrors.push('Script error.');
globalOptions.ignoreErrors.push('Script error');

// Other variants of external script errors:
globalOptions.ignoreErrors.push('Javascript error: Script error on line 0');
globalOptions.ignoreErrors.push('Javascript error: Script error. on line 0');

// join regexp rules into one big rule
globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
globalOptions.ignoreUrls = globalOptions.ignoreUrls.length ? joinRegExp(globalOptions.ignoreUrls) : false;
Expand Down
22 changes: 14 additions & 8 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('TraceKit', function(){
if (numDone == numReports) {
done();
}
}
};
TraceKit.report.subscribe(subscriptionHandler);

// TraceKit.report always throws an exception in order to trigger
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('globals', function() {
assert.isTrue(isString(''));
assert.isFalse(isString({}));
assert.isFalse(isString(undefined));
assert.isFalse(isString(function(){}))
assert.isFalse(isString(function(){}));
});
});

Expand Down Expand Up @@ -1080,6 +1080,17 @@ describe('Raven (public API)', function() {
});
});

describe('ignore errors', function() {
it('should install default ignore errors', function() {
Raven.config('//abc@example.com/2');

assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
assert.isTrue(globalOptions.ignoreErrors.test('Javascript error: Script error on line 0'), 'it should install "Javascript error: Script error on line 0" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Javascript error: Script error. on line 0'), 'it should install "Javascript error: Script error. on line 0" by default');
});
});

describe('callback function', function() {
it('should callback a function if it is global', function() {
window.RavenConfig = {
Expand All @@ -1094,8 +1105,7 @@ describe('Raven (public API)', function() {

assert.equal(globalKey, 'random');
assert.equal(globalServer, 'http://some.other.server:80/api/2/store/');
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');

assert.equal(globalOptions.some, 'config');
assert.equal(globalProject, '2');

Expand All @@ -1111,8 +1121,6 @@ describe('Raven (public API)', function() {
assert.equal(Raven, Raven.config(SENTRY_DSN, {foo: 'bar'}), 'it should return Raven');
assert.equal(globalKey, 'abc');
assert.equal(globalServer, 'http://example.com:80/api/2/store/');
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
assert.equal(globalOptions.foo, 'bar');
assert.equal(globalProject, '2');
assert.isTrue(isSetup());
Expand All @@ -1122,8 +1130,6 @@ describe('Raven (public API)', function() {
Raven.config('//abc@example.com/2');
assert.equal(globalKey, 'abc');
assert.equal(globalServer, '//example.com/api/2/store/');
assert.isTrue(globalOptions.ignoreErrors.test('Script error'), 'it should install "Script error" by default');
assert.isTrue(globalOptions.ignoreErrors.test('Script error.'), 'it should install "Script error." by default');
assert.equal(globalProject, '2');
assert.isTrue(isSetup());
});
Expand Down

0 comments on commit 9b901a7

Please sign in to comment.