1
- # Copyright 2016-2018 , Optimizely
1
+ # Copyright 2016-2019 , Optimizely
2
2
# Licensed under the Apache License, Version 2.0 (the "License");
3
3
# you may not use this file except in compliance with the License.
4
4
# You may obtain a copy of the License at
@@ -130,6 +130,7 @@ def _get_common_params(self, user_id, attributes):
130
130
commonParams [self .EventParams .USERS ][0 ][self .EventParams .ATTRIBUTES ] = self ._get_attributes (attributes )
131
131
132
132
commonParams [self .EventParams .SOURCE_SDK_TYPE ] = 'python-sdk'
133
+ commonParams [self .EventParams .ENRICH_DECISIONS ] = True
133
134
commonParams [self .EventParams .SOURCE_SDK_VERSION ] = version .__version__
134
135
commonParams [self .EventParams .ANONYMIZE_IP ] = self ._get_anonymize_ip ()
135
136
commonParams [self .EventParams .REVISION ] = self ._get_revision ()
@@ -152,6 +153,7 @@ class EventParams(object):
152
153
CAMPAIGN_ID = 'campaign_id'
153
154
VARIATION_ID = 'variation_id'
154
155
END_USER_ID = 'visitor_id'
156
+ ENRICH_DECISIONS = 'enrich_decisions'
155
157
EVENTS = 'events'
156
158
EVENT_ID = 'entity_id'
157
159
ATTRIBUTES = 'attributes'
@@ -233,30 +235,17 @@ def _get_required_params_for_impression(self, experiment, variation_id):
233
235
234
236
return snapshot
235
237
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 ):
237
239
""" Get parameters that are required for the conversion event to register.
238
240
239
241
Args:
240
242
event_key: Key representing the event which needs to be recorded.
241
243
event_tags: Dict representing metadata associated with the event.
242
- decisions: List of tuples representing valid experiments IDs and variation IDs.
243
244
244
245
Returns:
245
246
Dict consisting of the decisions and events info for conversion event.
246
247
"""
247
248
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
- })
260
249
261
250
event_dict = {
262
251
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)
303
292
http_verb = self .HTTP_VERB ,
304
293
headers = self .HTTP_HEADERS )
305
294
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 ):
307
296
""" Create conversion Event to be sent to the logging endpoint.
308
297
309
298
Args:
310
299
event_key: Key representing the event which needs to be recorded.
311
300
user_id: ID for user.
312
301
attributes: Dict representing user attributes and values.
313
302
event_tags: Dict representing metadata associated with the event.
314
- decisions: List of tuples representing experiments IDs and variation IDs.
315
303
316
304
Returns:
317
305
Event object encapsulating the conversion event.
318
306
"""
319
307
320
308
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 )
322
310
323
311
params [self .EventParams .USERS ][0 ][self .EventParams .SNAPSHOTS ].append (conversion_params )
324
312
return Event (self .EVENTS_URL ,
0 commit comments