Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing log messages for numeric metric #217

Merged
merged 2 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions optimizely/event/event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,20 @@ def create_log_event(cls, user_events, logger):
if visitor:
visitors.append(visitor)

user_context = event.event_context

event_batch = payload.EventBatch(
user_context.account_id,
user_context.project_id,
user_context.revision,
user_context.client_name,
user_context.client_version,
user_context.anonymize_ip,
True
)

if len(visitors) == 0:
return None

user_context = user_events[0].event_context
event_batch = payload.EventBatch(
user_context.account_id,
user_context.project_id,
user_context.revision,
user_context.client_name,
user_context.client_version,
user_context.anonymize_ip,
True
)

event_batch.visitors = visitors

event_params = event_batch.get_event_params()
Expand Down
10 changes: 7 additions & 3 deletions optimizely/helpers/event_tag_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ def get_numeric_value(event_tags, logger=None):
numeric_metric_value = None

if event_tags is None:
logger_message_debug = 'Event tags is undefined.'
if logger:
logger.log(enums.LogLevels.ERROR, 'Event tags is undefined.')
return
elif not isinstance(event_tags, dict):
logger_message_debug = 'Event tags is not a dictionary.'
if logger:
logger.log(enums.LogLevels.ERROR, 'Event tags is not a dictionary.')
return
elif NUMERIC_METRIC_TYPE not in event_tags:
logger_message_debug = 'The numeric metric key is not in event tags.'
return
else:
numeric_metric_value = event_tags[NUMERIC_METRIC_TYPE]
try:
Expand Down