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
282b9449
Commit
282b9449
authored
Sep 02, 2015
by
aamir-khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ECOM-2150: Added the ga client fetching as a customer header in middleware
parent
d17bff1c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
common/djangoapps/track/middleware.py
+1
-1
common/djangoapps/track/tests/test_middleware.py
+5
-1
No files found.
common/djangoapps/track/middleware.py
View file @
282b9449
...
@@ -145,7 +145,7 @@ class TrackMiddleware(object):
...
@@ -145,7 +145,7 @@ class TrackMiddleware(object):
# this: _ga=GA1.2.1033501218.1368477899. The clientId is this part: 1033501218.1368477899.
# this: _ga=GA1.2.1033501218.1368477899. The clientId is this part: 1033501218.1368477899.
google_analytics_cookie
=
request
.
COOKIES
.
get
(
'_ga'
)
google_analytics_cookie
=
request
.
COOKIES
.
get
(
'_ga'
)
if
google_analytics_cookie
is
None
:
if
google_analytics_cookie
is
None
:
context
[
'client_id'
]
=
None
context
[
'client_id'
]
=
request
.
META
.
get
(
'HTTP_X_EDX_GA_CLIENT_ID'
)
else
:
else
:
context
[
'client_id'
]
=
'.'
.
join
(
google_analytics_cookie
.
split
(
'.'
)[
2
:])
context
[
'client_id'
]
=
'.'
.
join
(
google_analytics_cookie
.
split
(
'.'
)[
2
:])
...
...
common/djangoapps/track/tests/test_middleware.py
View file @
282b9449
...
@@ -136,12 +136,16 @@ class TrackMiddlewareTestCase(TestCase):
...
@@ -136,12 +136,16 @@ class TrackMiddlewareTestCase(TestCase):
def
test_request_headers
(
self
):
def
test_request_headers
(
self
):
ip_address
=
'10.0.0.0'
ip_address
=
'10.0.0.0'
user_agent
=
'UnitTest/1.0'
user_agent
=
'UnitTest/1.0'
client_id_header
=
'123.123'
factory
=
RequestFactory
(
REMOTE_ADDR
=
ip_address
,
HTTP_USER_AGENT
=
user_agent
)
factory
=
RequestFactory
(
REMOTE_ADDR
=
ip_address
,
HTTP_USER_AGENT
=
user_agent
,
HTTP_X_EDX_GA_CLIENT_ID
=
client_id_header
)
request
=
factory
.
get
(
'/some-path'
)
request
=
factory
.
get
(
'/some-path'
)
context
=
self
.
get_context_for_request
(
request
)
context
=
self
.
get_context_for_request
(
request
)
self
.
assert_dict_subset
(
context
,
{
self
.
assert_dict_subset
(
context
,
{
'ip'
:
ip_address
,
'ip'
:
ip_address
,
'agent'
:
user_agent
,
'agent'
:
user_agent
,
'client_id'
:
client_id_header
})
})
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