'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var defineProperty = require('../../../defineProperty-COGyJ6Og.js');
var react = require('@honeybadger-io/react');
var v2_initializers_honeybadger_constants = require('./constants.js');
var v2_initializers_honeybadger_utils = require('./utils.js');
require('../../../toPropertyKey-DW-YC76_.js');
require('../../../typeof-D4ZZ_FlZ.js');

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { defineProperty._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var activeFilterErrors = null;
var beforeNotifyRegistered = false;
function initializeHoneybadger() {
  var _window$globalProps2, _window$globalProps3, _window$globalProps4;
  var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  if (!beforeNotifyRegistered) {
    beforeNotifyRegistered = true;
    react.Honeybadger.beforeNotify(function (notice) {
      var _activeFilterErrors, _window$globalProps;
      if (!notice) return false;
      var isIgnorable = v2_initializers_honeybadger_constants.IGNORABLE_ERRORS_REGEX.test(notice.message) || v2_initializers_honeybadger_constants.IGNORABLE_ERROR_NAMES_REGEX.test(notice.name) || v2_initializers_honeybadger_constants.IGNORABLE_STACKS_REGEX.test(notice.stack) || v2_initializers_honeybadger_utils.isNeetoReplaySecurityError(notice) || ((_activeFilterErrors = activeFilterErrors) === null || _activeFilterErrors === void 0 ? void 0 : _activeFilterErrors(notice)) === false;
      if (isIgnorable) return false;
      var context = {
        errorClass: notice.name
      };
      var user = (_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 || (_window$globalProps = _window$globalProps.user) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.email;
      if (user) context.user = user;
      var sessionReplay = v2_initializers_honeybadger_utils.getSessionReplayUrl();
      if (sessionReplay) context.sessionReplay = sessionReplay;
      v2_initializers_honeybadger_utils.attachContext(notice, context);
      return true;
    });
  }
  return react.Honeybadger.configure(_objectSpread({
    apiKey: (_window$globalProps2 = window.globalProps) === null || _window$globalProps2 === void 0 ? void 0 : _window$globalProps2.honeybadgerApiKey,
    environment: (_window$globalProps3 = window.globalProps) === null || _window$globalProps3 === void 0 ? void 0 : _window$globalProps3.railsEnv,
    revision: (_window$globalProps4 = window.globalProps) === null || _window$globalProps4 === void 0 ? void 0 : _window$globalProps4.honeybadgerRevision,
    developmentEnvironments: ["development", "test"],
    enableUncaught: true,
    async: true,
    breadcrumbsEnabled: true,
    projectRoot: "",
    enableUnhandledRejection: false
  }, overrides));
}
var setHoneybadgerErrorFilter = function setHoneybadgerErrorFilter(fn) {
  activeFilterErrors = fn;
};

exports.default = initializeHoneybadger;
exports.setHoneybadgerErrorFilter = setHoneybadgerErrorFilter;
//# sourceMappingURL=index.js.map
