-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Capture message respects ignoreUrls/whitelistUrls #774 #1080
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Capture message respects ignoreUrls/whitelistUrls #774 #1080
Conversation
docs/config.rst
Outdated
@@ -90,7 +90,7 @@ Those configuration options are documented below: | |||
tags. Not setting this value is equivalent to a catch-all and will not | |||
filter out any values. | |||
|
|||
Does not affect ``captureMessage`` or when non-error object is passed in | |||
Does not affect when non-error object is passed in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't be true anymore with this PR, as Raven.captureException({foo: 'bar'})
, will end up calling Raven.captureMessage
https://github.com/getsentry/raven-js/blob/master/src/raven.js#L378-L389
docs/config.rst
Outdated
@@ -107,7 +107,7 @@ Those configuration options are documented below: | |||
messages to be filtered out before being sent to Sentry as either | |||
regular expressions or strings. | |||
|
|||
Does not affect captureMessage or when non-error object is passed in | |||
Does not affect when non-error object is passed in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
docs/config.rst
Outdated
@@ -128,7 +128,7 @@ Those configuration options are documented below: | |||
ignoreUrls: [/graph\.facebook\.com/, 'http://example.com/script2.js'] | |||
} | |||
|
|||
Does not affect captureMessage or when non-error object is passed in | |||
Does not affect when non-error object is passed in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here
src/raven.js
Outdated
if ( | ||
!!this._globalOptions.ignoreUrls.test && | ||
this._globalOptions.ignoreUrls.test(fileurl) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrap return
statement in curly braces
src/raven.js
Outdated
!!this._globalOptions.whitelistUrls.test && | ||
!this._globalOptions.whitelistUrls.test(fileurl) | ||
) | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
src/raven.js
Outdated
|
||
var prvCall = stack.stack[1]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd call this initialCall
to give it more meaning. Also please add comment about why it's 2nd frame, not the top one – similar to here https://github.com/getsentry/raven-node/blob/master/lib/client.js#L337
test/raven.test.js
Outdated
Raven._globalOptions.whitelistUrls = joinRegExp([/.+?host1.+/, /.+?host2.+/]); | ||
TraceKitStub.returns({stack: [{url: 'http://host1/'}, {url: 'http://host1/'}]}); | ||
Raven.captureMessage('Capture!'); | ||
assert.equal(Raven._send.callCount, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use assert.isTrue(Raven._send.calledOnce);
and assert.isTrue(Raven._send.calledTwice);
to be more consistent with the next test (which uses callOnce
attribute).
Thanks for contributing @HeroProtagonist! Just a few minor requests and we're good to go :) |
@kamilogorek Thanks for the review! I have updated my PR reflecting your comments |
Aaaand it's merged! Thanks @HeroProtagonist! :) |
🙌 Huge! |
resolves #774
captureMessage
will now respect ignoreUrls/whitelistUrlscaptureMessage
. The stack trace of this error will be used to test the file url and see if it matches ignoreUrls/whitelistUrls.