Method: Elasticsearch::API::SearchApplication::Actions#post_behavioral_analytics_event

Defined in:
lib/elasticsearch/api/actions/search_application/post_behavioral_analytics_event.rb

#post_behavioral_analytics_event(arguments = {}) ⇒ Object

Creates a behavioral analytics event for existing collection. This functionality is Experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :collection_name (String)

    The name of behavioral analytics collection

  • :event_type (String)

    Behavioral analytics event type. Available: page_view, search, search_click

  • :debug (Boolean)

    If true, returns event information that will be stored

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The event definition (Required)

Raises:

  • (ArgumentError)

See Also:

[View source]

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/elasticsearch/api/actions/search_application/post_behavioral_analytics_event.rb', line 39

def post_behavioral_analytics_event(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'search_application.post_behavioral_analytics_event' }

  defined_params = %i[collection_name event_type].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'collection_name' missing" unless arguments[:collection_name]
  raise ArgumentError, "Required argument 'event_type' missing" unless arguments[:event_type]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _collection_name = arguments.delete(:collection_name)

  _event_type = arguments.delete(:event_type)

  method = Elasticsearch::API::HTTP_POST
  path   = "_application/analytics/#{Utils.__listify(_collection_name)}/event/#{Utils.__listify(_event_type)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end