Skip to content

fix: correcting metadata and decision payload #303

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

Merged
merged 1 commit into from
Oct 14, 2020
Merged
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
16 changes: 13 additions & 3 deletions optimizely/event/event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,20 @@ def _create_visitor(cls, event, logger):
"""

if isinstance(event, user_event.ImpressionEvent):
metadata = payload.Metadata(event.flag_key, event.rule_key, event.rule_type, event.variation.key)
decision = payload.Decision(event.experiment.layerId, event.experiment.id, event.variation.id, metadata)
experiment_layerId, experiment_id, variation_id, variation_key = '', '', '', ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

experiment_layer_id or experiment_layerid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I thought about it, but we already have event.experiment.layerId


if event.variation:
variation_id = event.variation.id
variation_key = event.variation.key

if event.experiment:
experiment_layerId = event.experiment.layerId
experiment_id = event.experiment.id

metadata = payload.Metadata(event.flag_key, event.rule_key, event.rule_type, variation_key)
decision = payload.Decision(experiment_layerId, experiment_id, variation_id, metadata)
snapshot_event = payload.SnapshotEvent(
event.experiment.layerId, event.uuid, cls.ACTIVATE_EVENT_KEY, event.timestamp,
experiment_layerId, event.uuid, cls.ACTIVATE_EVENT_KEY, event.timestamp,
)

snapshot = payload.Snapshot([snapshot_event], [decision])
Expand Down