import 'core-js/fn/object/values' // shim Object.values for Chromium<54
import { createStore, applyMiddleware, compose, combineReducers } from 'redux'
import { createEpicMiddleware, combineEpics } from 'redux-observable'
import Raven from 'raven-js'
import createRavenMiddleware from 'raven-for-redux'
import thunk from 'redux-thunk'

import overview from 'src/overview'
import { reducer as onboarding } from 'src/overview/onboarding'
import { reducer as filters } from 'src/overview/filters'

const rootReducer = combineReducers({
    overview: overview.reducer,
    onboarding,
    filters,
})

const rootEpic = combineEpics(...Object.values(overview.epics))

export default function configureStore({ ReduxDevTools = undefined } = {}) {
    const middlewares = [createEpicMiddleware(rootEpic), thunk]

    // Set up the sentry runtime error config + redux middleware
    if (process.env.SENTRY_DSN) {
        Raven.config(process.env.SENTRY_DSN).install()
        middlewares.push(createRavenMiddleware(Raven))
    }

    const enhancers = [overview.enhancer, applyMiddleware(...middlewares)]
    if (ReduxDevTools) {
        enhancers.push(ReduxDevTools.instrument())
    }
    const enhancer = compose(...enhancers)

    const store = createStore(
        rootReducer,
        undefined, // initial state
        enhancer,
    )

    return store
}

@@ -655,16 +655,552 @@
 pics))%0A%0A
+/**%0A * Used to transform the redux state before sending to raven, filtering out%0A * anything we don't need to know.%0A */%0Aconst stateTransformer = (%7B overview, ...state %7D) =%3E (%7B%0A    ...state,%0A    overview: %7B%0A        ...overview,%0A        searchResult: %7B%0A            ...overview.searchResult,%0A            // Filter out personal stuff from results; not really useful for our knowledge%0A            docs: overview.searchResult.docs.map(%0A                (%7B url, title, favIcon, screenshot, ...doc %7D) =%3E doc,%0A            ),%0A        %7D,%0A    %7D,%0A%7D)%0A%0A
 export d
@@ -1539,16 +1539,38 @@
 re(Raven
+, %7B stateTransformer %7D
 ))%0A    %7D

Add filter to remove parts for sentry-recorded UI state