Skip to content
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

fix: updated edx.ace.message_sent event #35498

Merged
merged 2 commits into from
Sep 24, 2024
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
30 changes: 13 additions & 17 deletions lms/djangoapps/bulk_email/signals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Signal handlers for the bulk_email app
"""
from django.contrib.auth import get_user_model
from django.dispatch import receiver
from eventtracking import tracker

Expand Down Expand Up @@ -32,29 +31,26 @@ def ace_email_sent_handler(sender, **kwargs):
"""
When an email is sent using ACE, this method will create an event to detect ace email success status
"""
# Fetch the message object from kwargs, defaulting to None if not present
message = kwargs.get('message', None)

user_model = get_user_model()
try:
user_id = user_model.objects.get(email=message.recipient.email_address).id
except user_model.DoesNotExist:
user_id = None
course_email = message.context.get('course_email', None)
course_id = message.context.get('course_id')
# Fetch the message dictionary from kwargs, defaulting to {} if not present
message = kwargs.get('message', {})
recipient = message.get('recipient', {})
message_name = message.get('name', None)
context = message.get('context', {})
email_address = recipient.get('email', None)
user_id = recipient.get('user_id', None)
channel = message.get('channel', None)
course_id = context.get('course_id', None)
if not course_id:
course_email = context.get('course_email', None)
course_id = course_email.course_id if course_email else None
try:
channel = sender.__class__.__name__
except AttributeError:
channel = 'Other'

tracker.emit(
'edx.ace.message_sent',
{
'message_type': message.name,
'message_type': message_name,
'channel': channel,
'course_id': course_id,
'user_id': user_id,
'user_email': message.recipient.email_address,
'user_email': email_address,
}
)
2 changes: 1 addition & 1 deletion requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ drf-yasg==1.21.7
# via
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via -r requirements/edx/kernel.in
edx-api-doc-tools==1.8.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ drf-yasg==1.21.7
# -r requirements/edx/testing.txt
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ drf-yasg==1.21.7
# -r requirements/edx/base.txt
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via -r requirements/edx/base.txt
edx-api-doc-tools==1.8.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ drf-yasg==1.21.7
# -r requirements/edx/base.txt
# django-user-tasks
# edx-api-doc-tools
edx-ace==1.11.1
edx-ace==1.11.2
# via -r requirements/edx/base.txt
edx-api-doc-tools==1.8.0
# via
Expand Down
Loading