From a0ef0c04afb1ed74bfb78a00838815f96b7e92c5 Mon Sep 17 00:00:00 2001 From: Alex Dusenbery Date: Thu, 6 Jan 2022 14:57:41 -0500 Subject: [PATCH] fix: ignore Braze frequency capping for ent emails --- ecommerce_worker/email/v1/braze/client.py | 11 ++++++++++- setup.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ecommerce_worker/email/v1/braze/client.py b/ecommerce_worker/email/v1/braze/client.py index e601720d..02d75d1f 100644 --- a/ecommerce_worker/email/v1/braze/client.py +++ b/ecommerce_worker/email/v1/braze/client.py @@ -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 + 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. ['test1@example.com', 'test2@example.com'] @@ -318,6 +323,7 @@ def send_message( # pylint: disable=dangerous-default-value { "external_user_ids": [ "user1@example.com", "user2@example.org" ], "campaign_id": "some-campaign-identifier", + "override_frequency_capping": true, "messages": { "email": { "app_id": "99999999-9999-9999-9999-999999999999", @@ -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: + 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], diff --git a/setup.py b/setup.py index cf7ef50e..c6d7398b 100644 --- a/setup.py +++ b/setup.py @@ -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=[