import hashHistory from 'react-router/lib/hashHistory';
import { routerMiddleware } from 'react-router-redux';
import Raven from 'raven-js';
import createRavenMiddleware from 'raven-for-redux';
import thunkMiddleware from 'redux-thunk';
import promiseMiddleware from 'redux-simple-promise';
import { createStore, applyMiddleware, compose } from 'redux';
import { errorReportingMiddleware } from './lib/reduxHelpers';
import getRootReducer from './reducers/root';
import { isDevMode } from './config';

const reduxRouterMiddleware = routerMiddleware(hashHistory);

const middlewares = [
  promiseMiddleware(),
  reduxRouterMiddleware,
  thunkMiddleware,
  errorReportingMiddleware,
];

function configDevelopmentStore(appName) {
  return createStore(getRootReducer(appName), {}, compose(
    applyMiddleware(
      promiseMiddleware(),
      reduxRouterMiddleware,
      thunkMiddleware,
      // errorReportingMiddleware,
      createRavenMiddleware(Raven, {
        breadcrumbDataFromAction: action => (
          { STRING: action.str }
        ),
      }),
    ),
    window.devToolsExtension ? window.devToolsExtension() : f => f
  ));
}

function configProductionStore(appName) {
  return createStore(getRootReducer(appName), {}, compose(
    applyMiddleware(...middlewares,
      createRavenMiddleware(Raven),
    ),
  ));
}

let store;   // singleton store

// acts as a singleton factory method
function getStore(appName) {
  if (store === undefined) {
    store = (isDevMode()) ? configDevelopmentStore(appName) : configProductionStore(appName);
  }
  return store;
}

export default getStore;

@@ -884,180 +884,8 @@
 re,%0A
-      // errorReportingMiddleware,%0A      createRavenMiddleware(Raven, %7B%0A        breadcrumbDataFromAction: action =%3E (%0A          %7B STRING: action.str %7D%0A        ),%0A      %7D),%0A
     
@@ -1133,16 +1133,117 @@
 re(Raven
+, %7B%0A        breadcrumbDataFromAction: action =%3E (%0A          %7B STRING: action.str %7D%0A        ),%0A      %7D
 ),%0A    )

Move sentry logging to production mode #954