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

chore: added anonymous id in user registered event #35875

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
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
9 changes: 6 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,10 @@ 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 = request.COOKIES.get('ajs_anonymous_id')
traits = {
'email': user.email,
'username': user.username,
Expand All @@ -370,7 +371,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 +399,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
Loading