Module: ThisData::TrackRequest
- Defined in:
- lib/this_data/track_request.rb
Defined Under Namespace
Classes: ThisDataTrackError
Instance Method Summary collapse
-
#thisdata_track(verb: ThisData::Verbs::LOG_IN, user: nil) ⇒ Object
Will pull request and user details from the controller, and send an event to ThisData.
Instance Method Details
#thisdata_track(verb: ThisData::Verbs::LOG_IN, user: nil) ⇒ Object
Will pull request and user details from the controller, and send an event to ThisData. Arguments:
verb: (String, Required). Defaults to ThisData::Verbs::LOG_IN.
user: (Object, Optional). If you want to override the user record
that we would usually fetch, you can pass it here.
Unless a user is specified here we'll attempt to get the user record
as specified in the ThisData gem configuration. This defaults to
`current_user`.
The object must respond to at least
`ThisData.configuration.user_id_method`, which defaults to `id`.
Returns the result of ThisData.track (an HTTPartyResponse)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/this_data/track_request.rb', line 25 def thisdata_track(verb: ThisData::Verbs::LOG_IN, user: nil) if user.nil? user = send(ThisData.configuration.user_method) end event = { verb: verb, ip: request.remote_ip, user_agent: request.user_agent, user: user_details(user) } ThisData.track(event) rescue => e ThisData.error "Could not track event:" ThisData.error e ThisData.error e.backtrace[0..5].join("\n") false end |