feat: added anonymous id in edx.bi.user.account.authenticated event (#35934)
This commit is contained in:
committed by
GitHub
parent
69216e5560
commit
3d5f4983c5
@@ -715,8 +715,18 @@ def login_analytics(strategy, auth_entry, current_partial=None, *args, **kwargs)
|
||||
""" Sends login info to Segment """
|
||||
|
||||
event_name = None
|
||||
anonymous_id = ""
|
||||
additional_params = {}
|
||||
|
||||
try:
|
||||
request = kwargs['request']
|
||||
anonymous_id = request.COOKIES.get('ajs_anonymous_id', "")
|
||||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
|
||||
if auth_entry == AUTH_ENTRY_LOGIN:
|
||||
event_name = 'edx.bi.user.account.authenticated'
|
||||
additional_params['anonymous_id'] = anonymous_id
|
||||
elif auth_entry in [AUTH_ENTRY_ACCOUNT_SETTINGS]:
|
||||
event_name = 'edx.bi.user.account.linked'
|
||||
|
||||
@@ -724,7 +734,8 @@ def login_analytics(strategy, auth_entry, current_partial=None, *args, **kwargs)
|
||||
segment.track(kwargs['user'].id, event_name, {
|
||||
'category': "conversion",
|
||||
'label': None,
|
||||
'provider': kwargs['backend'].name
|
||||
'provider': kwargs['backend'].name,
|
||||
**additional_params
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -354,6 +354,11 @@ def _track_user_login(user, request):
|
||||
# .. pii: Username and email are sent to Segment here. Retired directly through Segment API call in Tubular.
|
||||
# .. pii_types: email_address, username
|
||||
# .. pii_retirement: third_party
|
||||
anonymous_id = ""
|
||||
try:
|
||||
anonymous_id = request.COOKIES.get('ajs_anonymous_id', "")
|
||||
except: # pylint: disable=bare-except
|
||||
pass
|
||||
segment.identify(
|
||||
user.id,
|
||||
{"email": user.email, "username": user.username},
|
||||
@@ -367,7 +372,12 @@ def _track_user_login(user, request):
|
||||
segment.track(
|
||||
user.id,
|
||||
"edx.bi.user.account.authenticated",
|
||||
{"category": "conversion", "label": request.POST.get("course_id"), "provider": None},
|
||||
{
|
||||
"category": "conversion",
|
||||
"label": request.POST.get("course_id"),
|
||||
"provider": None,
|
||||
"anonymous_id": anonymous_id,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1145,7 +1145,7 @@ class LoginSessionViewTest(ApiTestCase, OpenEdxEventsTestMixin):
|
||||
mock_segment.track.assert_called_once_with(
|
||||
expected_user_id,
|
||||
'edx.bi.user.account.authenticated',
|
||||
{'category': 'conversion', 'provider': None, 'label': track_label}
|
||||
{'category': 'conversion', 'provider': None, 'label': track_label, 'anonymous_id': ''}
|
||||
)
|
||||
|
||||
def test_login_with_username(self):
|
||||
|
||||
Reference in New Issue
Block a user