Method: Optimizely::EventBuilder#create_conversion_event

Defined in:
lib/optimizely/event_builder.rb

#create_conversion_event(project_config, event, user_id, attributes, event_tags) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/optimizely/event_builder.rb', line 137

def create_conversion_event(project_config, event, user_id, attributes, event_tags)
  # Create conversion Event to be sent to the logging endpoint.
  #
  # project_config -           +Object+ Instance of ProjectConfig
  # event -                    +Object+ Event which needs to be recorded.
  # user_id -                  +String+ ID for user.
  # attributes -               +Hash+ representing user attributes and values which need to be recorded.
  # event_tags -               +Hash+ representing metadata associated with the event.
  #
  # Returns +Event+ encapsulating the conversion event.

  event_params = get_common_params(project_config, user_id, attributes)
  conversion_params = get_conversion_params(event, event_tags)
  event_params[:visitors][0][:snapshots] = [conversion_params]

  Event.new(:post, ENDPOINT, event_params, POST_HEADERS)
end