redux-reporter
Redux middleware for reporting actions to third party APIs. This package is extremely useful for analytics and error handling. Can be used with various APIs such as New Relic, Sentry, Adobe DTM, Keen
Installation
npm install --save redux-reporter
Usage
General Reporting
Create your reporting middleware
// /middleware/myReporter.js; { try // report to external API catch err {} };
Attach meta data to your actions
// /actions/MyActions.js { let type = 'MY_ACTION'; return type meta: report: // default attribute that is selected by redux-reporter type payload: 'example payload' ;}
Configure store with your middleware
// /store/configureStore.js;;;; // import your reporter const isBrowser = typeof window !== 'undefined';const enhancer = ? window : f); { return ;}
Reporting to Multiple APIs: You can report to multiple APIs by configuring multiple middlewares and attaching additional attributes to your actions
// /actions/MyActions.js { let type = 'MY_ACTION'; return type meta: analytics: type payload: 'example payload' experiments: type payload: 'example payload' ;}
New Relic
Example w/error reporting
// /middleware/newrelic.js; const report = { try windownewrelic; catch err {}}; const crashReporter = ;const errorReporter = ; // /actions/MyActions.js { let type = 'MY_ERROR_ACTION'; return type error: true payload: 'My Handled Error' ;}
User behavior (New Relic browser/insights)
// /middleware/newrelic.js; const analyticsReporter = ; // /actions/MyActions.js { let type = 'MY_ACTION'; return type meta: analytics: type payload: 'example payload' ;}