@@ -3,7 +3,7 @@ import type {ExceptionValue, Frame} from 'sentry/types/event';
3
3
import type { StacktraceType } from 'sentry/types/stacktrace' ;
4
4
import { defined } from 'sentry/utils' ;
5
5
6
- function getJavaScriptFrame ( frame : Frame ) : string {
6
+ function getJavaScriptFrame ( frame : Frame , includeLocation : boolean ) : string {
7
7
let result = '' ;
8
8
if ( defined ( frame . function ) ) {
9
9
result += ' at ' + frame . function + '(' ;
@@ -15,17 +15,17 @@ function getJavaScriptFrame(frame: Frame): string {
15
15
} else if ( defined ( frame . module ) ) {
16
16
result += frame . module ;
17
17
}
18
- if ( defined ( frame . lineNo ) && frame . lineNo >= 0 ) {
18
+ if ( defined ( frame . lineNo ) && frame . lineNo >= 0 && includeLocation ) {
19
19
result += ':' + frame . lineNo ;
20
20
}
21
- if ( defined ( frame . colNo ) && frame . colNo >= 0 ) {
21
+ if ( defined ( frame . colNo ) && frame . colNo >= 0 && includeLocation ) {
22
22
result += ':' + frame . colNo ;
23
23
}
24
24
result += ')' ;
25
25
return result ;
26
26
}
27
27
28
- function getRubyFrame ( frame : Frame ) : string {
28
+ function getRubyFrame ( frame : Frame , includeLocation : boolean ) : string {
29
29
let result = ' from ' ;
30
30
if ( defined ( frame . filename ) ) {
31
31
result += frame . filename ;
@@ -34,10 +34,10 @@ function getRubyFrame(frame: Frame): string {
34
34
} else {
35
35
result += '?' ;
36
36
}
37
- if ( defined ( frame . lineNo ) && frame . lineNo >= 0 ) {
37
+ if ( defined ( frame . lineNo ) && frame . lineNo >= 0 && includeLocation ) {
38
38
result += ':' + frame . lineNo ;
39
39
}
40
- if ( defined ( frame . colNo ) && frame . colNo >= 0 ) {
40
+ if ( defined ( frame . colNo ) && frame . colNo >= 0 && includeLocation ) {
41
41
result += ':' + frame . colNo ;
42
42
}
43
43
if ( defined ( frame . function ) ) {
@@ -46,12 +46,17 @@ function getRubyFrame(frame: Frame): string {
46
46
return result ;
47
47
}
48
48
49
- function getPHPFrame ( frame : Frame , idx : number ) : string {
49
+ function getPHPFrame ( frame : Frame , idx : number , includeLocation : boolean ) : string {
50
50
const funcName = frame . function === 'null' ? '{main}' : frame . function ;
51
- return `#${ idx } ${ frame . filename || frame . module } (${ frame . lineNo } ): ${ funcName } ` ;
51
+ let result = `#${ idx } ${ frame . filename || frame . module } ` ;
52
+ if ( includeLocation && defined ( frame . lineNo ) && frame . lineNo >= 0 ) {
53
+ result += `(${ frame . lineNo } )` ;
54
+ }
55
+ result += `: ${ funcName } ` ;
56
+ return result ;
52
57
}
53
58
54
- function getPythonFrame ( frame : Frame ) : string {
59
+ function getPythonFrame ( frame : Frame , includeLocation : boolean ) : string {
55
60
let result = '' ;
56
61
if ( defined ( frame . filename ) ) {
57
62
result += ' File "' + frame . filename + '"' ;
@@ -60,10 +65,10 @@ function getPythonFrame(frame: Frame): string {
60
65
} else {
61
66
result += ' ?' ;
62
67
}
63
- if ( defined ( frame . lineNo ) && frame . lineNo >= 0 ) {
68
+ if ( defined ( frame . lineNo ) && frame . lineNo >= 0 && includeLocation ) {
64
69
result += ', line ' + frame . lineNo ;
65
70
}
66
- if ( defined ( frame . colNo ) && frame . colNo >= 0 ) {
71
+ if ( defined ( frame . colNo ) && frame . colNo >= 0 && includeLocation ) {
67
72
result += ', col ' + frame . colNo ;
68
73
}
69
74
if ( defined ( frame . function ) ) {
@@ -79,7 +84,7 @@ function getPythonFrame(frame: Frame): string {
79
84
return result ;
80
85
}
81
86
82
- export function getJavaFrame ( frame : Frame ) : string {
87
+ export function getJavaFrame ( frame : Frame , includeLocation : boolean ) : string {
83
88
let result = ' at' ;
84
89
85
90
if ( defined ( frame . module ) ) {
@@ -90,15 +95,19 @@ export function getJavaFrame(frame: Frame): string {
90
95
}
91
96
if ( defined ( frame . filename ) ) {
92
97
result += '(' + frame . filename ;
93
- if ( defined ( frame . lineNo ) && frame . lineNo >= 0 ) {
98
+ if ( defined ( frame . lineNo ) && frame . lineNo >= 0 && includeLocation ) {
94
99
result += ':' + frame . lineNo ;
95
100
}
96
101
result += ')' ;
97
102
}
98
103
return result ;
99
104
}
100
105
101
- function getDartFrame ( frame : Frame , frameIdxFromEnd : number ) : string {
106
+ function getDartFrame (
107
+ frame : Frame ,
108
+ frameIdxFromEnd : number ,
109
+ includeLocation : boolean
110
+ ) : string {
102
111
let result = ` #${ frameIdxFromEnd } ` ;
103
112
104
113
if ( frame . function === '<asynchronous suspension>' ) {
@@ -112,10 +121,10 @@ function getDartFrame(frame: Frame, frameIdxFromEnd: number): string {
112
121
result += ' (' ;
113
122
114
123
result += frame . absPath ;
115
- if ( defined ( frame . lineNo ) && frame . lineNo >= 0 ) {
124
+ if ( defined ( frame . lineNo ) && frame . lineNo >= 0 && includeLocation ) {
116
125
result += ':' + frame . lineNo ;
117
126
}
118
- if ( defined ( frame . colNo ) && frame . colNo >= 0 ) {
127
+ if ( defined ( frame . colNo ) && frame . colNo >= 0 && includeLocation ) {
119
128
result += ':' + frame . colNo ;
120
129
}
121
130
@@ -129,7 +138,7 @@ function ljust(str: string, len: number) {
129
138
return str + new Array ( Math . max ( 0 , len - str . length ) + 1 ) . join ( ' ' ) ;
130
139
}
131
140
132
- function getNativeFrame ( frame : Frame ) : string {
141
+ function getNativeFrame ( frame : Frame , includeLocation : boolean ) : string {
133
142
let result = ' ' ;
134
143
if ( defined ( frame . package ) ) {
135
144
result += ljust ( trimPackage ( frame . package ) , 20 ) ;
@@ -140,7 +149,7 @@ function getNativeFrame(frame: Frame): string {
140
149
result += ' ' + ( frame . function || frame . symbolAddr ) ;
141
150
if ( defined ( frame . filename ) ) {
142
151
result += ' (' + frame . filename ;
143
- if ( defined ( frame . lineNo ) && frame . lineNo >= 0 ) {
152
+ if ( defined ( frame . lineNo ) && frame . lineNo >= 0 && includeLocation ) {
144
153
result += ':' + frame . lineNo ;
145
154
}
146
155
result += ')' ;
@@ -169,40 +178,42 @@ function getFrame(
169
178
frame : Frame ,
170
179
frameIdx : number ,
171
180
frameIdxFromEnd : number ,
172
- platform : string | undefined
181
+ platform : string | undefined ,
182
+ includeLocation : boolean
173
183
) : string {
174
184
if ( frame . platform ) {
175
185
platform = frame . platform ;
176
186
}
177
187
switch ( platform ) {
178
188
case 'javascript' :
179
- return getJavaScriptFrame ( frame ) ;
189
+ return getJavaScriptFrame ( frame , includeLocation ) ;
180
190
case 'ruby' :
181
- return getRubyFrame ( frame ) ;
191
+ return getRubyFrame ( frame , includeLocation ) ;
182
192
case 'php' :
183
- return getPHPFrame ( frame , frameIdx ) ;
193
+ return getPHPFrame ( frame , frameIdx , includeLocation ) ;
184
194
case 'python' :
185
- return getPythonFrame ( frame ) ;
195
+ return getPythonFrame ( frame , includeLocation ) ;
186
196
case 'java' :
187
- return getJavaFrame ( frame ) ;
197
+ return getJavaFrame ( frame , includeLocation ) ;
188
198
case 'dart' :
189
- return getDartFrame ( frame , frameIdxFromEnd ) ;
199
+ return getDartFrame ( frame , frameIdxFromEnd , includeLocation ) ;
190
200
case 'objc' :
191
201
// fallthrough
192
202
case 'cocoa' :
193
203
// fallthrough
194
204
case 'native' :
195
- return getNativeFrame ( frame ) ;
205
+ return getNativeFrame ( frame , includeLocation ) ;
196
206
default :
197
- return getPythonFrame ( frame ) ;
207
+ return getPythonFrame ( frame , includeLocation ) ;
198
208
}
199
209
}
200
210
201
211
export default function displayRawContent (
202
212
data : StacktraceType | null ,
203
213
platform ?: string ,
204
214
exception ?: ExceptionValue ,
205
- hasSimilarityEmbeddingsFeature = false
215
+ hasSimilarityEmbeddingsFeature = false ,
216
+ includeLocation = true
206
217
) {
207
218
const rawFrames = data ?. frames || [ ] ;
208
219
@@ -214,7 +225,13 @@ export default function displayRawContent(
214
225
: rawFrames ;
215
226
216
227
const frames = framesToUse . map ( ( frame , frameIdx ) =>
217
- getFrame ( frame , frameIdx , framesToUse . length - frameIdx - 1 , platform )
228
+ getFrame (
229
+ frame ,
230
+ frameIdx ,
231
+ framesToUse . length - frameIdx - 1 ,
232
+ platform ,
233
+ includeLocation
234
+ )
218
235
) ;
219
236
220
237
if ( platform !== 'python' ) {
0 commit comments