Parse and log user agent type to NewRelic.

Parse the user agent and log whether it seems like a known bot or a
human to NewRelic under the `user.bot` request attribute. This is so
that known bots can be filtered out of search traffic analytics. Bots
and search crawlers make up a significant portion of search traffic.
This commit is contained in:
evazion
2021-06-28 05:01:10 -05:00
parent ad4c75eb1a
commit 000653d840
3 changed files with 255 additions and 1 deletions

View File

@@ -74,7 +74,8 @@ class DanbooruLogger
level: user&.level_string,
ip: request.remote_ip,
country: CurrentUser.country,
safe_mode: CurrentUser.safe_mode?
safe_mode: CurrentUser.safe_mode?,
bot: UserAgent.new(request.headers["HTTP_USER_AGENT"]).is_bot?,
}
end