2018-05-24 15:36:17 +00:00
|
|
|
export default tracker => ({ getState }) => next => action => {
|
|
|
|
next(action)
|
|
|
|
const newState = getState()
|
|
|
|
if (action.type == 'STEP_ACTION' && action.name == 'fold') {
|
|
|
|
tracker.push([
|
|
|
|
'trackEvent',
|
|
|
|
'answer:' + action.source,
|
|
|
|
action.step,
|
|
|
|
newState.situationGate(action.step)
|
|
|
|
])
|
|
|
|
|
|
|
|
if (!newState.currentQuestion) {
|
|
|
|
tracker.push([
|
|
|
|
'trackEvent',
|
|
|
|
'done',
|
2018-06-01 15:53:07 +00:00
|
|
|
'after ' + newState.foldedSteps.length + ' questions'
|
2018-05-24 15:36:17 +00:00
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action.type === 'SET_ACTIVE_TARGET_INPUT') {
|
|
|
|
tracker.push(['trackEvent', 'select', newState.activeTargetInput])
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === 'START_CONVERSATION') {
|
|
|
|
tracker.push([
|
|
|
|
'trackEvent',
|
|
|
|
'refine',
|
|
|
|
newState.activeTargetInput,
|
|
|
|
newState.situationGate(newState.activeTargetInput)
|
|
|
|
])
|
|
|
|
}
|
|
|
|
if (action.type == 'STEP_ACTION' && action.name == 'unfold') {
|
|
|
|
tracker.push(['trackEvent', 'unfold', action.step])
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === 'RESET_SIMULATION') {
|
|
|
|
tracker.push(['trackEvent', 'restart', ''])
|
|
|
|
}
|
|
|
|
if (action.type === 'USER_INPUT_UPDATE') {
|
|
|
|
tracker.push(['trackEvent', 'input', action.meta.field, action.payload])
|
|
|
|
}
|
|
|
|
if (action.type === 'LOAD_PREVIOUS_SIMULATION') {
|
|
|
|
tracker.push(['trackEvent', 'loadPreviousSimulation'])
|
|
|
|
}
|
|
|
|
}
|