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

captureMessage() uses global ignoreErrors config #312

Merged
merged 2 commits into from
Jan 28, 2015

Conversation

acdha
Copy link
Contributor

@acdha acdha commented Jan 28, 2015

Previously, only errors recorded using captureException were checked against the ignoreErrors regexp. captureMessage will now silently discard messages which match ignoreErrors.

The backstory is that I have code to collect errors which occur before Raven.JS has loaded:

        <script>
            var _raven_queue = [], Raven = {context: function (i) { return i(); }};
            window.onerror = function(message, file, line) {
               var msg = line ? message + " at " + line : message;
               _raven_queue.push([msg, {culprit: file}]);
            }
        </script>

and my page uses <script async> to load Raven without blocking and logs any errors which happened in the interim:

/* global RAVEN_PUBLIC_DSN, Raven, _raven_queue */

(function() {
    'use strict';

    if (!!RAVEN_PUBLIC_DSN && !!Raven && !!Raven.config) {
        Raven.config(RAVEN_PUBLIC_DSN, {
            ignoreErrors: [
                'bmi_SafeAddOnload',
                'EBCallBackMessageReceived',
                'conduitPage'
            ],
            ignoreUrls: [
                /^extensions\//i,
                /^chrome:\/\//i,
                /.*(twitter|readspeaker).*/i,
                /.*widgets[.]js/
            ]
        }).install();

        for (var i = 0; i < _raven_queue.length; i++) {
            Raven.captureMessage.apply(this, _raven_queue[i]);
        }
    }
}());

Previously, only errors recorded using captureException
were checked against the ignoreErrors regexp. captureMessage
will now silently discard messages which match ignoreErrors.
@mattrobenolt
Copy link
Contributor

Wanna add a test for this? :)

@acdha
Copy link
Contributor Author

acdha commented Jan 28, 2015

The attached test fails on master and passes with this branch.

mattrobenolt added a commit that referenced this pull request Jan 28, 2015
captureMessage() uses global ignoreErrors config
@mattrobenolt mattrobenolt merged commit 3ceae83 into getsentry:master Jan 28, 2015
@mattrobenolt
Copy link
Contributor

Thanks, homie. 🍰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants