From a77b18fd6036faa9796e32c3665255b9fa1a38bd Mon Sep 17 00:00:00 2001 From: Laurent Bossavit Date: Thu, 3 May 2018 14:45:35 +0200 Subject: [PATCH] =?UTF-8?q?:chart=5Fwith=5Fupwards=5Ftrend:=20Am=C3=A9lior?= =?UTF-8?q?e=20le=20tracking=20des=20saisies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/debounceFormChangeActions.js | 2 +- source/entry-colour-chooser.js | 12 +++++------ source/entry.dev.js | 8 ++++---- source/reducers/reduceSteps.js | 32 ++++++++++++++--------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/source/debounceFormChangeActions.js b/source/debounceFormChangeActions.js index 2074ba33f..5f12ce6cc 100644 --- a/source/debounceFormChangeActions.js +++ b/source/debounceFormChangeActions.js @@ -26,7 +26,7 @@ export default () => { dispatch(action) return new Promise(resolve => { timers[key] = setTimeout(() => { - resolve(dispatch({ type: 'USER_INPUT_UPDATE' })) + resolve(dispatch({ ...action, type: 'USER_INPUT_UPDATE' })) }, time) }) } diff --git a/source/entry-colour-chooser.js b/source/entry-colour-chooser.js index 1374eae65..cbc30dea3 100644 --- a/source/entry-colour-chooser.js +++ b/source/entry-colour-chooser.js @@ -8,12 +8,11 @@ import reducers from './reducers/reducers' import { changeThemeColour } from './actions' import Layout from './containers/Layout' import { SliderPicker } from 'react-color' -import { rules, rulesFr } from 'Engine/rules' -import lang from './i18n' +import { rulesFr } from 'Engine/rules' let tracker = { push: () => {}, - connectToHistory: () => {} + connectToHistory: history => history } let store = createStore(reducers(tracker, rulesFr)) @@ -30,7 +29,7 @@ class MyComponent extends React.Component { return (

- Visualisez sur cette page l'apparence du module pour différentes + Visualisez sur cette page l’apparence du module pour différentes couleurs principales.

- La couleur sélectionnée, à déclarer comme attribut "data-couleur" du - script sur votre page est : {this.props.couleur} + La couleur sélectionnée, à déclarer comme attribut + "data-couleur" du script sur votre page est :{' '} + {this.props.couleur}

diff --git a/source/entry.dev.js b/source/entry.dev.js index c03d39b0f..e6a5248a4 100644 --- a/source/entry.dev.js +++ b/source/entry.dev.js @@ -2,9 +2,9 @@ import React from 'react' import { render } from 'react-dom' import { compose, createStore, applyMiddleware } from 'redux' import reducers from './reducers/reducers' -import DevTools from '../DevTools' +import DevTools from './DevTools' import { Provider } from 'react-redux' -import Layout from './Layout' +import Layout from './containers/Layout' import { AppContainer } from 'react-hot-loader' import debounceFormChangeActions from './debounceFormChangeActions' import computeThemeColours from './components/themeColours' @@ -25,7 +25,7 @@ let enhancer = compose( let tracker = { push: console.log, - connectToHistory: () => {} + connectToHistory: (history) => history } let initialRules = lang == 'en' ? rules : rulesFr @@ -35,7 +35,7 @@ let anchor = document.querySelector('#js') let App = ({ store }) => (
- +
diff --git a/source/reducers/reduceSteps.js b/source/reducers/reduceSteps.js index c7d620069..a3ebe952e 100644 --- a/source/reducers/reduceSteps.js +++ b/source/reducers/reduceSteps.js @@ -1,4 +1,4 @@ -import { path, head, reject, concat, without, length, map } from 'ramda' +import { path, head, concat, without, length, map } from 'ramda' import { rules, collectDefaults, rulesFr } from 'Engine/rules' import { @@ -46,13 +46,12 @@ 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', userInput(state)]) + tracker.push([ + 'trackEvent', + 'input', + action.meta.field + ':' + action.payload + ]) return { ...state, analysis, @@ -87,17 +86,20 @@ export default (tracker, flatRules, answerSource) => (state, action) => { } if (action.type === 'START_CONVERSATION') { - tracker.push(['trackEvent', 'refine', userInput(state)]) + tracker.push([ + 'trackEvent', + 'refine', + state.activeTargetInput + + ':' + + answerSource(state)(state.activeTargetInput) + ]) } - 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) + 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 @@ -126,9 +128,7 @@ export default (tracker, flatRules, answerSource) => (state, action) => { ), initialAnalysis = analyseMany(state.parsedRules, state.targetNames)( name => - qualifiedTargets.includes(name) - ? answerSource(state)(name) - : null + qualifiedTargets.includes(name) ? answerSource(state)(name) : null ), initialMissingVariablesByTarget = collectMissingVariablesByTarget( initialAnalysis.targets