const addPiwik = function(history) { if (shouldEnableTracking() && getTracker()) { let trackerInstance = getTracker() history = trackerInstance.connectToHistory(history) // when using a hash history, the initial visit is not tracked by piwik react router trackerInstance.track(history.location) } return history }
export const setupHistory = () => { const piwikEnabled = shouldEnableTracking() && getTracker() let history = hashHistory if (piwikEnabled) { const trackerInstance = getTracker() history = trackerInstance.connectToHistory(history) trackerInstance.track(history.getCurrentLocation()) // when using a hash history, the initial visit is not tracked by piwik react router } return history }
const configureStore = (cozyClient, persistedState) => { // Enable Redux dev tools const composeEnhancers = (__DEVELOPMENT__ && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose // reducers const reducers = [appReducers, persistedState] // middlewares const middlewares = [thunkMiddleware, cozyMiddleware(cozyClient)] if (shouldEnableTracking() && getTracker()) { middlewares.push(createTrackerMiddleware()) } if (flag('logs') && __DEVELOPMENT__) { // eslint-disable-line // must be the last middleware in chain https://git.io/vHQpt const loggerMiddleware = createLogger() middlewares.push(loggerMiddleware) } if (isReporterEnabled()) { middlewares.push(getReporterMiddleware()) } const store = createStore( ...reducers, composeEnhancers(applyMiddleware.apply(null, middlewares)) ) cozyClient.attachStore(store) return store }