Refactor Segment.io integration with sequentials and instructor dashboard pages
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user