I have setup rollbar in my rails application. It keeps reporting recordnotfound which is as a result of SEO scrawlers (i.e Google bot, Baidu, findxbot etc..) searching for deleted post.
How to prevent rollbar from reporting SEO scrawler activities.
I have setup rollbar in my rails application. It keeps reporting recordnotfound which is as a result of SEO scrawlers (i.e Google bot, Baidu, findxbot etc..) searching for deleted post.
How to prevent rollbar from reporting SEO scrawler activities.
3
Answers
Looks like you are using rollbar-gem, so you’d want to use
Rollbar::Ignore
to tell Rollbar to ignore errors that were caused by a spiderwhere
is_crawler_error
detects if the request that led to the error was from a crawler.If you are using rollbar.js to detect errors in client-side Javascript, then you can use the
checkIgnore
option to filter out client-side errors caused by bots:Here’s what I did:
Based on these docs.
TL;DR:
======================
Be careful with magic comment
frozen_string_literal
and use=~
instead ofmatch?
if you have Ruby version less than 2.3.Here I use an array that will be transformed into regexp. I did this because I wanted to prevent syntax and escaping related errors of developers in future and add ignorecase thing for same reason.
So in regexp you will see a
Mail.RU_Bot
, instead of anything wrong.Also in your case you can use simply word
bot
instead of many crawlers, but be careful with unusual user-agents. In my case, I want to know all crawlers on my site, so I came up with this solution. Yet another example of working part: there arecrawler
andcrawler4j
on my production site. I use justcrawler
in array to prevent notifing for both of them.Last thing I want to say — my solution is not very optimal, but it just works. I hope someone will share an optimized version of my code. That’s also the main reason I recommend to send data asynchronously, i.e. use sidekiq, delayed_job or whatever you want, don’t forget to check related wikis.
My answer is based on @AndrewSouthpaw’s solution (?), that wasn’t working for me. Hoping that approved wiki-copy-pasted @Jesse Gibbs will be moderated some way.
=======
EDIT1: it’s nice idea to check the https://github.com/ZLevine/rollbar-ignore-crawler-errors repo if you need to prevent rollbar to notify on js.