"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

const getErrorBundle = ({
  logger,
  recentActionsToTrack = 20
}) => ({
  name: 'errorBundle',
  getMiddleware: () => store => next => action => {
    const recentActions = store.meta.recentActions || (store.meta.recentActions = []);
    recentActions.push(action);

    if (recentActions.length > recentActionsToTrack) {
      recentActions.shift();
    }

    try {
      return next(action);
    } catch (error) {
      logger.error({
        error: {
          message: error.message,
          stack: error.stack
        },
        message: 'middlewareCaughtError',
        action
      });
    }
  }
});

var _default = getErrorBundle;
exports.default = _default;