-
Notifications
You must be signed in to change notification settings - Fork 4k
feat: send mobile braze notifications LEARNER-10298 #36272
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
base: master
Are you sure you want to change the base?
Conversation
@jawad-khan can you fix the failing checks here? before we request Infinity folks to give this PR a pass, thanks! |
12f4356
to
5cdb65d
Compare
@@ -266,3 +267,25 @@ def get_core_config(self, app_name) -> Dict: | |||
} | |||
""" | |||
return self.get_notification_types(app_name).get('core', {}) | |||
|
|||
|
|||
class NotificationBrazeCampaigns(TimeStampedModel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be a model it should be a django setting, Emails sent through braze also require campaing_id that is stored in Django settings. Please review how Braze is integrated into edx-platform for emails.
https://github.com/openedx/edx-ace/blob/64023b0b6a92fd990bcae2c79cce2ae2b2d3de6c/edx_ace/channel/braze.py#L56
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted mobile team to have the flexibility of adding braze campaign ids whenever they want. Plus it gives extra control on disabling push notifications for a certain notification type.
send_braze_notification_to_mobile_users(push_notification_audience, generated_notification) | ||
|
||
|
||
def send_braze_notification_to_mobile_users(audience_ids, notification_object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending push notifications through braze should be part of edx-ace , a new channel can be created for this in edx-ace like this
https://github.com/openedx/edx-ace/blob/master/edx_ace/channel/push_notification.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide some information on the initiative that this is part of? e.g., is this linked to a product proposal, or are there any public tickets or docs explaining the need for the new braze model?
Unfortunately there is no public ticket or documentation for it yet. We are implementing push notification using braze for mobile devices. This PR is still in progress and we might remove this braze model. |
Okay, I have converted it to Draft since it is still in progress. Just to set expectations, the edx-platform maintenance team is unlikely to accept new code that ties the core platform to Braze (especially data models) unless there is a compelling product use case for the community. |
35e4b16
to
bc28321
Compare
bc28321
to
d060159
Compare
@kdmccormick I have decoupled core platform from edx-braze-client and removed data model. Also changing the status of PR since its almost ready. |
Hey @jawad-khan. By installing edx-braze-client as a base edx-platform requirement, this PR would still be adding Braze-specific logic and requirements to edx-platform, which we cannot accept. That said, thank you for your work on this--I think it's much closer to what we need. What we need is for the vendor-specific logic to be implemented through a pluggable backend rather than through a base-requirement library. My understanding is that edx-ace is meant to be that pluggable backend, so I am little confused about this PR, and unsure what exactly to recommend. Could you share the product proposal or design docs associated with this PR? That would help me recommend a path forward. |
Hi @kdmccormick. I am thinking of this solution in edx-ace. By removing edx-braze-client from base.in in edx-ace we can achieve this. What do you think of this solution? I'll try to collect any public documentation we have for you tomorrow. |
sender_id = context.pop('sender_id', None) | ||
default_web_config = get_default_values_of_preference(app_name, notification_type).get('web', False) | ||
generated_notification_audience = [] | ||
push_notification_audience = [] | ||
is_push_notification_enabled = ENABLE_PUSH_NOTIFICATIONS.is_enabled() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use CourseWaffleFlag
here. This will give more control when testing on stage and on prod
(settings.NOTIFICATION_CREATION_BATCH_SIZE, 10, 7), | ||
(settings.NOTIFICATION_CREATION_BATCH_SIZE + 10, 12, 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think query count should be +2 not +3. One query for fetching waffle flag and second to get list of emails.
- Purpose of this test case is to make sure that
NOTIFICATION_CREATION_BATCH_SIZE
is optimized. It is better to keep changes in this test case to minimum. i.e. we can set push waffle flag to False and see that if it only increases 1 query count. If change is more than +1, we need to update batch size accordingly
app_label="notifications", name="braze_push" | ||
).personalize(recipient, 'en', context) | ||
message.options['emails'] = emails | ||
message.options['braze_campaign'] = notification_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -254,6 +258,7 @@ def test_send_with_app_disabled_notifications(self, app_name, notification_type) | |||
self.assertIsNone(notification) | |||
|
|||
@override_waffle_flag(ENABLE_NOTIFICATIONS, active=True) | |||
@override_waffle_flag(ENABLE_PUSH_NOTIFICATIONS, active=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For test cases, which don't require push notifications to be enabled, I think we should skip override_waffle_flag
for them
a8147ee
to
078e4b5
Compare
# .. toggle_use_cases: temporary, open_edx | ||
# .. toggle_creation_date: 2025-02-11 | ||
# .. toggle_target_removal_date: 2026-02-11 | ||
# .. toggle_warning: When the flag is ON, Notifications will go through using braze on mobile devices. | ||
# .. toggle_tickets: LEARNER-10298 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toggle_tickets must be a public link.
If this truly is a temporary toggle with target removal of 2026, then the linked ticket should give us maintainers a way to check on the status of this removal plan.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need this toggle ticket here, I just followed template from other waffle flags. Also I don't think we need it temporarily. I'll update toggle info.
if notification_object.app_name != 'discussion': | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explain this with a comment.
sender = User.objects.get(id=sender_id) | ||
recipient = Recipient(sender.id, sender.email) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm probably just confused here, but could you explain why sender and recipient refer to the same user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a Recipient object to call PushNotificationMessageType.personalize method, otherwise we don't need this recipient. I have added send here in case we might need sender in future in the context.
I'll add a comment to clear this confusion.
def send_ace_msg_to_braze_push_channel(audience_ids, notification_object, sender_id): | ||
""" | ||
Send mobile notifications using ace braze_push channel. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[This is my primary review comment]
I am thinking of openedx/edx-enterprise#2352 in edx-ace. By removing edx-braze-client from base.in in edx-ace we can achieve this. What do you think of this solution?
Thank you for linking that. I don't think that would solve the underlying issue, which is: you are building push notifications support specifically for Braze users. It is not clear to me why you are doing that instead of building general push notification support, with Braze as a configurable backend.
However, maybe there is a piece of context I am missing? I would be happy to discuss the appropriateness of a generic approach vs. a Braze specific approach, but I cannot do that, because there is no public supporting information for this PR-- the product goal, the timeline, the details of the overall initative-- these are all unavailable to me or any other community member. Without support information, this will not merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kdmccormick We are working on product proposal which we can make public for open source community.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kdmccormick here's the proposal: https://openedx.atlassian.net/wiki/spaces/COMM/pages/4982079504/Push+Notifications+in+Mobile+Apps
(GitHub ticket also created following the proposal guidelines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is perfect Moiz, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kdmccormick is there anything else required for this PR to be moved to merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kdmccormick I have made this approach generic and its not linked with braze anymore. Let me know if anything else is needed.
Description
Send braze notification to mobile users. This change will pick braze campaign ids from db and send notification trigger to braze.
LEARNER-10298
Useful information to include:
Supporting information
Jira issue: https://2u-internal.atlassian.net/browse/LEARNER-10298
Deadline
ASAP.