All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.cjs.react-utils.HoneybadgerErrorBoundary.HoneybadgerErrorBoundary.js Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = require("@honeybadger-io/react");
var _constants = require("./constants");
var _FallbackComponent = _interopRequireDefault(require("./FallbackComponent"));
var _utils = require("./utils");
var _jsxRuntime = require("react/jsx-runtime");
/** @type {import("neetocommons/react-utils").HoneybadgerErrorBoundary} */var HoneybadgerErrorBoundary = function HoneybadgerErrorBoundary(_ref) {
  var children = _ref.children,
    _ref$ErrorComponent = _ref.ErrorComponent,
    ErrorComponent = _ref$ErrorComponent === void 0 ? _FallbackComponent["default"] : _ref$ErrorComponent,
    _ref$filterErrors = _ref.filterErrors,
    filterErrors = _ref$filterErrors === void 0 ? undefined : _ref$filterErrors;
  _react.Honeybadger.beforeNotify(function (notice) {
    var _globalProps$user;
    if (!notice) return false;
    var isIgnorable = _constants.IGNORABLE_ERRORS_REGEX.test(notice.message) || _constants.IGNORABLE_ERROR_NAMES_REGEX.test(notice.name) || notice.stack.includes("chrome-extension://") || (filterErrors === null || filterErrors === void 0 ? void 0 : filterErrors(notice)) === false;
    if (isIgnorable) return false;
    var context = {
      errorClass: notice.name
    };
    if (notice.name === "ChunkLoadError") {
      context.IGNORABLE_ERROR_NAMES_REGEX = _constants.IGNORABLE_ERROR_NAMES_REGEX;
      context.isChunkLoadError = _constants.IGNORABLE_ERROR_NAMES_REGEX.test(notice.name);
    }
    var user = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email;
    if (user) context.user = user;
    var sessionReplay = (0, _utils.getSessionReplayUrl)();
    if (sessionReplay) context.sessionReplay = sessionReplay;
    (0, _utils.attachContext)(notice, context);
    return true;
  });
  var honeybadger = _react.Honeybadger.configure({
    apiKey: globalProps.honeybadgerApiKey,
    environment: globalProps.railsEnv,
    revision: globalProps.honeybadgerRevision,
    developmentEnvironments: ["development", "test"],
    enableUncaught: true,
    async: true,
    breadcrumbsEnabled: true,
    projectRoot: "webpack:///./",
    enableUnhandledRejection: false
  });
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.HoneybadgerErrorBoundary, {
    ErrorComponent: ErrorComponent,
    honeybadger: honeybadger,
    children: children
  });
};
var _default = exports["default"] = HoneybadgerErrorBoundary;
//# sourceMappingURL=HoneybadgerErrorBoundary.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy