From e28a01e2bf78d5750c649edf5e8d48776cc38d8d Mon Sep 17 00:00:00 2001 From: Muhammad Adeel Tajamul <77053848+muhammadadeeltajamul@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:13:06 +0500 Subject: [PATCH] temp: logs for unsubscribe event (#35652) --- openedx/core/djangoapps/notifications/email/utils.py | 4 ++++ openedx/core/djangoapps/notifications/events.py | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openedx/core/djangoapps/notifications/email/utils.py b/openedx/core/djangoapps/notifications/email/utils.py index 582e867d629d..81a245b2cf12 100644 --- a/openedx/core/djangoapps/notifications/email/utils.py +++ b/openedx/core/djangoapps/notifications/email/utils.py @@ -3,6 +3,7 @@ """ import datetime import json +import logging from bs4 import BeautifulSoup from django.conf import settings @@ -31,6 +32,7 @@ User = get_user_model() +log = logging.getLogger(__name__) def is_email_notification_flag_enabled(user=None): @@ -411,4 +413,6 @@ def get_updated_preference(pref): if pref_value else EmailCadence.NEVER type_prefs['email_cadence'] = cadence_value preference.save() + if not user.id: + log.info(f" - user.id is null - {encrypted_username} ") notification_preference_unsubscribe_event(user) diff --git a/openedx/core/djangoapps/notifications/events.py b/openedx/core/djangoapps/notifications/events.py index 91b12075a8a1..74e6e56e41e3 100644 --- a/openedx/core/djangoapps/notifications/events.py +++ b/openedx/core/djangoapps/notifications/events.py @@ -167,6 +167,5 @@ def notification_preference_unsubscribe_event(user): 'username': user.username, 'event_type': 'email_digest_unsubscribe' } - with tracker.get_tracker().context(NOTIFICATION_PREFERENCE_UNSUBSCRIBE, event_data): - tracker.emit(NOTIFICATION_PREFERENCE_UNSUBSCRIBE, event_data) - segment.track(user.id, NOTIFICATION_PREFERENCE_UNSUBSCRIBE, event_data) + tracker.emit(NOTIFICATION_PREFERENCE_UNSUBSCRIBE, event_data) + segment.track(user.id, NOTIFICATION_PREFERENCE_UNSUBSCRIBE, event_data)