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
5ac92804
Commit
5ac92804
authored
Jul 02, 2013
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #315 from edx/renzo/segment-io-refactor
Renzo/segment io refactor
parents
9b0fa006
51f694b1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
26 deletions
+35
-26
common/lib/xmodule/xmodule/js/src/sequence/display.coffee
+27
-1
common/static/coffee/spec/logger_spec.coffee
+0
-10
common/static/coffee/src/logger.coffee
+1
-13
lms/static/coffee/src/instructor_dashboard_tracking.coffee
+4
-0
lms/templates/courseware/instructor_dashboard.html
+1
-1
lms/templates/widgets/segment-io.html
+2
-1
No files found.
common/lib/xmodule/xmodule/js/src/sequence/display.coffee
View file @
5ac92804
...
...
@@ -111,7 +111,15 @@ class @Sequence
if
(
1
<=
new_position
)
and
(
new_position
<=
@
num_contents
)
Logger
.
log
"seq_goto"
,
old
:
@
position
,
new
:
new_position
,
id
:
@
id
# On Sequence chage, destroy any existing polling thread
analytics
.
pageview
@
id
# navigation by clicking the tab directly
analytics
.
track
"Accessed Sequential Directly"
,
sequence_id
:
@
id
current_sequential
:
@
position
target_sequential
:
new_position
# On Sequence change, destroy any existing polling thread
# for queued submissions, see ../capa/display.coffee
if
window
.
queuePollerID
window
.
clearTimeout
(
window
.
queuePollerID
)
...
...
@@ -125,12 +133,30 @@ class @Sequence
event
.
preventDefault
()
new_position
=
@
position
+
1
Logger
.
log
"seq_next"
,
old
:
@
position
,
new
:
new_position
,
id
:
@
id
analytics
.
pageview
@
id
# navigation using the next arrow
analytics
.
track
"Accessed Next Sequential"
,
sequence_id
:
@
id
current_sequential
:
@
position
target_sequential
:
new_position
@
render
new_position
previous
:
(
event
)
=>
event
.
preventDefault
()
new_position
=
@
position
-
1
Logger
.
log
"seq_prev"
,
old
:
@
position
,
new
:
new_position
,
id
:
@
id
analytics
.
pageview
@
id
# navigation using the previous arrow
analytics
.
track
"Accessed Previous Sequential"
,
sequence_id
:
@
id
current_sequential
:
@
position
target_sequential
:
new_position
@
render
new_position
link_for
:
(
position
)
->
...
...
common/static/coffee/spec/logger_spec.coffee
View file @
5ac92804
...
...
@@ -3,16 +3,6 @@ describe 'Logger', ->
expect
(
window
.
log_event
).
toBe
Logger
.
log
describe
'log'
,
->
it
'sends an event to Segment.io, if the event is whitelisted and the data is not a dictionary'
,
->
spyOn
(
analytics
,
'track'
)
Logger
.
log
'seq_goto'
,
'data'
expect
(
analytics
.
track
).
toHaveBeenCalledWith
'seq_goto'
,
value
:
'data'
it
'sends an event to Segment.io, if the event is whitelisted and the data is a dictionary'
,
->
spyOn
(
analytics
,
'track'
)
Logger
.
log
'seq_goto'
,
value
:
'data'
expect
(
analytics
.
track
).
toHaveBeenCalledWith
'seq_goto'
,
value
:
'data'
it
'send a request to log event'
,
->
spyOn
$
,
'postWithPrefix'
Logger
.
log
'example'
,
'data'
...
...
common/static/coffee/src/logger.coffee
View file @
5ac92804
class
@
Logger
# events we want sent to Segment.io for tracking
SEGMENT_IO_WHITELIST
=
[
"seq_goto"
,
"seq_next"
,
"seq_prev"
,
"problem_check"
,
"problem_reset"
,
"problem_show"
,
"problem_save"
]
# listeners[event_type][element] -> list of callbacks
listeners
=
{}
@
log
:
(
event_type
,
data
,
element
=
null
)
->
# Segment.io event tracking
if
event_type
in
SEGMENT_IO_WHITELIST
# to avoid changing the format of data sent to our servers, we only massage it here
if
typeof
data
isnt
'object'
or
data
is
null
analytics
.
track
event_type
,
value
:
data
else
analytics
.
track
event_type
,
data
# Check to see if we're listening for the event type.
if
event_type
of
listeners
# Cool. Do the elements also match?
...
...
@@ -43,7 +32,6 @@ class @Logger
else
listeners
[
event_type
][
element
].
push
callback
@
bind
:
->
window
.
onunload
=
->
$
.
ajaxWithPrefix
...
...
@@ -54,5 +42,5 @@ class @Logger
page
:
window
.
location
.
href
async
:
false
# Keeping this for co
n
patibility issue only.
# Keeping this for co
m
patibility issue only.
@
log_event
=
Logger
.
log
lms/static/coffee/src/instructor_dashboard_tracking.coffee
0 → 100644
View file @
5ac92804
if
$
(
'.instructor-dashboard-wrapper'
).
length
==
1
analytics
.
track
"Loaded an Instructor Dashboard Page"
,
location
:
window
.
location
.
pathname
dashboard_page
:
$
(
'.navbar .selectedmode'
).
text
()
lms/templates/courseware/instructor_dashboard.html
View file @
5ac92804
...
...
@@ -104,7 +104,7 @@ function goto( mode)
<section
class=
"instructor-dashboard-content"
>
<h1>
Instructor Dashboard
</h1>
<h2>
[
<a
href=
"#"
onclick=
"goto('Grades');"
class=
"${modeflag.get('Grades')}"
>
Grades
</a>
|
<h2
class=
"navbar"
>
[
<a
href=
"#"
onclick=
"goto('Grades');"
class=
"${modeflag.get('Grades')}"
>
Grades
</a>
|
%if settings.MITX_FEATURES.get('ENABLE_PSYCHOMETRICS'):
<a
href=
"#"
onclick=
"goto('Psychometrics');"
class=
"${modeflag.get('Psychometrics')}"
>
Psychometrics
</a>
|
%endif
...
...
lms/templates/widgets/segment-io.html
View file @
5ac92804
...
...
@@ -17,7 +17,8 @@
<!-- dummy segment.io -->
<script
type=
"text/javascript"
>
var
analytics
=
{
track
:
function
()
{
return
;
}
track
:
function
()
{
return
;
},
pageview
:
function
()
{
return
;
}
};
</script>
<!-- end dummy segment.io -->
...
...
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