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
07d50ba7
Commit
07d50ba7
authored
Nov 13, 2014
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MA-90 Update Analytics Shim to match new mobile requirements.
parent
a4fea913
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
14 deletions
+26
-14
common/djangoapps/track/shim.py
+2
-2
common/djangoapps/track/views/segmentio.py
+13
-2
common/djangoapps/track/views/tests/test_segmentio.py
+11
-10
No files found.
common/djangoapps/track/shim.py
View file @
07d50ba7
...
...
@@ -127,6 +127,6 @@ class VideoEventProcessor(object):
context
=
event
[
'context'
]
if
'
browser_page
'
in
context
:
page
,
_sep
,
_tail
=
context
.
pop
(
'
browser_page
'
)
.
rpartition
(
'/'
)
if
'
open_in_browser_url
'
in
context
:
page
,
_sep
,
_tail
=
context
.
pop
(
'
open_in_browser_url
'
)
.
rpartition
(
'/'
)
event
[
'page'
]
=
page
common/djangoapps/track/views/segmentio.py
View file @
07d50ba7
...
...
@@ -143,9 +143,20 @@ def track_segmentio_event(request): # pylint: disable=too-many-statements
raise
EventValidationError
(
WARNING_IGNORED_TYPE
)
if
segment_context
:
# copy required fields from segment's context dict to our custom context dict
for
context_field_name
,
segment_context_field_name
in
[
(
'course_id'
,
'course_id'
),
(
'open_in_browser_url'
,
'open_in_browser_url'
),
(
'agent'
,
'userAgent'
)
]:
if
segment_context_field_name
in
segment_context
:
context
[
context_field_name
]
=
segment_context
[
segment_context_field_name
]
# copy the entire segment's context dict as a sub-field of our custom context dict
context
[
'client'
]
=
dict
(
segment_context
)
context
[
'agent'
]
=
segment_context
.
get
(
'userAgent'
,
''
)
for
field
in
(
'traits'
,
'integrations'
,
'userAgent'
):
# remove duplicate and unnecessary fields from our copy
for
field
in
(
'traits'
,
'integrations'
,
'userAgent'
,
'course_id'
,
'open_in_browser_url'
):
if
field
in
context
[
'client'
]:
del
context
[
'client'
][
field
]
...
...
common/djangoapps/track/views/tests/test_segmentio.py
View file @
07d50ba7
...
...
@@ -114,9 +114,6 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
"properties"
:
{
'name'
:
kwargs
.
get
(
'name'
,
str
(
sentinel
.
name
)),
'data'
:
kwargs
.
get
(
'data'
,
{}),
'context'
:
{
'course_id'
:
kwargs
.
get
(
'course_id'
)
or
''
,
}
},
"channel"
:
'server'
,
"context"
:
{
...
...
@@ -125,6 +122,7 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
"version"
:
"unknown"
},
'userAgent'
:
str
(
sentinel
.
user_agent
),
'course_id'
:
kwargs
.
get
(
'course_id'
)
or
''
,
},
"receivedAt"
:
"2014-08-27T16:33:39.100Z"
,
"timestamp"
:
"2014-08-27T16:33:39.215Z"
,
...
...
@@ -141,7 +139,10 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
}
if
'context'
in
kwargs
:
sample_event
[
'properties'
][
'context'
]
.
update
(
kwargs
[
'context'
])
sample_event
[
'context'
]
.
update
(
kwargs
[
'context'
])
if
'open_in_browser_url'
in
kwargs
:
sample_event
[
'context'
][
'open_in_browser_url'
]
=
kwargs
[
'open_in_browser_url'
]
return
sample_event
...
...
@@ -304,9 +305,9 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
data
=
self
.
create_segmentio_event_json
(
name
=
name
,
data
=
input_payload
,
open_in_browser_url
=
'https://testserver/courses/foo/bar/baz/courseware/Week_1/Activity/2'
,
context
=
{
'course_id'
:
course_id
,
'browser_page'
:
'https://testserver/courses/foo/bar/baz/courseware/Week_1/Activity/2'
,
'application'
:
{
'name'
:
'edx.mobileapp.android'
,
'version'
:
'29'
,
...
...
@@ -342,14 +343,14 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
'library'
:
{
'name'
:
'test-app'
,
'version'
:
'unknown'
},
'application'
:
{
'name'
:
'edx.mobileapp.android'
,
'version'
:
'29'
,
'component'
:
'videoplayer'
}
},
'received_at'
:
datetime
.
strptime
(
"2014-08-27T16:33:39.100Z"
,
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
fZ"
),
'application'
:
{
'name'
:
'edx.mobileapp.android'
,
'version'
:
'29'
,
'component'
:
'videoplayer'
}
},
}
expected_payload
=
{
...
...
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