Closed pke closed 7 years ago
Interesting! You could shoe-horn this functionality into raven-for-redux
by putting your logic in breadcrumbDataFromAction
, since that function gets called for every action. However, that's pretty gross.
const breadcrumbDataFromAction = (action) => {
if (action.error === true) {
Raven.captureException(action.payload, {
extra: action.meta
});
}
};
const store = createStore(
reducer,
applyMiddleware(
createRavenMiddleware(Raven, {
breadcrumbDataFromAction
})
)
);
Or, you could just write it as its own middleware and it would be nearly as simple:
const fsaMiddleware = (store) => (next) => (action) => {
if (action.error === true) {
Raven.captureException(action.payload, {
extra: action.meta
});
}
return next(action);
};
const store = createStore(
reducer,
applyMiddleware(
createRavenMiddleware(Raven),
fsaMiddleware
)
);
I don't think this makes sense to be in raven-for-redux
as a core feature, since FSA, is just a subset of Redux usage. That being said, it might be nice to offer this via something like import createFsaRavenMiddleware from 'raven-for-redux/fsa';
.
Can you think of other common patterns/feature that FSA/Raven users might want?
Yeah I thought about just writing my own little middleware for that. I have no other common patterns in mind at the moment.
I haven't used FSA before. Is it common to do error handling inside the reducer? If so, reporting all action errors may not really be the right thing anyway.
How about the middleware to catch FSA with
error === true
automatically. Whenever it sees a FSA with theerror
key set totrue
it could report the error.