mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 17:45:54 +08:00
FIX: Do not consider mobile app traffic as crawler visits
Followup to a4eb523a
This commit is contained in:
@ -68,17 +68,30 @@ describe Middleware::RequestTracker do
|
||||
expect(ApplicationRequest.page_view_crawler.first.count).to eq(1)
|
||||
expect(ApplicationRequest.page_view_anon_mobile.first.count).to eq(1)
|
||||
|
||||
# log discourse User Agent requests as crawler for page views
|
||||
expect(ApplicationRequest.page_view_crawler.first.count).to eq(1)
|
||||
end
|
||||
|
||||
it "can log Discourse user agent requests correctly" do
|
||||
# log discourse api agents as crawlers for page view stats...
|
||||
data = Middleware::RequestTracker.get_data(env(
|
||||
"HTTP_USER_AGENT" => "DiscourseAPI Ruby Gem 0.19.0"
|
||||
), ["200", { "Content-Type" => 'text/html' }], 0.1)
|
||||
|
||||
Middleware::RequestTracker.log_request(data)
|
||||
ApplicationRequest.write_cache!
|
||||
expect(ApplicationRequest.page_view_crawler.first.count).to eq(1)
|
||||
|
||||
expect(ApplicationRequest.page_view_crawler.first.count).to eq(2)
|
||||
# ...but count our mobile app user agents as regular visits
|
||||
data = Middleware::RequestTracker.get_data(env(
|
||||
"HTTP_USER_AGENT" => "Mozilla/5.0 AppleWebKit/605.1.15 Mobile/15E148 DiscourseHub)"
|
||||
), ["200", { "Content-Type" => 'text/html' }], 0.1)
|
||||
|
||||
Middleware::RequestTracker.log_request(data)
|
||||
ApplicationRequest.write_cache!
|
||||
|
||||
expect(ApplicationRequest.page_view_crawler.first.count).to eq(1)
|
||||
expect(ApplicationRequest.page_view_anon.first.count).to eq(1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "rate limiting" do
|
||||
|
Reference in New Issue
Block a user