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
a7042ca3
Commit
a7042ca3
authored
Dec 22, 2014
by
Fred Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6319 from edx/hotfix/analytics-mobile-shim
Update segment.io shim for mobile event syntax change.
parents
dbc6166f
ad7a67da
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
common/djangoapps/track/views/segmentio.py
+10
-1
common/djangoapps/track/views/tests/test_segmentio.py
+15
-1
No files found.
common/djangoapps/track/views/segmentio.py
View file @
a7042ca3
...
...
@@ -157,6 +157,15 @@ def track_segmentio_event(request): # pylint: disable=too-many-statements
):
raise
EventValidationError
(
WARNING_IGNORED_TYPE
)
# create and populate application field if it doesn't exist
app_context
=
segment_properties
.
get
(
'context'
,
{})
if
'application'
not
in
app_context
:
context
[
'application'
]
=
{
'name'
:
app_context
.
get
(
'app_name'
,
''
),
'version'
:
''
if
not
segment_context
else
segment_context
.
get
(
'app'
,
{})
.
get
(
'version'
,
''
)
}
app_context
.
pop
(
'app_name'
,
None
)
if
segment_context
:
# copy the entire segment's context dict as a sub-field of our custom context dict
context
[
'client'
]
=
dict
(
segment_context
)
...
...
@@ -168,7 +177,7 @@ def track_segmentio_event(request): # pylint: disable=too-many-statements
del
context
[
'client'
][
field
]
# Overlay any context provided in the properties
context
.
update
(
segment_properties
.
get
(
'context'
,
{})
)
context
.
update
(
app_context
)
user_id
=
full_segment_event
.
get
(
'userId'
)
if
not
user_id
:
...
...
common/djangoapps/track/views/tests/test_segmentio.py
View file @
a7042ca3
...
...
@@ -122,6 +122,7 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
'data'
:
kwargs
.
get
(
'data'
,
{}),
'context'
:
{
'course_id'
:
kwargs
.
get
(
'course_id'
)
or
''
,
'app_name'
:
'edx.mobile.android'
,
}
},
"channel"
:
'server'
,
...
...
@@ -130,6 +131,9 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
"name"
:
kwargs
.
get
(
'library_name'
,
'test-app'
),
"version"
:
"unknown"
},
"app"
:
{
"version"
:
"1.0.1"
,
},
'userAgent'
:
str
(
sentinel
.
user_agent
),
},
"receivedAt"
:
"2014-08-27T16:33:39.100Z"
,
...
...
@@ -197,6 +201,10 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
'time'
:
datetime
.
strptime
(
"2014-08-27T16:33:39.215Z"
,
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
fZ"
),
'host'
:
'testserver'
,
'context'
:
{
'application'
:
{
'name'
:
'edx.mobile.android'
,
'version'
:
'1.0.1'
,
},
'user_id'
:
USER_ID
,
'course_id'
:
course_id
,
'org_id'
:
'foo'
,
...
...
@@ -205,7 +213,10 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
'library'
:
{
'name'
:
'test-app'
,
'version'
:
'unknown'
}
},
'app'
:
{
'version'
:
'1.0.1'
,
},
},
'received_at'
:
datetime
.
strptime
(
"2014-08-27T16:33:39.100Z"
,
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
fZ"
),
},
...
...
@@ -361,6 +372,9 @@ class SegmentIOTrackingTestCase(EventTrackingTestCase):
'name'
:
'test-app'
,
'version'
:
'unknown'
},
'app'
:
{
'version'
:
'1.0.1'
,
},
},
'application'
:
{
'name'
:
'edx.mobileapp.android'
,
...
...
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