Commit 2cd18dfa by Renzo Lucioni

Merge pull request #263 from edx/renzo/segment-io-whitelist-expansion

Add handful of events to the Segment.io whitelist
parents 38d7ddf0 3f49da38
......@@ -138,7 +138,8 @@ class @Problem
# maybe preferable to consolidate all dispatches to use FormData
###
check_fd: =>
Logger.log 'problem_check', @answers
# Calling check from check_fd will result in firing the 'problem_check' event twice, since it is also called in the check function.
#Logger.log 'problem_check', @answers
# If there are no file inputs in the problem, we can fall back on @check
if $('input:file').length == 0
......
......@@ -3,10 +3,15 @@ describe 'Logger', ->
expect(window.log_event).toBe Logger.log
describe 'log', ->
it 'sends an event to Segment.io, if the event is whitelisted', ->
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', '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 $, 'getWithPrefix'
......
class @Logger
# events we want sent to Segment.io for tracking
SEGMENT_IO_WHITELIST = ["seq_goto", "seq_next", "seq_prev"]
SEGMENT_IO_WHITELIST = ["seq_goto", "seq_next", "seq_prev", "problem_check", "problem_reset", "problem_show", "problem_save"]
@log: (event_type, data) ->
# Segment.io event tracking
if event_type in SEGMENT_IO_WHITELIST
# Segment.io event tracking
analytics.track event_type, data
# 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
$.getWithPrefix '/event',
event_type: event_type
......
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