12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- Object.defineProperty(exports, '__esModule', { value: true });
- const core = require('@sentry/core');
- const utils = require('@sentry/utils');
- const INTEGRATION_NAME = 'RewriteFrames';
- const _rewriteFramesIntegration = ((options = {}) => {
- const root = options.root;
- const prefix = options.prefix || 'app:///';
- const iteratee =
- options.iteratee ||
- ((frame) => {
- if (!frame.filename) {
- return frame;
- }
-
- const isWindowsFrame =
- /^[a-zA-Z]:\\/.test(frame.filename) ||
-
- (frame.filename.includes('\\') && !frame.filename.includes('/'));
-
- const startsWithSlash = /^\//.test(frame.filename);
- if (isWindowsFrame || startsWithSlash) {
- const filename = isWindowsFrame
- ? frame.filename
- .replace(/^[a-zA-Z]:/, '')
- .replace(/\\/g, '/')
- : frame.filename;
- const base = root ? utils.relative(root, filename) : utils.basename(filename);
- frame.filename = `${prefix}${base}`;
- }
- return frame;
- });
-
- function _processExceptionsEvent(event) {
- try {
- return {
- ...event,
- exception: {
- ...event.exception,
-
-
- values: event.exception.values.map(value => ({
- ...value,
- ...(value.stacktrace && { stacktrace: _processStacktrace(value.stacktrace) }),
- })),
- },
- };
- } catch (_oO) {
- return event;
- }
- }
-
- function _processStacktrace(stacktrace) {
- return {
- ...stacktrace,
- frames: stacktrace && stacktrace.frames && stacktrace.frames.map(f => iteratee(f)),
- };
- }
- return {
- name: INTEGRATION_NAME,
-
- setupOnce() {},
- processEvent(originalEvent) {
- let processedEvent = originalEvent;
- if (originalEvent.exception && Array.isArray(originalEvent.exception.values)) {
- processedEvent = _processExceptionsEvent(processedEvent);
- }
- return processedEvent;
- },
- };
- }) ;
- const rewriteFramesIntegration = core.defineIntegration(_rewriteFramesIntegration);
- const RewriteFrames = core.convertIntegrationFnToClass(
- INTEGRATION_NAME,
- rewriteFramesIntegration,
- )
- ;
- exports.RewriteFrames = RewriteFrames;
- exports.rewriteFramesIntegration = rewriteFramesIntegration;
|