Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

fix: ignore Braze frequency capping for ent emails #157

Merged
merged 1 commit into from
Jan 6, 2022
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
11 changes: 10 additions & 1 deletion ecommerce_worker/email/v1/braze/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ def send_message( # pylint: disable=dangerous-default-value
):
"""
Sends the message via Braze Rest API /messages/send
The "override_frequency_capping" key in the request payload is important;
it tells Braze to ignore the global campaign message frequency cap
for the message we're sending in this method. Since this is a transactional

Choose a reason for hiding this comment

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

nit: an extra space here

message, we'd like the recipient to receive it regardless of what/how-many
other campaign messages they have received.

Arguments:
email_ids (list): e.g. ['[email protected]', '[email protected]']
Expand All @@ -318,6 +323,7 @@ def send_message( # pylint: disable=dangerous-default-value
{
"external_user_ids": [ "[email protected]", "[email protected]" ],
"campaign_id": "some-campaign-identifier",
"override_frequency_capping": true,
"messages": {
"email": {
"app_id": "99999999-9999-9999-9999-999999999999",
Expand Down Expand Up @@ -374,12 +380,15 @@ def send_message( # pylint: disable=dangerous-default-value
message = {
'user_aliases': user_aliases,
'external_user_ids': external_ids,
'campaign_id': campaign_id,
'recipient_subscription_state': 'all',
'messages': {
'email': email
}
}
if campaign_id:

Choose a reason for hiding this comment

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

might not matter in the context of ecommerce-worker since all messages are probably transactional, but should override_frequency_capping be passed in rather than rely on the existence of campaign_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, IDK. To me, send_message() is only for transactional emails, and those should never be subject to the frequency cap. I could state the assumption clearly in the docstring, maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, I guess the docstring already states this pretty clearly.

message['campaign_id'] = campaign_id
message['override_frequency_capping'] = True

# Scrub the app_id from the log message
cleaned_message = copy.deepcopy(message)
cleaned_app_id = '{}...{}'.format(cleaned_message['messages']['email']['app_id'][0:4],
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def is_requirement(line):

setup(
name='edx-ecommerce-worker',
version='3.1.1',
version='3.1.2',
description='Celery tasks supporting the operations of edX\'s ecommerce service',
long_description=long_description,
classifiers=[
Expand Down