Skip to content

Commit

Permalink
chore: added anonymous id in user registered event (#35875)
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadadeeltajamul authored Nov 22, 2024
1 parent 46ee8a9 commit 0682493
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions openedx/core/djangoapps/user_authn/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def create_account_with_params(request, params): # pylint: disable=too-many-sta
log.exception('Error while setting is_marketable attribute.')
is_marketable = None

_track_user_registration(user, profile, params, third_party_provider, registration, is_marketable)
_track_user_registration(user, profile, params, third_party_provider, registration, is_marketable, request=request)

# Sites using multiple languages need to record the language used during registration.
# If not, compose_and_send_activation_email will be sent in site's default language only.
Expand Down Expand Up @@ -356,9 +356,14 @@ def _link_user_to_third_party_provider(
return third_party_provider, running_pipeline


def _track_user_registration(user, profile, params, third_party_provider, registration, is_marketable):
def _track_user_registration(user, profile, params, third_party_provider, registration, is_marketable, request=None):
""" Track the user's registration. """
if hasattr(settings, 'LMS_SEGMENT_KEY') and settings.LMS_SEGMENT_KEY:
anonymous_id = ""
try:
anonymous_id = request.COOKIES.get('ajs_anonymous_id', "")
except: # pylint: disable=bare-except
pass
traits = {
'email': user.email,
'username': user.username,
Expand All @@ -370,7 +375,8 @@ def _track_user_registration(user, profile, params, third_party_provider, regist
'address': profile.mailing_address,
'gender': profile.gender_display,
'country': str(profile.country),
'is_marketable': is_marketable
'is_marketable': is_marketable,
'anonymous_id': anonymous_id
}
if settings.MARKETING_EMAILS_OPT_IN and params.get('marketing_emails_opt_in'):
email_subscribe = 'subscribed' if is_marketable else 'unsubscribed'
Expand All @@ -397,6 +403,7 @@ def _track_user_registration(user, profile, params, third_party_provider, regist
'host': params.get('host', ''),
'app_name': params.get('app_name', ''),
'utm_campaign': params.get('utm_campaign', ''),
'anonymous_id': anonymous_id
}
# VAN-738 - added below properties to experiment marketing emails opt in/out events on Braze.
if params.get('marketing_emails_opt_in') and settings.MARKETING_EMAILS_OPT_IN:
Expand Down

0 comments on commit 0682493

Please sign in to comment.