UNPKG

@prezly/theme-kit-nextjs

Version:

Data layer and utility library for developing Prezly themes with NextJS

72 lines (69 loc) 2.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildSentryConfig = buildSentryConfig; var IGNORED_EVENT_CULPRITS = [ // This usually means that something happened outside of application code. // All instances of errors with this origin that I found usually were caused by referring to variables that couldn't ever exist in our code. // Likely misbehaving browser extensions or people playing around in DevTools trying to break the app. '<anonymous>', '?(<anonymous>)', 'global code']; function shouldStackFrameBeIgnored(frame) { var { abs_path, function: frameFunction } = frame; if (abs_path && IGNORED_EVENT_CULPRITS.some(ignoredCulprit => abs_path.includes(ignoredCulprit))) { return true; } if (frameFunction && IGNORED_EVENT_CULPRITS.some(ignoredCulprit => frameFunction.includes(ignoredCulprit))) { return true; } return false; } function shouldExceptionBeIgnored(exception) { var _stacktrace$frames; var { stacktrace } = exception; // Ignore global code errors that are not related to the application code. // See comments in `IGNORED_EVENT_CULPRITS` const for context on each entry if (stacktrace && (_stacktrace$frames = stacktrace.frames) !== null && _stacktrace$frames !== void 0 && _stacktrace$frames.some(shouldStackFrameBeIgnored)) { return true; } return false; } function buildSentryConfig(dsn, themeName) { return { dsn, // Adjust this value in production, or use tracesSampler for greater control tracesSampleRate: 0.005, // ... // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps ignoreErrors: [ // This particular error is coming from Microsoft Outlook SafeLink crawler. // It doesn't affect the user experience in any way, but produces a lot of unwanted Sentry events. // See https://forum.sentry.io/t/unhandledrejection-non-error-promise-rejection-captured-with-value/14062 'Object Not Found Matching Id', // This error is caused by `beacon.min.js` polyfill in Cloudflare Insights. From what we see, it doesn't affect the user experience. 'Illegal invocation'], beforeSend: event => { var _event$exception; if ((_event$exception = event.exception) !== null && _event$exception !== void 0 && (_event$exception = _event$exception.values) !== null && _event$exception !== void 0 && _event$exception.every(shouldExceptionBeIgnored)) { return null; } return event; }, // Attach theme tag to each event initialScope: scope => { if (themeName) { scope.setTags({ prezly_theme: themeName }); } return scope; } }; }