Skip to content

Commit

Permalink
attributes list should always be in event object. removed revision (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
mauerbac authored and aliabbasrizvi committed Jul 18, 2017
1 parent 315275d commit 138cb0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 3 additions & 9 deletions optimizely/event_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ class EventParams(object):
EVENT_ID = 'entity_id'
ATTRIBUTES = 'attributes'
DECISIONS = 'decisions'
REVISION = 'revision'
TIME = 'timestamp'
KEY = 'key'
TAGS = 'tags'
Expand All @@ -315,12 +314,12 @@ def _add_attributes(self, attributes):
attributes: Dict representing user attributes and values which need to be recorded.
"""

if not attributes:
return

visitor = self.params[self.EventParams.USERS][0]
visitor[self.EventParams.ATTRIBUTES] = []

if not attributes:
return

for attribute_key in attributes.keys():
attribute_value = attributes.get(attribute_key)
# Omit falsy attribute values
Expand All @@ -340,10 +339,6 @@ def _add_source(self):
self.params[self.EventParams.SOURCE_SDK_TYPE] = 'python-sdk'
self.params[self.EventParams.SOURCE_SDK_VERSION] = version.__version__

def _add_revision(self):
""" Add datafile revision information to the event. """
self.params[self.EventParams.REVISION] = self.config.get_revision()

def _add_time(self):
""" Add time information to the event. """

Expand Down Expand Up @@ -371,7 +366,6 @@ def _add_common_params(self, user_id, attributes):
self._add_visitor(user_id)
self._add_attributes(attributes)
self._add_source()
self._add_revision()

def _add_required_params_for_impression(self, experiment, variation_id):
""" Add parameters that are required for the impression event to register.
Expand Down
6 changes: 1 addition & 5 deletions tests/test_event_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def test_create_impression_event(self):
'project_id': '111001',
'visitors': [{
'visitor_id': 'test_user',
'attributes': [],
'snapshots': [{
'decisions': [{
'variation_id': '111129',
Expand All @@ -358,7 +359,6 @@ def test_create_impression_event(self):
}]
}]
}],
'revision': '42',
'client_name': 'python-sdk',
'client_version': version.__version__
}
Expand Down Expand Up @@ -403,7 +403,6 @@ def test_create_impression_event__with_attributes(self):
}]
}]
}],
'revision': '42',
'client_name': 'python-sdk',
'client_version': version.__version__
}
Expand Down Expand Up @@ -449,7 +448,6 @@ def test_create_conversion_event__with_attributes(self):
}]
}]
}],
'revision': '42',
'client_name': 'python-sdk',
'client_version': version.__version__
}
Expand Down Expand Up @@ -502,7 +500,6 @@ def test_create_conversion_event__with_event_value(self):
}],
'account_id': '12001',
'client_name': 'python-sdk',
'revision': '42'
}

with mock.patch('time.time', return_value=42.123), \
Expand Down Expand Up @@ -553,7 +550,6 @@ def test_create_conversion_event__with_invalid_event_value(self):
}],
'account_id': '12001',
'client_name': 'python-sdk',
'revision': '42'
}

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

0 comments on commit 138cb0d

Please sign in to comment.