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

feat: added email sent signal to edx ace #292

Merged
merged 3 commits into from
Aug 6, 2024
Merged

Conversation

AhtishamShahid
Copy link
Contributor

@AhtishamShahid AhtishamShahid commented Jul 22, 2024

Description

Added signal to track if email is sent for analytics and tracking.

Ticket

https://2u-internal.atlassian.net/browse/INF-1456

edx_ace/ace.py Outdated
@@ -51,6 +51,7 @@ def send(msg):
try:
rendered_message = presentation.render(channel, msg)
delivery.deliver(channel, rendered_message, msg)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this line to keep the commit more focused.

@@ -10,6 +10,7 @@
from django.conf import settings

from edx_ace.errors import RecoverableChannelDeliveryError
from edx_ace.signals import ACE_EMAIL_SENT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AhtishamShahid Should we use a Django signal here or a https://github.com/openedx/openedx-events and https://github.com/openedx/openedx-filters event?

This is more of discussion than a request. Please let me know what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

We are not fundamentally changing the application behavior or flow , so using openedx-filters does not seem appropriate. However, openedx-events can work similarly to our current implementation. The use of global signals would be meaningful if we intended to handle that signal in other packages as well, but that is not the case at this time. Therefore, directly using Django signals makes more sense to me.

Comment on lines 6 to 7
# signal to indicate that an email has been sent using ace
ACE_EMAIL_SENT = Signal()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# signal to indicate that an email has been sent using ace
ACE_EMAIL_SENT = Signal()
# signal to indicate that a message has been sent using ace
ACE_MESSAGE_SENT = Signal()

We support both Push notifications and email as message types among other types.

Copy link
Member

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename it. I still see the old EMAIL word in the diff.

from django.dispatch import Signal

# signal to indicate that a message has been sent using ace
ACE_EMAIL_SENT = Signal()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ACE_EMAIL_SENT = Signal()
ACE_MESSAGE_SENT = Signal()

Copy link
Contributor

@muhammadadeeltajamul muhammadadeeltajamul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you thought of a way to check if an email fails to send? I think they are also needed for tracking.

FYI: I know the ticket scope is to generate event when email is send successfully.

@AhtishamShahid AhtishamShahid merged commit 8f9a355 into master Aug 6, 2024
10 checks passed
@AhtishamShahid AhtishamShahid deleted the ahtisham/INF-1456 branch August 6, 2024 10:48
Copy link
Member

@OmarIthawi OmarIthawi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AhtishamShahid I've sumitted a review already, but it seems that a bad internet connection got it lost.

I was surprised that it's been merged, but since my review was lost by GitHub, it's fine.

Would you mind checking the comment? It seems that we're sending the signal in cases where the message isn't sent.

Anyway, please ensure tests are added for the following cases:

  • Email is sent: ensure only one signal is sent.
  • Email sending fails: Ensure no signal is sent.
  • Email and Push notifications: Two signals are sent with appropriate channel parameter
ACE_MESSAGE_SENT.send(sender=channel, message=message)

return

delivery_expired_report = f'{channel_type}_delivery_expired'
logger.debug(delivery_expired_report)
message.report(delivery_expired_report, get_current_time() - start_time)
ACE_MESSAGE_SENT.send(sender=channel, message=message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind explaining the logic behind this line?

It seems to be added by mistake.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muhammadadeeltajamul please check the review above and let me know when the notes can be addressed.

@AhtishamShahid
Copy link
Contributor Author

@AhtishamShahid I've sumitted a review already, but it seems that a bad internet connection got it lost.

I was surprised that it's been merged, but since my review was lost by GitHub, it's fine.

Would you mind checking the comment? It seems that we're sending the signal in cases where the message isn't sent.

Anyway, please ensure tests are added for the following cases:

  • Email is sent: ensure only one signal is sent.
  • Email sending fails: Ensure no signal is sent.
  • Email and Push notifications: Two signals are sent with appropriate channel parameter
ACE_MESSAGE_SENT.send(sender=channel, message=message)

Create a PR with these changes #296

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants