Merge pull request #93 from sgmap/more-action-tracking

Suivi de nouvelles actions
pull/94/head
Laurent Bossavit 2017-10-13 12:12:14 +02:00 committed by GitHub
commit 733290be22
2 changed files with 12 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import './Simulateur.css'
import {capitalise0} from '../utils'
import Conversation from './conversation/Conversation'
import ReactPiwik from 'react-piwik';
let situationSelector = formValueSelector('conversation')
@ -62,6 +63,7 @@ export default class extends React.Component {
sim = path =>
R.path(R.unless(R.is(Array), R.of)(path))(this.rule.simulateur || {}),
reinitalise = () => {
ReactPiwik.push(['trackEvent', 'restart', '']);
this.props.resetForm(this.name)
this.props.startConversation(this.name)
},

View File

@ -62,15 +62,19 @@ export let reduceSteps = (state, action) => {
ReactPiwik.push(['trackEvent', 'answer', action.step+": "+situationGate(action.step)]);
let foldedSteps = [...state.foldedSteps, R.head(state.unfoldedSteps)],
unfoldedSteps = buildNextSteps(situationGate, flatRules, newState.analysedSituation)
unfoldedSteps = buildNextSteps(situationGate, flatRules, newState.analysedSituation),
assumptionsMade = !R.isEmpty(softAssumptions),
done = unfoldedSteps.length == 0
// The simulation is "over" - except we can now fill in extra questions
// where the answers were previously given default reasonable assumptions
if (unfoldedSteps.length == 0 && !R.isEmpty(softAssumptions)) {
if (done && assumptionsMade) {
let newSituation = intermediateSituation(state),
reanalyse = analyseTopDown(flatRules,rootVariable)(newSituation),
extraSteps = buildNextSteps(newSituation, flatRules, reanalyse)
ReactPiwik.push(['trackEvent', 'done', 'extra questions: '+extraSteps.length]);
return {
...newState,
foldedSteps,
@ -79,6 +83,10 @@ export let reduceSteps = (state, action) => {
}
}
if (done) {
ReactPiwik.push(['trackEvent', 'done', 'no more questions']);
}
return {
...newState,
foldedSteps,