Module: AnalyticsPSW::Events

Included in:
Analytics
Defined in:
lib/analytics-psw/events.rb

Instance Method Summary collapse

Instance Method Details

#record_event(event_type, metadata = {}, asynchronous = false) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/analytics-psw/events.rb', line 4

def record_event(event_type,  = {}, asynchronous = false)
  return invalid_event_type_response unless event_type_exists? event_type
  return  unless dimensions_exist? 

  _record_event = -> do
    [:event_type] = event_type.to_s
    body = create_json_body('event', )
    http_request(:post, "#{@service_location}/events", nil, body)
  end

  asynchronous ? Thread.new { _record_event.call } : _record_event.call
end