overleaf/services/web/app/coffee/infrastructure/CrawlerLogger.coffee

12 lines
387 B
CoffeeScript
Raw Normal View History

metrics = require('metrics-sharelatex')
2014-02-12 10:23:40 +00:00
module.exports =
log: (req)->
if req.headers["user-agent"]?
userAgent = req.headers["user-agent"].toLowerCase()
if userAgent.indexOf("google") != -1
metrics.inc "crawler.google"
else if userAgent.indexOf("facebook") != -1
metrics.inc "crawler.facebook"
else if userAgent.indexOf("bing") != -1
metrics.inc "crawler.bing"