Because parsing user agent string is a pain in the nit, we go lazy on this
one. We associate each broswer key like Chromium
to the query that allows
us to count the number of visits.
# MongoMatch query used for each browser key
#
# Because parsing user agent string is a pain in the nit, we go lazy on this
# one. We associate each broswer key like `Chromium` to the query that allows
# us to count the number of visits.
var browser_queries: HashMap[String, MongoMatch] do
var map = new HashMap[String, MongoMatch]
map["Chromium"] = (new MongoMatch).regex("user_agent", "Chromium")
map["Edge"] = (new MongoMatch).regex("user_agent", "Edge")
map["Firefox"] = (new MongoMatch).regex("user_agent", "Firefox")
map["IE"] = (new MongoMatch).regex("user_agent", "(MSIE)|(Trident)")
map["Netscape"] = (new MongoMatch).regex("user_agent", "Netscape")
map["Opera"] = (new MongoMatch).regex("user_agent", "Opera")
map["Safari"] = (new MongoMatch).land(null, [
(new MongoMatch).regex("user_agent", "Safari"),
(new MongoMatch).regex("user_agent", "^((?!Chrome).)*$")])
map["Chrome"] = (new MongoMatch).land(null, [
(new MongoMatch).regex("user_agent", "Chrome"),
(new MongoMatch).regex("user_agent", "^((?!Edge).)*$")])
return map
end
lib/popcorn/pop_tracker.nit:129,2--150,4