diff --git a/openedx/core/djangoapps/notifications/email/events.py b/openedx/core/djangoapps/notifications/email/events.py index a575d78eae..d05c829df2 100644 --- a/openedx/core/djangoapps/notifications/email/events.py +++ b/openedx/core/djangoapps/notifications/email/events.py @@ -48,3 +48,30 @@ def send_user_email_digest_sent_event(user, cadence_type, notifications, message EMAIL_DIGEST_SENT, event_data, ) + + +def send_immediate_email_digest_sent_event(user, cadence_type, notification): + """ + Sends tracker and segment event for immediate notification email + """ + event_data = { + "username": user.username, + "email": user.email, + "cadence_type": cadence_type, + "course_id": str(notification.course_id), + "app_name": notification.app_name, + "notification_type": notification.notification_type, + "content_url": notification.content_url, + "content": notification.content, + "send_at": str(datetime.datetime.now()) + } + with tracker.get_tracker().context(EMAIL_DIGEST_SENT, event_data): + tracker.emit( + EMAIL_DIGEST_SENT, + event_data, + ) + segment.track( + user.id, + EMAIL_DIGEST_SENT, + event_data, + ) diff --git a/openedx/core/djangoapps/notifications/email/tasks.py b/openedx/core/djangoapps/notifications/email/tasks.py index c907a6f09b..17aeca7ab2 100644 --- a/openedx/core/djangoapps/notifications/email/tasks.py +++ b/openedx/core/djangoapps/notifications/email/tasks.py @@ -16,7 +16,7 @@ from openedx.core.djangoapps.notifications.models import ( Notification, get_course_notification_preference_config_version ) -from .events import send_user_email_digest_sent_event +from .events import send_immediate_email_digest_sent_event, send_user_email_digest_sent_event from .message_type import EmailNotificationMessageType from .utils import ( add_headers_to_email_message, @@ -183,3 +183,4 @@ def send_immediate_cadence_email(email_notification_mapping, course_key): ).personalize(Recipient(user.id, user.email), language, message_context) message = add_headers_to_email_message(message, message_context) ace.send(message) + send_immediate_email_digest_sent_event(user, EmailCadence.IMMEDIATELY, notification)