diff --git a/openedx/core/djangoapps/notifications/email/utils.py b/openedx/core/djangoapps/notifications/email/utils.py index 582e867d62..81a245b2cf 100644 --- a/openedx/core/djangoapps/notifications/email/utils.py +++ b/openedx/core/djangoapps/notifications/email/utils.py @@ -3,6 +3,7 @@ Email Notifications Utils """ import datetime import json +import logging from bs4 import BeautifulSoup from django.conf import settings @@ -31,6 +32,7 @@ from .notification_icons import NotificationTypeIcons User = get_user_model() +log = logging.getLogger(__name__) def is_email_notification_flag_enabled(user=None): @@ -411,4 +413,6 @@ def update_user_preferences_from_patch(encrypted_username, encrypted_patch): 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 91b12075a8..74e6e56e41 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)