1.4.1 • Published 7 years ago

redux-sentry v1.4.1

Weekly downloads
25
License
MIT
Repository
github
Last release
7 years ago

Redux sentry

Includes middleware that logs all your store and actions on exception to Sentry with raven-js

Table of Contents

Installation

Install redux-sentry package from npm:

npm i --save redux-sentry

Usage

redux-sentry can be used in cases:

  • Raven has been initialized before
/* store.js */

import { SENTRY_SETTINGS, VERSION } from './constants';

import { createStore, applyMiddleware, compose, combineReducers } from 'redux';

import createSentryMiddleware from 'redux-sentry';

const sentryMiddleware = createSentryMiddleware();

// Add sentry middleware to your list of middlewares
const middlewares = [ sentryMiddleware ];

// Enhance your store by using sentry's enhancer
const toEnhance = [
    applyMiddleware(...middlewares)
];

// Put it all together
const enhancer = compose(...toEnhance);
const reducers = combineReducers({
    // combined reducers
});

const initialState = {}

const store = createStore(reducers, initialState, enhancer);

export default store;
  • Raven hasn't been initialized. It should be configured by params
/* store.js */

import { SENTRY_SETTINGS, VERSION } from './constants';

import { createStore, applyMiddleware, compose, combineReducers } from 'redux';

import createSentryMiddleware from 'redux-sentry';

const sentryMiddleware = createSentryMiddleware({
    dsn: SENTRY_SETTINGS.DSN,
    configuration: {
        release: VERSION,
        collectWindowErrors: true
    },
    username: parse(document.cookie).login
});

// Add sentry middleware to your list of middlewares
const middlewares = [ sentryMiddleware ];

// Enhance your store by using sentry's enhancer
const toEnhance = [
    applyMiddleware(...middlewares)
];

// Put it all together
const enhancer = compose(...toEnhance);
const reducers = combineReducers({
    // combined reducers
});

const initialState = {}

const store = createStore(reducers, initialState, enhancer);

export default store;

API

createSentryMiddleware({ dsn, configuration = {}, username }, transform = {})

import createSentryMiddleware from 'redux-sentry';

Middleware that logs all your store and actions on exception to Sentry with raven-js

dsn {String}

DSNData Source Name. Unique name generated for the project by you Sentry.

configuration {Object} optional

Raven configuration object. Full list of keys can be found here.

username {String} optional

Default: Guest username used for setting user context.

Raven.setUserContext({ username });

transform {Object} optional

Default:

{
    actionTransform: a => a,
    stateTransform: a => a.toJS()
}

Functions used for cooking action object, store for Raven's extra field. stateTransform uses toJS from immutable.js to convert state back to raw JavaScript object.

Contributing

  • Provide conventional commit messages by using npm run commit instead of git commit.
  • Core contributors: use GitHub's Rebase and merge as a default way of merging PRs.

License

MIT © AuRu

1.4.1

7 years ago

1.4.0

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago