Skip to content

Commit bdc34b2

Browse files
author
Sergio Daniel Xalambrí
committed
Update README.md
Add info about using it with Sentry
1 parent 17eb763 commit bdc34b2

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Diff for: README.md

+43
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,46 @@ const store = createStore(reducer, applyMiddleware(
2222
- `reduxCatch` receive a function to use when an error happen.
2323
- The error handler function could be just a `console.error` like the example above or a function to log the error in some kind of error tracking platform.
2424
- You should use this middleware as the first middleware in the chain, so its allowed to catch all the possible errors in the application.
25+
26+
### Using it with [Sentry](https://www.getsentry.com/)
27+
To use it with Sentry just download the Sentry script from npm:
28+
29+
```bash
30+
npm i -S raven-js raven-node
31+
```
32+
- [raven-js](https://www.npmjs.com/package/raven-js): This is the client for browser usage.
33+
- [raven-node](https://github.com/getsentry/raven-node): This is the client for server usage.
34+
35+
Now load and configure your client:
36+
37+
```javascript
38+
import Raven from 'raven-js';
39+
40+
const sentryKey = '<key>';
41+
42+
Raven
43+
.config(`https://${sentryKey}@app.getsentry.com/<project>`)
44+
.install();
45+
```
46+
47+
And then use `Raven.captureException` as the error handler like this:
48+
49+
```javascript
50+
const store = createStore(reducer, applyMiddleware(
51+
reduxCatch(Raven.captureException)
52+
));
53+
```
54+
55+
Now `redux-catch` will start to send the errors of your reducers and middlewares to Sentry.
56+
57+
#### Add state as extra data
58+
You can also add the state data as extra data for your errors so you can know the state at the moment of the error.
59+
60+
```javascript
61+
function errorHandler(error, getState) {
62+
Raven.context({
63+
state: getState(),
64+
});
65+
Raven.captureException(error);
66+
}
67+
```

0 commit comments

Comments
 (0)