vidit-sh/redux-sentry-middleware

Never accept notifications from sentry.

Closed this issue · 0 comments

Sentry.configureScope(scope => {
scope.addEventProcessor((event, hint) => {
const state = store.getState();
event.extra = {
...event.extra,
lastAction: actionTransformer(lastAction),
state: stateTransformer(state)
};
if (getUserContext) {
event.user = { ...event.user, ...getUserContext(state) };
}
if (getTags) {
const tags = getTags(state);
Object.keys(tags).forEach(key => {
scope.tags = { ...scope.tags, [key]: tags[key] };
});
}
return event;
});
});

The event processor created when creating redux sentry middleware has never been executed.

Do I need to configure some other things or Upgrade Redux?

https://github.com/getsentry/sentry-javascript/blob/1fb4808e69dd272c951c86fa90570c04ccfbad6b/packages/hub/src/scope.ts#L68-L81

I don't know if it is this reason:
if the last processor return null, it will not to be executed.

And why not to manage scope in middleware?

function createSentryMiddleware(hub, options = {}) {
  const {
    breadcrumbDataFromAction = identity,
    actionTransformer = identity,
    stateTransformer = identity,
    breadcrumbCategory = 'redux-action',
    filterBreadcrumbActions = filter,
    getUserContext,
    getTags,
  } = options;

  return store => {
    let lastAction;

    return next => action => {
      Sentry.configureScope(scope => {
        const state = store.getState();
        scope.setExtra('state', stateTransformer(state));
        scope.setExtra('lastAction', actionTransformer(lastAction));
        if (getUserContext) {
          scope.setUser({
            ...scope.user,
            ...getUserContext(state),
          });
        }
        if (getTags) {
          Object.entries(getTags(state)).forEach(item => {
            scope.setTag(...item);
          });
        }
      });
      if (filterBreadcrumbActions(action)) {
        Sentry.addBreadcrumb({
          category: breadcrumbCategory,
          message: action.type,
          level: 'info',
          data: breadcrumbDataFromAction(action),
        });
      }

      lastAction = action;
      return next(action);
    };
  };
}

Version Info:

  • Redux: 3.7.2
  • redux-sentry-middleware: 0.0.12
  • @sentry/browser: 4.4.2