import { createStore, applyMiddleware } from 'redux';
import { routerMiddleware } from 'react-router-redux';
import { createTracker } from 'redux-segment';
import { composeWithDevTools } from 'redux-devtools-extension';

import reducer from './controllers/reducers/';

export default function setupStore(history) {
  const middleware = [
    routerMiddleware(history),
    createTracker(),
  ];

  let store;

  if (process.env.NODE_ENV === 'development') {
    const enhancer = composeWithDevTools(applyMiddleware(...middleware));
    store = createStore(reducer, enhancer);
  } else {
    store = applyMiddleware(...middleware)(createStore)(reducer);
  }

  if (module.hot) {
    module.hot.accept('./controllers/reducers', () => {
      const nextRootReducer = require('./controllers/reducers').default;
      store.replaceReducer(nextRootReducer);
    });
  }

  return store;
}

@@ -310,20 +310,18 @@
 ry) %7B%0A  
-cons
+le
 t middle
@@ -364,29 +364,8 @@
 y),%0A
-    createTracker(),%0A
   %5D;
@@ -557,16 +557,67 @@
  else %7B%0A
+    middleware = %5B...middleware, createTracker()%5D;%0A
     stor

disable tracker in dev