UNPKG

@kirz/react-native-toolkit

Version:

Toolkit to speed up React Native development

38 lines (37 loc) 2.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SentryPlugin = void 0; var _integrations = require("@sentry/integrations"); var Sentry = _interopRequireWildcard(require("@sentry/react-native")); var _Plugin = require("../Plugin"); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } class SentryPlugin extends _Plugin.Plugin { constructor(options) { super(); this.options = options; _defineProperty(this, "name", 'SentryPlugin'); _defineProperty(this, "features", ['ErrorTracking']); _defineProperty(this, "initializationTimeout", 5000); } async initialize() { if (!this.options.dsn) { throw new Error('Sentry DSN is missing'); } Sentry.init({ dsn: this.options.dsn, // @ts-ignore integrations: [new _integrations.CaptureConsole({ levels: ['warn', 'error'] })], ...this.options }); } } exports.SentryPlugin = SentryPlugin; //# sourceMappingURL=SentryPlugin.js.map