mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 18:41:07 +08:00
improve metrics gathered using in our traffic section
this also pulls out the middleware into its own home and inserts in front
This commit is contained in:
@ -114,29 +114,6 @@ module Middleware
|
||||
@app = app
|
||||
end
|
||||
|
||||
def self.log_request_on_site(env, helper=nil)
|
||||
host = RailsMultisite::ConnectionManagement.host(env)
|
||||
RailsMultisite::ConnectionManagement.with_hostname(host) do
|
||||
log_request(env,helper)
|
||||
end
|
||||
end
|
||||
|
||||
def self.log_request(env,helper=nil)
|
||||
|
||||
helper ||= Helper.new(env)
|
||||
|
||||
type =
|
||||
if helper.is_crawler?
|
||||
:crawler
|
||||
elsif helper.has_auth_cookie?
|
||||
:logged_in
|
||||
else
|
||||
:anon
|
||||
end
|
||||
|
||||
ApplicationRequest.increment!(type)
|
||||
end
|
||||
|
||||
def call(env)
|
||||
helper = Helper.new(env)
|
||||
|
||||
@ -146,10 +123,6 @@ module Middleware
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
ensure
|
||||
Scheduler::Defer.later "Track view" do
|
||||
self.class.log_request_on_site(env,helper)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user