Skip to content

Set AnymailTrackingEvent.metadata to empty dict instead of None #67

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

Closed
lauritzen opened this issue Jun 15, 2017 · 2 comments
Closed

Set AnymailTrackingEvent.metadata to empty dict instead of None #67

lauritzen opened this issue Jun 15, 2017 · 2 comments

Comments

@lauritzen
Copy link

If there is no metadata attached a tracking event the metadata field is set to None. This is a bit inconvenient while handling tracking events as it introduces an extra conditional before accessing the datastructure:

if event.metadata:
  value = event.metadata.get(key)

Setting metadata = {} instead removes the need for the conditional.

@medmunds
Copy link
Contributor

That seems reasonable. I think my intent was for None to indicate the ESP hadn't included metadata in the webhook, so we couldn't be sure whether that meant the message was sent without metadata, or whether the ESP simply didn't pass it along with the event. But looking at the implementation, I don't think it ended up working that way.

I wonder if tags should also be initialized to [] rather than None, for similar reasons.

@lauritzen
Copy link
Author

Great. I agree on the same approach for tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants