UNPKG

@sentry/remix

Version:
48 lines (44 loc) • 1.38 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const browser = require('@sentry/browser'); const diagnosticsChannelShim = require('./diagnosticsChannelShim.js'); const MECHANISM_TYPE = "auto.ui.remix_v3"; const RUN_CHANNELS = ["orchestrion:@remix-run/ui:run", "orchestrion:@remix-run/component:run"]; const attached = /* @__PURE__ */ new WeakSet(); let subscribed = false; function captureRuntimeErrors(app) { if (attached.has(app)) { return; } attached.add(app); app.addEventListener("error", (event) => { browser.captureException(readComponentError(event), { mechanism: { handled: false, type: MECHANISM_TYPE } }); }); } function instrumentClientRuntime() { if (subscribed) { return; } subscribed = true; for (const name of RUN_CHANNELS) { diagnosticsChannelShim.tracingChannel(name).subscribe({ end(context) { const app = context.result; if (isAppRuntime(app)) { captureRuntimeErrors(app); } } }); } } function isAppRuntime(value) { return typeof value?.addEventListener === "function"; } function readComponentError(event) { const error = event.error; return error !== void 0 ? error : event; } exports.captureRuntimeErrors = captureRuntimeErrors; exports.instrumentClientRuntime = instrumentClientRuntime; //# sourceMappingURL=errors.js.map