Skip to content

Commit bd6ea2e

Browse files
Fixing log messages for numeric metric (#217)
1 parent 03e61ad commit bd6ea2e

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

optimizely/event/event_factory.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,20 @@ def create_log_event(cls, user_events, logger):
5555
if visitor:
5656
visitors.append(visitor)
5757

58-
user_context = event.event_context
59-
60-
event_batch = payload.EventBatch(
61-
user_context.account_id,
62-
user_context.project_id,
63-
user_context.revision,
64-
user_context.client_name,
65-
user_context.client_version,
66-
user_context.anonymize_ip,
67-
True
68-
)
69-
7058
if len(visitors) == 0:
7159
return None
7260

61+
user_context = user_events[0].event_context
62+
event_batch = payload.EventBatch(
63+
user_context.account_id,
64+
user_context.project_id,
65+
user_context.revision,
66+
user_context.client_name,
67+
user_context.client_version,
68+
user_context.anonymize_ip,
69+
True
70+
)
71+
7372
event_batch.visitors = visitors
7473

7574
event_params = event_batch.get_event_params()

optimizely/helpers/event_tag_utils.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,15 @@ def get_numeric_value(event_tags, logger=None):
6767
numeric_metric_value = None
6868

6969
if event_tags is None:
70-
logger_message_debug = 'Event tags is undefined.'
70+
if logger:
71+
logger.log(enums.LogLevels.ERROR, 'Event tags is undefined.')
72+
return
7173
elif not isinstance(event_tags, dict):
72-
logger_message_debug = 'Event tags is not a dictionary.'
74+
if logger:
75+
logger.log(enums.LogLevels.ERROR, 'Event tags is not a dictionary.')
76+
return
7377
elif NUMERIC_METRIC_TYPE not in event_tags:
74-
logger_message_debug = 'The numeric metric key is not in event tags.'
78+
return
7579
else:
7680
numeric_metric_value = event_tags[NUMERIC_METRIC_TYPE]
7781
try:

0 commit comments

Comments
 (0)