📈 Améliorer le tracking

pull/215/head
Laurent Bossavit 2018-05-03 10:27:26 +02:00
parent b9dfd6f558
commit cffce11401
1 changed files with 29 additions and 22 deletions

View File

@ -36,8 +36,7 @@ export default (tracker, flatRules, answerSource) => (state, action) => {
)
return state
if (path(['form', 'conversation', 'syncErrors'], state))
return state
if (path(['form', 'conversation', 'syncErrors'], state)) return state
// Most rules have default values
let rulesDefaults = collectDefaults(flatRules),
@ -47,13 +46,18 @@ export default (tracker, flatRules, answerSource) => (state, action) => {
situationWithDefaults(state)
)
let userInput = state =>
state.activeTargetInput +
':' +
answerSource(state)(state.activeTargetInput)
if (action.type === 'USER_INPUT_UPDATE') {
tracker.push([
'trackEvent',
'input:' + state.activeTargetInput,
answerSource(state)(state.activeTargetInput)
])
return { ...state, analysis, situationGate: situationWithDefaults(state) }
tracker.push(['trackEvent', 'input', userInput(state)])
return {
...state,
analysis,
situationGate: situationWithDefaults(state)
}
}
let nextStepsAnalysis = analyseMany(state.parsedRules, state.targetNames)(
@ -79,25 +83,22 @@ export default (tracker, flatRules, answerSource) => (state, action) => {
}
if (action.type === 'SET_ACTIVE_TARGET_INPUT') {
tracker.push([
'trackEvent',
'select',
state.activeTargetInput
])
tracker.push(['trackEvent', 'select', state.activeTargetInput])
}
if (action.type === 'START_CONVERSATION') {
tracker.push([
'trackEvent',
'refine',
''
])
debugger
tracker.push(['trackEvent', 'refine', userInput(state)])
}
if (['SET_ACTIVE_TARGET_INPUT','START_CONVERSATION'].includes(action.type)) {
if (
['SET_ACTIVE_TARGET_INPUT', 'START_CONVERSATION'].includes(action.type)
) {
// Si rien n'a été renseigné (stillBlank) on renvoie state et pas newState
// pour éviter que les cases blanches disparaissent, c'est un hack…
let stillBlank = state.activeTargetInput && !answerSource(state)(state.activeTargetInput)
let stillBlank =
state.activeTargetInput &&
!answerSource(state)(state.activeTargetInput)
// Il faut recalculer les missingVariablesByTarget à chaque changement d'objectif
// car les variables manquantes du salaire de base calculé par inversion dépendent
@ -120,9 +121,15 @@ export default (tracker, flatRules, answerSource) => (state, action) => {
// TODO - corriger ce bug correctement avec des tests auto
// TODO - utiliser le nom qualifié dans analyseMany et qualifier les targetNames
let qualifiedTargets = map(x => "contrat salarié . "+x, state.targetNames),
let qualifiedTargets = map(
x => 'contrat salarié . ' + x,
state.targetNames
),
initialAnalysis = analyseMany(state.parsedRules, state.targetNames)(
name => qualifiedTargets.includes(name) ? answerSource(state)(name) : null
name =>
qualifiedTargets.includes(name)
? answerSource(state)(name)
: null
),
initialMissingVariablesByTarget = collectMissingVariablesByTarget(
initialAnalysis.targets