chore: added immediate email event (#36950)

This commit is contained in:
Muhammad Adeel Tajamul
2025-06-26 13:50:47 +05:00
committed by GitHub
parent f3053de6b7
commit 3806f9f4f0
2 changed files with 29 additions and 1 deletions

View File

@@ -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,
)

View File

@@ -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)