import { get } from 'lodash';
import Raven from 'raven-js';

export default function createMessageMiddleware(actionToDispatch) {
  return store => next => action => {
    const success = action.success && get(action, ['meta', 'successMessage']);
    const error = action.error && get(action, ['meta', 'errorMessage']);
    if (!(success || error)) {
      return next(action);
    }
    let message;

    if (error) {
      Raven.captureException(action.payload);
      message = typeof error === 'function' ? error(action.error) : error;
    } else {
      message = success;
    }
    store.dispatch(actionToDispatch(message));
    return next(action);
  };
}

@@ -54,16 +54,106 @@
 n-js';%0A%0A
+const reportToSentry = action =%3E%0A  __CLIENT__ && Raven.captureException(action.payload);%0A%0A
 export d
@@ -505,54 +505,8 @@
 ) %7B%0A
-      Raven.captureException(action.payload);%0A
     
@@ -576,16 +576,46 @@
  error;%0A
+      reportToSentry(action);%0A
     %7D el

Fix sentry reporting in SSR