Skip to content

Commit 138cb0d

Browse files
mauerbacaliabbasrizvi
authored andcommitted
attributes list should always be in event object. removed revision (#63)
1 parent 315275d commit 138cb0d

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

optimizely/event_builder.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ class EventParams(object):
297297
EVENT_ID = 'entity_id'
298298
ATTRIBUTES = 'attributes'
299299
DECISIONS = 'decisions'
300-
REVISION = 'revision'
301300
TIME = 'timestamp'
302301
KEY = 'key'
303302
TAGS = 'tags'
@@ -315,12 +314,12 @@ def _add_attributes(self, attributes):
315314
attributes: Dict representing user attributes and values which need to be recorded.
316315
"""
317316

318-
if not attributes:
319-
return
320-
321317
visitor = self.params[self.EventParams.USERS][0]
322318
visitor[self.EventParams.ATTRIBUTES] = []
323319

320+
if not attributes:
321+
return
322+
324323
for attribute_key in attributes.keys():
325324
attribute_value = attributes.get(attribute_key)
326325
# Omit falsy attribute values
@@ -340,10 +339,6 @@ def _add_source(self):
340339
self.params[self.EventParams.SOURCE_SDK_TYPE] = 'python-sdk'
341340
self.params[self.EventParams.SOURCE_SDK_VERSION] = version.__version__
342341

343-
def _add_revision(self):
344-
""" Add datafile revision information to the event. """
345-
self.params[self.EventParams.REVISION] = self.config.get_revision()
346-
347342
def _add_time(self):
348343
""" Add time information to the event. """
349344

@@ -371,7 +366,6 @@ def _add_common_params(self, user_id, attributes):
371366
self._add_visitor(user_id)
372367
self._add_attributes(attributes)
373368
self._add_source()
374-
self._add_revision()
375369

376370
def _add_required_params_for_impression(self, experiment, variation_id):
377371
""" Add parameters that are required for the impression event to register.

tests/test_event_builder.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def test_create_impression_event(self):
344344
'project_id': '111001',
345345
'visitors': [{
346346
'visitor_id': 'test_user',
347+
'attributes': [],
347348
'snapshots': [{
348349
'decisions': [{
349350
'variation_id': '111129',
@@ -358,7 +359,6 @@ def test_create_impression_event(self):
358359
}]
359360
}]
360361
}],
361-
'revision': '42',
362362
'client_name': 'python-sdk',
363363
'client_version': version.__version__
364364
}
@@ -403,7 +403,6 @@ def test_create_impression_event__with_attributes(self):
403403
}]
404404
}]
405405
}],
406-
'revision': '42',
407406
'client_name': 'python-sdk',
408407
'client_version': version.__version__
409408
}
@@ -449,7 +448,6 @@ def test_create_conversion_event__with_attributes(self):
449448
}]
450449
}]
451450
}],
452-
'revision': '42',
453451
'client_name': 'python-sdk',
454452
'client_version': version.__version__
455453
}
@@ -502,7 +500,6 @@ def test_create_conversion_event__with_event_value(self):
502500
}],
503501
'account_id': '12001',
504502
'client_name': 'python-sdk',
505-
'revision': '42'
506503
}
507504

508505
with mock.patch('time.time', return_value=42.123), \
@@ -553,7 +550,6 @@ def test_create_conversion_event__with_invalid_event_value(self):
553550
}],
554551
'account_id': '12001',
555552
'client_name': 'python-sdk',
556-
'revision': '42'
557553
}
558554

559555
with mock.patch('time.time', return_value=42.123), \

0 commit comments

Comments
 (0)