1 | Object.defineProperty(exports, '__esModule', { value: true });
|
2 |
|
3 | const utils = require('@sentry/utils');
|
4 |
|
5 |
|
6 | class RewriteFrames {
|
7 | |
8 |
|
9 |
|
10 | static __initStatic() {this.id = 'RewriteFrames';}
|
11 |
|
12 | |
13 |
|
14 |
|
15 | __init() {this.name = RewriteFrames.id;}
|
16 |
|
17 | |
18 |
|
19 |
|
20 |
|
21 | |
22 |
|
23 |
|
24 | __init2() {this._prefix = 'app:///';}
|
25 |
|
26 | |
27 |
|
28 |
|
29 | constructor(options = {}) {;RewriteFrames.prototype.__init.call(this);RewriteFrames.prototype.__init2.call(this);RewriteFrames.prototype.__init3.call(this);
|
30 | if (options.root) {
|
31 | this._root = options.root;
|
32 | }
|
33 | if (options.prefix) {
|
34 | this._prefix = options.prefix;
|
35 | }
|
36 | if (options.iteratee) {
|
37 | this._iteratee = options.iteratee;
|
38 | }
|
39 | }
|
40 |
|
41 | |
42 |
|
43 |
|
44 | setupOnce(addGlobalEventProcessor, getCurrentHub) {
|
45 | addGlobalEventProcessor(event => {
|
46 | const self = getCurrentHub().getIntegration(RewriteFrames);
|
47 | if (self) {
|
48 | return self.process(event);
|
49 | }
|
50 | return event;
|
51 | });
|
52 | }
|
53 |
|
54 |
|
55 | process(originalEvent) {
|
56 | let processedEvent = originalEvent;
|
57 |
|
58 | if (originalEvent.exception && Array.isArray(originalEvent.exception.values)) {
|
59 | processedEvent = this._processExceptionsEvent(processedEvent);
|
60 | }
|
61 |
|
62 | return processedEvent;
|
63 | }
|
64 |
|
65 | |
66 |
|
67 |
|
68 | __init3() {this._iteratee = (frame) => {
|
69 | if (!frame.filename) {
|
70 | return frame;
|
71 | }
|
72 |
|
73 | const isWindowsFrame = /^[A-Z]:\\/.test(frame.filename);
|
74 | const startsWithSlash = /^\//.test(frame.filename);
|
75 | if (isWindowsFrame || startsWithSlash) {
|
76 | const filename = isWindowsFrame
|
77 | ? frame.filename
|
78 | .replace(/^[A-Z]:/, '')
|
79 | .replace(/\\/g, '/')
|
80 | : frame.filename;
|
81 | const base = this._root ? utils.relative(this._root, filename) : utils.basename(filename);
|
82 | frame.filename = `${this._prefix}${base}`;
|
83 | }
|
84 | return frame;
|
85 | };}
|
86 |
|
87 |
|
88 | _processExceptionsEvent(event) {
|
89 | try {
|
90 | return {
|
91 | ...event,
|
92 | exception: {
|
93 | ...event.exception,
|
94 |
|
95 |
|
96 | values: event.exception.values.map(value => ({
|
97 | ...value,
|
98 | ...(value.stacktrace && { stacktrace: this._processStacktrace(value.stacktrace) }),
|
99 | })),
|
100 | },
|
101 | };
|
102 | } catch (_oO) {
|
103 | return event;
|
104 | }
|
105 | }
|
106 |
|
107 |
|
108 | _processStacktrace(stacktrace) {
|
109 | return {
|
110 | ...stacktrace,
|
111 | frames: stacktrace && stacktrace.frames && stacktrace.frames.map(f => this._iteratee(f)),
|
112 | };
|
113 | }
|
114 | } RewriteFrames.__initStatic();
|
115 |
|
116 | exports.RewriteFrames = RewriteFrames;
|
117 |
|