Module: Analytic::Trackable
- Included in:
- DashboardController
- Defined in:
- app/controllers/concerns/analytic/trackable.rb
Instance Method Summary collapse
- #analytic_enqueue_track_job! ⇒ Object
- #analytic_host ⇒ String
- #analytic_ip ⇒ IPAddr
- #analytic_params ⇒ Hash
- #analytic_path ⇒ String
- #analytic_referrer ⇒ String
- #analytic_session_id ⇒ String
- #analytic_track! ⇒ Object
- #analytic_user_agent ⇒ String
- #analytic_visitor_id ⇒ String
Instance Method Details
#analytic_enqueue_track_job! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 21 def analytic_enqueue_track_job! Analytic::TrackJob.perform_later( session_id: analytic_session_id, visitor_id: analytic_visitor_id, ip: analytic_ip, host: analytic_host, path: analytic_path, referrer: analytic_referrer, user_agent: request.user_agent, params: analytic_params ) end |
#analytic_host ⇒ String
55 56 57 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 55 def analytic_host request.host end |
#analytic_ip ⇒ IPAddr
45 46 47 48 49 50 51 52 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 45 def analytic_ip ip_addr = IPAddr.new(request.remote_ip) return ip_addr.mask(Analytic.config.ip_v4_mask) if Analytic.config.ip_v4_mask? && ip_addr.ipv4? return ip_addr.mask(Analytic.config.ip_v6_mask) if Analytic.config.ip_v6_mask? && ip_addr.ipv6? ip_addr end |
#analytic_params ⇒ Hash
75 76 77 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 75 def analytic_params params.slice(*Analytic.config.params) end |
#analytic_path ⇒ String
60 61 62 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 60 def analytic_path request.path end |
#analytic_referrer ⇒ String
65 66 67 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 65 def analytic_referrer request.referer end |
#analytic_session_id ⇒ String
35 36 37 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 35 def analytic_session_id session[:analytic_session_id] ||= SecureRandom.uuid end |
#analytic_track! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 6 def analytic_track! Analytic::Event.create!( timestamp: Time.current, session_id: analytic_session_id, visitor_id: analytic_visitor_id, ip: analytic_ip, host: analytic_host, path: analytic_path, referrer: analytic_referrer, user_agent: request.user_agent, params: analytic_params ) end |
#analytic_user_agent ⇒ String
70 71 72 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 70 def analytic_user_agent request.user_agent end |
#analytic_visitor_id ⇒ String
40 41 42 |
# File 'app/controllers/concerns/analytic/trackable.rb', line 40 def analytic_visitor_id .permanent[:analytic_visitor_id] ||= SecureRandom.uuid end |