Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Usage with Redux

1. Add dependencies

npm install @airbrake/browser redux-airbrake --save

2. Import dependency

import { Notifier } from '@airbrake/browser';
import airbrakeMiddleware from 'redux-airbrake';

3. Configure & add middleware

const airbrake = new Notifier({
  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/tree/master/packages/browser#filtering-errors

For full documentation, visit redux-airbrake on GitHub.