Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
68f44862
Commit
68f44862
authored
Sep 25, 2014
by
Bertrand Marron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add context.ionisx_id field to tracking logs
parent
4e9e5aaa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
common/djangoapps/track/middleware.py
+13
-0
No files found.
common/djangoapps/track/middleware.py
View file @
68f44862
...
...
@@ -6,6 +6,8 @@ import logging
from
django.conf
import
settings
from
social.apps.django_app.default
import
models
as
social_models
from
track
import
views
from
track
import
contexts
from
eventtracking
import
tracker
...
...
@@ -100,6 +102,7 @@ class TrackMiddleware(object):
context
=
{
'session'
:
self
.
get_session_key
(
request
),
'user_id'
:
self
.
get_user_primary_key
(
request
),
'ionisx_id'
:
self
.
get_ionisx_user_id
(
request
),
'username'
:
self
.
get_username
(
request
),
}
for
header_name
,
context_key
in
META_KEY_TO_CONTEXT_KEY
.
iteritems
():
...
...
@@ -148,6 +151,16 @@ class TrackMiddleware(object):
except
AttributeError
:
return
''
def
get_ionisx_user_id
(
self
,
request
):
"""Gets the user id stored in the IONISx social auth"""
try
:
social_auth
=
social_models
.
DjangoStorage
.
user
.
get_social_auth_for_user
(
request
.
user
)
if
len
(
social_auth
)
==
1
:
return
social_auth
[
0
]
.
uid
return
''
except
AttributeError
:
return
''
def
get_username
(
self
,
request
):
"""Gets the username of the logged in Django user"""
try
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment