Class: Trackguard::PageViewRecorder
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- Trackguard::PageViewRecorder
- Defined in:
- app/services/trackguard/page_view_recorder.rb
Constant Summary collapse
- BOT_REGEX =
/ Googlebot|Bingbot|Slurp|DuckDuckBot|Baidu|YandexBot| facebookexternalhit|Twitterbot|LinkedInBot| curl|wget|python-requests|python-urllib| Go-http-client|libwww|Java|Ruby| bot|crawl|spider /ix
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path:, ip:, user_agent:, referer:, session_id:, trace_id:, source: nil, initial: false) ⇒ PageViewRecorder
constructor
A new instance of PageViewRecorder.
Methods inherited from ApplicationService
Constructor Details
#initialize(path:, ip:, user_agent:, referer:, session_id:, trace_id:, source: nil, initial: false) ⇒ PageViewRecorder
Returns a new instance of PageViewRecorder.
11 12 13 14 15 16 17 18 19 20 |
# File 'app/services/trackguard/page_view_recorder.rb', line 11 def initialize(path:, ip:, user_agent:, referer:, session_id:, trace_id:, source: nil, initial: false) @path = path.to_s @ip = ip @user_agent = user_agent.to_s @referer = referer @session_id = session_id @trace_id = trace_id @source = source.presence @initial = initial end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/trackguard/page_view_recorder.rb', line 22 def call return if BOT_REGEX.match?(@user_agent) return if BlockedUserAgent.blocked?(@user_agent) return if @path.blank? || @path.start_with?("/admin") TrackPageViewJob.perform_later( path: @path, ip: @ip, user_agent: @user_agent, referer: @referer, session_id: @session_id, trace_id: @trace_id, source: @source, initial: @initial ) end |