mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +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:
parent
ebc2ad7c81
commit
08b790b3c2
14 changed files with 188 additions and 104 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue