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

package.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
import { Honeybadger, HoneybadgerErrorBoundary as ErrorBoundary } from "@honeybadger-io/react";
import { IGNORABLE_ERROR_NAMES_REGEX, IGNORABLE_ERRORS_REGEX } from "./constants";
import FallbackComponent from "./FallbackComponent";
import { attachContext, getSessionReplayUrl } from "./utils";

/** @type {import("neetocommons/react-utils").HoneybadgerErrorBoundary} */
import { jsx as _jsx } from "react/jsx-runtime";
var HoneybadgerErrorBoundary = function HoneybadgerErrorBoundary(_ref) {
  var children = _ref.children,
    _ref$ErrorComponent = _ref.ErrorComponent,
    ErrorComponent = _ref$ErrorComponent === void 0 ? FallbackComponent : _ref$ErrorComponent,
    _ref$filterErrors = _ref.filterErrors,
    filterErrors = _ref$filterErrors === void 0 ? undefined : _ref$filterErrors;
  Honeybadger.beforeNotify(function (notice) {
    var _globalProps$user;
    if (!notice) return false;
    var isIgnorable = IGNORABLE_ERRORS_REGEX.test(notice.message) || 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 = IGNORABLE_ERROR_NAMES_REGEX;
      context.isChunkLoadError = 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 = getSessionReplayUrl();
    if (sessionReplay) context.sessionReplay = sessionReplay;
    attachContext(notice, context);
    return true;
  });
  var honeybadger = 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__*/_jsx(ErrorBoundary, {
    ErrorComponent: ErrorComponent,
    honeybadger: honeybadger,
    children: children
  });
};
export default HoneybadgerErrorBoundary;
//# sourceMappingURL=HoneybadgerErrorBoundary.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy