Module: Mixpanelable::TrackerMethods::ClassMethods
- Defined in:
- lib/mixpanelable/tracker_methods.rb
Instance Method Summary collapse
- #track_event(name, properties = {}) ⇒ Object
- #track_event_for(active_record, name, properties = {}) ⇒ Object
- #track_event_for_request(name, properties = {}) ⇒ Object
- #user_agent ⇒ Object
- #user_agent_is_bot? ⇒ Boolean
Instance Method Details
#track_event(name, properties = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/mixpanelable/tracker_methods.rb', line 6 def track_event(name, properties = {}) return if user_agent_is_bot? event = EventBuilder.new(name: name, properties: properties).event Mixpanelable::Config.adapter.send_event(event) end |
#track_event_for(active_record, name, properties = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/mixpanelable/tracker_methods.rb', line 13 def track_event_for(active_record, name, properties = {}) return if user_agent_is_bot? event = EventBuilder.new(active_record: active_record, name: name, properties: properties).event Mixpanelable::Config.adapter.send_event(event) end |
#track_event_for_request(name, properties = {}) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/mixpanelable/tracker_methods.rb', line 20 def track_event_for_request(name, properties = {}) return if user_agent_is_bot? event = EventBuilder.new(unique_to_request: true, name: name, properties: properties).event Mixpanelable::Config.adapter.send_event(event) end |
#user_agent ⇒ Object
31 32 33 |
# File 'lib/mixpanelable/tracker_methods.rb', line 31 def user_agent Thread.current[:mixpanelable_user_agent] end |
#user_agent_is_bot? ⇒ Boolean
27 28 29 |
# File 'lib/mixpanelable/tracker_methods.rb', line 27 def user_agent_is_bot? Mixpanelable::Bots.bot?(user_agent) end |