question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ignore certain User agents?

See original GitHub issue

One feature I’m missing from raven-js is the ability to filter out user agents that have ill-behaving or just really old javascript engines. For example I get non-reproducible errors from CloudFlare-AlwaysOnline. And I don’t really want to bother if the microscopic number of IE8-9 users have some problems with the JS that I serve. Would it make sense to add an option for this?

I’m imagining something like this, using regex to allow full flexibility:

Raven.config('https://xyz@app.getsentry.com/12345', {
    ignoreUserAgents: ['^.*CloudFlare-AlwaysOnline.*$', '^.+MSIE 8.0;.+$']
}).install()

Perhaps it would make sense to add an additional option that just ignores all browsers that don’t support column numbers and stack traces, as you’ve listed here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
kamilogorekcommented, Aug 14, 2019

@hinok

Is it going to check also user-agent?

Not in this case, user agent is extracted from the request itself. You have to check it yourself.

Sentry.init({
  beforeSend(event) {
    // Ignore CloudFlare crawlers
    if (window.navigator.userAgent.indexOf('CloudFlare-AlwaysOnline') !== -1) return null;
    return event;
  }
});
3reactions
benvinegarcommented, Jun 21, 2016

So, you can do this today with shouldSendCallback:

Raven.config('https://xyz@app.getsentry.com/12345', {
  shouldSendCallback(data) {
    return !/^(.*CloudFlare-AlwaysOnline.*|.+MSIE 8\.0;.+)$/.test(window.navigator.userAgent);
  }
}).install();

I’m hesitant to add a bunch of convenience methods for stuff like this since it will add overhead to Raven.js, and it is frequently communicated to me how keeping Raven.js small is really important to users.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to ignore certain user agents? - Atatus Documentation
In the above example, we have ignored Phantom, CloudFare and IE 8 user agents. In the same way you can exclude your own...
Read more >
Ignore certain User agents? · Issue #617 · getsentry ... - GitHub
One feature I'm missing from raven-js is the ability to filter out user agents that have ill-behaving or just really old javascript engines....
Read more >
How do I exclude all requests with a specific User Agent from ...
To exclude traffic for a particular User agent (or several user agents), go to “Administration”, click on “Settings” under the “Websites” (or “Measurables”) ......
Read more >
Nginx disable logging for certain user agents - Stack Overflow
I'm trying to disable logging for certain user agents, unless I disable the main log for the site, it'll continue logging what I...
Read more >
Atlassian Partner, Wellington - User Agent Filtering - How To?
When you add a user-agent string into "Instant User-Agent parsing" and click parse, the result returned can be copy/pasted into either the include...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found