Commit b61f6bde by Aamir

Merge pull request #9581 from edx/aamir-khan/ECOM-2150-ga-client-missing-in-request

ECOM-2150: Added the ga client fetching as a customer header in middl…
parents 4234ff59 282b9449
......@@ -145,7 +145,7 @@ class TrackMiddleware(object):
# this: _ga=GA1.2.1033501218.1368477899. The clientId is this part: 1033501218.1368477899.
google_analytics_cookie = request.COOKIES.get('_ga')
if google_analytics_cookie is None:
context['client_id'] = None
context['client_id'] = request.META.get('HTTP_X_EDX_GA_CLIENT_ID')
else:
context['client_id'] = '.'.join(google_analytics_cookie.split('.')[2:])
......
......@@ -136,12 +136,16 @@ class TrackMiddlewareTestCase(TestCase):
def test_request_headers(self):
ip_address = '10.0.0.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')
context = self.get_context_for_request(request)
self.assert_dict_subset(context, {
'ip': ip_address,
'agent': user_agent,
'client_id': client_id_header
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment