Skip to content

Latest commit

 

History

History
 
 

redux

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Usage with Redux

1. Add dependencies

npm install airbrake-js redux-airbrake --save

2. Import dependency

import AirbrakeClient from 'airbrake-js';
import airbrakeMiddleware from 'redux-airbrake';

3. Configure & add middleware

const airbrake = new AirbrakeClient({
    projectId: '******',
    projectKey: '**************'
});

const errorMiddleware = airbrakeMiddleware(airbrake);

export const store = createStore(
    rootReducer,
    applyMiddleware(
        errorMiddleware
    )
);

export default store;

Adding notice annotations (optional)

It's possible to annotate error notices with all sorts of useful information at the time they're captured by supplying it in the object being reported.

const errorMiddleware = airbrakeMiddleware(airbrake, {
    noticeAnnotations: { context: { environment: window.ENV } }
});

Adding filters

Since an Airbrake instrace is passed to the middleware, you can simply add filters to the instance as described here:

https://github.com/airbrake/airbrake-js#filtering-errors

For full documentation, visit redux-airbrake on GitHub.