diff --git a/common/djangoapps/track/segment.py b/common/djangoapps/track/segment.py index 9b2b1dbadab165afdfe4dd15cd810def6b5a6a0f..e1470a83f05df7b84a166acb08fe993e02b778a3 100644 --- a/common/djangoapps/track/segment.py +++ b/common/djangoapps/track/segment.py @@ -8,7 +8,7 @@ required by server-side events. To use, call "from track import segment", then call segment.track() or segment.identify(). """ -from urlparse import urljoin +from urlparse import urlunsplit import analytics from django.conf import settings @@ -39,10 +39,12 @@ def track(user_id, event_name, properties=None, context=None): page = tracking_context.get('page') if path and not page: - # Try to put together a url from host and path: + # Try to put together a url from host and path, hardcoding the schema. + # (Segment doesn't care about the schema for GA, but will extract the host and path from the url.) host = tracking_context.get('host') if host: - page = urljoin("//{host}".format(host=host), path) + parts = ("https", host, path, "", "") + page = urlunsplit(parts) if path is not None or referer is not None or page is not None: if 'page' not in segment_context: diff --git a/common/djangoapps/track/tests/test_segment.py b/common/djangoapps/track/tests/test_segment.py index aef0421269a2e4ff36527eb15837092f26470294..90f45a51782b90dd1cfe327167b39dd21a56bfbd 100644 --- a/common/djangoapps/track/tests/test_segment.py +++ b/common/djangoapps/track/tests/test_segment.py @@ -109,7 +109,7 @@ class SegmentTrackTestCase(TestCase): 'page': { 'path': '/this/is/a/path', 'referrer': sentinel.referer, - 'url': '//hostname/this/is/a/path' # Synthesized URL value. + 'url': 'https://hostname/this/is/a/path' # Synthesized URL value. } } self.assertEqual((sentinel.user_id, sentinel.name, self.properties, expected_segment_context), args) diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 8c8a5328b406a1907ad16bb96cf28f46c83a6f2d..d7c3bcdad5a0f7aeb6c83378d39addbf4a4c5228 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -133,7 +133,7 @@ edx-user-state-client==1.0.4 edxval==0.1.22 elasticsearch==1.9.0 # via edx-search enum34==1.1.6 -event-tracking==0.2.6 +event-tracking==0.2.7 feedparser==5.1.3 firebase-token-generator==1.3.2 fs-s3fs==0.1.8 diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index 4a9e263f7234f24bd049eb023b2bd1985acd8185..dcf4d6c50c338f20a0ab0e60a846ef89cddfd812 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -154,7 +154,7 @@ edx-user-state-client==1.0.4 edxval==0.1.22 elasticsearch==1.9.0 enum34==1.1.6 -event-tracking==0.2.6 +event-tracking==0.2.7 execnet==1.5.0 extras==1.0.0 factory_boy==2.8.1 diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index e514c6601614b9d6cc086a3731a028ff259da22c..2562e0f61eb565a4111d1cea3f8bc19eb14ee672 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -148,7 +148,7 @@ edx-user-state-client==1.0.4 edxval==0.1.22 elasticsearch==1.9.0 enum34==1.1.6 -event-tracking==0.2.6 +event-tracking==0.2.7 execnet==1.5.0 # via pytest-xdist extras==1.0.0 # via python-subunit, testtools factory_boy==2.8.1