1- # Copyright 2016-2018 , Optimizely
1+ # Copyright 2016-2019 , Optimizely
22# Licensed under the Apache License, Version 2.0 (the "License");
33# you may not use this file except in compliance with the License.
44# You may obtain a copy of the License at
@@ -130,6 +130,7 @@ def _get_common_params(self, user_id, attributes):
130130 commonParams [self .EventParams .USERS ][0 ][self .EventParams .ATTRIBUTES ] = self ._get_attributes (attributes )
131131
132132 commonParams [self .EventParams .SOURCE_SDK_TYPE ] = 'python-sdk'
133+ commonParams [self .EventParams .ENRICH_DECISIONS ] = True
133134 commonParams [self .EventParams .SOURCE_SDK_VERSION ] = version .__version__
134135 commonParams [self .EventParams .ANONYMIZE_IP ] = self ._get_anonymize_ip ()
135136 commonParams [self .EventParams .REVISION ] = self ._get_revision ()
@@ -152,6 +153,7 @@ class EventParams(object):
152153 CAMPAIGN_ID = 'campaign_id'
153154 VARIATION_ID = 'variation_id'
154155 END_USER_ID = 'visitor_id'
156+ ENRICH_DECISIONS = 'enrich_decisions'
155157 EVENTS = 'events'
156158 EVENT_ID = 'entity_id'
157159 ATTRIBUTES = 'attributes'
@@ -233,30 +235,17 @@ def _get_required_params_for_impression(self, experiment, variation_id):
233235
234236 return snapshot
235237
236- def _get_required_params_for_conversion (self , event_key , event_tags , decisions ):
238+ def _get_required_params_for_conversion (self , event_key , event_tags ):
237239 """ Get parameters that are required for the conversion event to register.
238240
239241 Args:
240242 event_key: Key representing the event which needs to be recorded.
241243 event_tags: Dict representing metadata associated with the event.
242- decisions: List of tuples representing valid experiments IDs and variation IDs.
243244
244245 Returns:
245246 Dict consisting of the decisions and events info for conversion event.
246247 """
247248 snapshot = {}
248- snapshot [self .EventParams .DECISIONS ] = []
249-
250- for experiment_id , variation_id in decisions :
251-
252- experiment = self .config .get_experiment_from_id (experiment_id )
253-
254- if variation_id :
255- snapshot [self .EventParams .DECISIONS ].append ({
256- self .EventParams .EXPERIMENT_ID : experiment_id ,
257- self .EventParams .VARIATION_ID : variation_id ,
258- self .EventParams .CAMPAIGN_ID : experiment .layerId
259- })
260249
261250 event_dict = {
262251 self .EventParams .EVENT_ID : self .config .get_event (event_key ).id ,
@@ -303,22 +292,21 @@ def create_impression_event(self, experiment, variation_id, user_id, attributes)
303292 http_verb = self .HTTP_VERB ,
304293 headers = self .HTTP_HEADERS )
305294
306- def create_conversion_event (self , event_key , user_id , attributes , event_tags , decisions ):
295+ def create_conversion_event (self , event_key , user_id , attributes , event_tags ):
307296 """ Create conversion Event to be sent to the logging endpoint.
308297
309298 Args:
310299 event_key: Key representing the event which needs to be recorded.
311300 user_id: ID for user.
312301 attributes: Dict representing user attributes and values.
313302 event_tags: Dict representing metadata associated with the event.
314- decisions: List of tuples representing experiments IDs and variation IDs.
315303
316304 Returns:
317305 Event object encapsulating the conversion event.
318306 """
319307
320308 params = self ._get_common_params (user_id , attributes )
321- conversion_params = self ._get_required_params_for_conversion (event_key , event_tags , decisions )
309+ conversion_params = self ._get_required_params_for_conversion (event_key , event_tags )
322310
323311 params [self .EventParams .USERS ][0 ][self .EventParams .SNAPSHOTS ].append (conversion_params )
324312 return Event (self .EVENTS_URL ,
0 commit comments