Module: Talis::Analytics

Defined in:
lib/talis/analytics.rb,
lib/talis/analytics/event.rb

Overview

Use this as a mixin within your classes to be able to send analytics events.

Defined Under Namespace

Classes: Event

Instance Method Summary collapse

Instance Method Details

#send_analytics_event(event, request_id: nil) ⇒ Object

Create a single analytics event. In order to send events, the client must be configured with a valid OAuth client that is allowed to search for users:

Talis::Authentication.client_id = 'client_id'
Talis::Authentication.client_secret = 'client_secret'

Parameters:

  • event (Hash)

    The event to send. It must contain the minimum keys:

    {
      class: 'my.class.name',
      source: 'my.source.name'
    }
    

    Other valid keys include: timestamp, user and props. Props can contain any key-value pair of custom data. All other keys will be ignored.

  • request_id (String) (defaults to: nil)

    (‘uuid’) unique ID for the remote request.

Raises:



27
28
29
# File 'lib/talis/analytics.rb', line 27

def send_analytics_event(event, request_id: nil)
  Event.create(request_id: request_id, event: event)
end