2020-04-13 08:24:13 +00:00
|
|
|
import { reduxBatch } from "@manaflair/redux-batch";
|
2019-12-23 12:16:33 +00:00
|
|
|
import { createStore, applyMiddleware } from "redux";
|
|
|
|
|
import {
|
|
|
|
|
useSelector as useReduxSelector,
|
|
|
|
|
TypedUseSelectorHook,
|
|
|
|
|
} from "react-redux";
|
|
|
|
|
import appReducer, { AppState } from "./reducers";
|
|
|
|
|
import createSagaMiddleware from "redux-saga";
|
2020-04-13 08:24:13 +00:00
|
|
|
import { rootSaga } from "sagas";
|
2019-12-23 12:16:33 +00:00
|
|
|
import { composeWithDevTools } from "redux-devtools-extension/logOnlyInProduction";
|
2020-08-28 11:31:07 +00:00
|
|
|
import * as Sentry from "@sentry/react";
|
2020-12-09 09:12:12 +00:00
|
|
|
import { ReduxActionTypes } from "constants/ReduxActionConstants";
|
2019-12-23 12:16:33 +00:00
|
|
|
|
|
|
|
|
const sagaMiddleware = createSagaMiddleware();
|
2020-08-28 11:31:07 +00:00
|
|
|
const sentryReduxEnhancer = Sentry.createReduxEnhancer({
|
2020-12-24 04:32:25 +00:00
|
|
|
actionTransformer: (action) => {
|
2020-12-09 09:12:12 +00:00
|
|
|
if (
|
|
|
|
|
action.type === ReduxActionTypes.SET_EVALUATED_TREE ||
|
|
|
|
|
action.type === ReduxActionTypes.EXECUTE_API_ACTION_SUCCESS
|
|
|
|
|
) {
|
|
|
|
|
// Return null to not log the action to Sentry
|
|
|
|
|
action.payload = null;
|
|
|
|
|
}
|
|
|
|
|
return action;
|
|
|
|
|
},
|
2020-08-28 11:31:07 +00:00
|
|
|
});
|
|
|
|
|
|
2019-12-23 12:16:33 +00:00
|
|
|
export default createStore(
|
|
|
|
|
appReducer,
|
2020-08-28 11:31:07 +00:00
|
|
|
composeWithDevTools(
|
|
|
|
|
reduxBatch,
|
|
|
|
|
applyMiddleware(sagaMiddleware),
|
|
|
|
|
reduxBatch,
|
|
|
|
|
sentryReduxEnhancer,
|
|
|
|
|
),
|
2019-12-23 12:16:33 +00:00
|
|
|
);
|
|
|
|
|
sagaMiddleware.run(rootSaga);
|
|
|
|
|
|
|
|
|
|
export const useSelector: TypedUseSelectorHook<AppState> = useReduxSelector;
|