Update application_controller.rb
This commit is contained in:
parent
3e713a9b26
commit
cc74145033
@ -25,8 +25,34 @@ class ApplicationController < ActionController::Base
|
|||||||
/ArkWeb/
|
/ArkWeb/
|
||||||
]
|
]
|
||||||
before_action :set_locale
|
before_action :set_locale
|
||||||
|
before_action :log_browser_info
|
||||||
after_action :track_action
|
after_action :track_action
|
||||||
|
|
||||||
|
def log_browser_info
|
||||||
|
# 构建详细的浏览器信息
|
||||||
|
browser_info = {
|
||||||
|
user_agent: request.user_agent,
|
||||||
|
path: request.path,
|
||||||
|
browser_name: browser.name,
|
||||||
|
browser_version: browser.version,
|
||||||
|
platform: browser.platform.name,
|
||||||
|
device: browser.device.name,
|
||||||
|
mobile: browser.mobile?,
|
||||||
|
tablet: browser.tablet?,
|
||||||
|
bot: browser.bot?,
|
||||||
|
matched_patterns: matched_browser_patterns,
|
||||||
|
timestamp: Time.current
|
||||||
|
}
|
||||||
|
|
||||||
|
# 使用 Rails.logger 记录信息(both development and production)
|
||||||
|
# Rails.logger.info "Browser Info: #{browser_info.to_json}"
|
||||||
|
|
||||||
|
# 如果是被拦截的浏览器,记录额外信息
|
||||||
|
unless browser_allowed?
|
||||||
|
Rails.logger.warn "Browser Blocked: #{browser_info.to_json}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def track_action
|
def track_action
|
||||||
|
Loading…
Reference in New Issue
Block a user