|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 | 3 | #
|
4 |
| -# Copyright 2016-2018, Optimizely and contributors |
| 4 | +# Copyright 2016-2019, Optimizely and contributors |
5 | 5 | #
|
6 | 6 | # Licensed under the Apache License, Version 2.0 (the "License");
|
7 | 7 | # you may not use this file except in compliance with the License.
|
@@ -113,6 +113,7 @@ def get_common_params(user_id, attributes)
|
113 | 113 | anonymize_ip: @config.anonymize_ip,
|
114 | 114 | revision: @config.revision,
|
115 | 115 | client_name: CLIENT_ENGINE,
|
| 116 | + enrich_decisions: true, |
116 | 117 | client_version: VERSION
|
117 | 118 | }
|
118 | 119 |
|
@@ -142,19 +143,18 @@ def create_impression_event(experiment, variation_id, user_id, attributes)
|
142 | 143 | Event.new(:post, ENDPOINT, event_params, POST_HEADERS)
|
143 | 144 | end
|
144 | 145 |
|
145 |
| - def create_conversion_event(event_key, user_id, attributes, event_tags, experiment_variation_map) |
| 146 | + def create_conversion_event(event, user_id, attributes, event_tags) |
146 | 147 | # Create conversion Event to be sent to the logging endpoint.
|
147 | 148 | #
|
148 |
| - # event_key - +String+ Event key representing the event which needs to be recorded. |
| 149 | + # event - +Object+ Event which needs to be recorded. |
149 | 150 | # user_id - +String+ ID for user.
|
150 | 151 | # attributes - +Hash+ representing user attributes and values which need to be recorded.
|
151 | 152 | # event_tags - +Hash+ representing metadata associated with the event.
|
152 |
| - # experiment_variation_map - +Map+ of experiment ID to the ID of the variation that the user is bucketed into. |
153 | 153 | #
|
154 | 154 | # Returns +Event+ encapsulating the conversion event.
|
155 | 155 |
|
156 | 156 | event_params = get_common_params(user_id, attributes)
|
157 |
| - conversion_params = get_conversion_params(event_key, event_tags, experiment_variation_map) |
| 157 | + conversion_params = get_conversion_params(event, event_tags) |
158 | 158 | event_params[:visitors][0][:snapshots] = [conversion_params]
|
159 | 159 |
|
160 | 160 | Event.new(:post, ENDPOINT, event_params, POST_HEADERS)
|
@@ -190,32 +190,20 @@ def get_impression_params(experiment, variation_id)
|
190 | 190 | impression_event_params
|
191 | 191 | end
|
192 | 192 |
|
193 |
| - def get_conversion_params(event_key, event_tags, experiment_variation_map) |
| 193 | + def get_conversion_params(event, event_tags) |
194 | 194 | # Creates object of params specific to conversion events
|
195 | 195 | #
|
196 |
| - # event_key - +String+ Key representing the event which needs to be recorded |
| 196 | + # event - +Object+ Event which needs to be recorded. |
197 | 197 | # event_tags - +Hash+ Values associated with the event.
|
198 |
| - # experiment_variation_map - +Hash+ Map of experiment IDs to bucketed variation IDs |
199 | 198 | #
|
200 | 199 | # Returns +Hash+ Conversion event params
|
201 | 200 |
|
202 | 201 | single_snapshot = {}
|
203 |
| - single_snapshot[:decisions] = [] |
204 |
| - experiment_variation_map.each do |experiment_id, variation_id| |
205 |
| - next unless variation_id |
206 |
| - |
207 |
| - single_snapshot[:decisions].push( |
208 |
| - campaign_id: @config.experiment_id_map[experiment_id]['layerId'], |
209 |
| - experiment_id: experiment_id, |
210 |
| - variation_id: variation_id |
211 |
| - ) |
212 |
| - end |
213 |
| - |
214 | 202 | event_object = {
|
215 |
| - entity_id: @config.event_key_map[event_key]['id'], |
| 203 | + entity_id: event['id'], |
216 | 204 | timestamp: create_timestamp,
|
217 | 205 | uuid: create_uuid,
|
218 |
| - key: event_key |
| 206 | + key: event['key'] |
219 | 207 | }
|
220 | 208 |
|
221 | 209 | if event_tags
|
|
0 commit comments