@@ -118,47 +118,50 @@ function applyClientOptions(event: Event, options: ClientOptions): void {
118
118
*/
119
119
export function applyDebugMetadata ( event : Event , stackParser : StackParser ) : void {
120
120
const debugIdMap = GLOBAL_OBJ . _sentryDebugIds ;
121
- if ( debugIdMap ) {
122
- // Build a map of abs_path -> debug_id
123
- const absPathDebugIdMap : Record < string , string > = { } ;
124
- Object . keys ( debugIdMap ) . forEach ( debugIdStackTrace => {
125
- const parsedStack = stackParser ( debugIdStackTrace ) ;
126
- for ( const stackFrame of parsedStack ) {
127
- if ( stackFrame . abs_path ) {
128
- absPathDebugIdMap [ stackFrame . abs_path ] = debugIdMap [ debugIdStackTrace ] ;
129
- break ;
130
- }
131
- }
132
- } ) ;
133
121
134
- // Get a Set of abs_paths in the stack trace
135
- const errorAbsPaths = new Set < string > ( ) ;
136
- if ( event && event . exception && event . exception . values ) {
137
- event . exception . values . forEach ( exception => {
138
- if ( exception . stacktrace && exception . stacktrace . frames ) {
139
- exception . stacktrace . frames . forEach ( frame => {
140
- if ( frame . abs_path ) {
141
- errorAbsPaths . add ( frame . abs_path ) ;
142
- }
143
- } ) ;
144
- }
145
- } ) ;
122
+ if ( ! debugIdMap ) {
123
+ return ;
124
+ }
125
+
126
+ // Build a map of abs_path -> debug_id
127
+ const absPathDebugIdMap : Record < string , string > = { } ;
128
+ Object . keys ( debugIdMap ) . forEach ( debugIdStackTrace => {
129
+ const parsedStack = stackParser ( debugIdStackTrace ) ;
130
+ for ( const stackFrame of parsedStack ) {
131
+ if ( stackFrame . abs_path ) {
132
+ absPathDebugIdMap [ stackFrame . abs_path ] = debugIdMap [ debugIdStackTrace ] ;
133
+ break ;
134
+ }
146
135
}
136
+ } ) ;
147
137
148
- // Fill debug_meta information
149
- event . debug_meta = event . debug_meta || { } ;
150
- event . debug_meta . images = event . debug_meta . images || [ ] ;
151
- const images = event . debug_meta . images ;
152
- errorAbsPaths . forEach ( absPath => {
153
- if ( absPathDebugIdMap [ absPath ] ) {
154
- images . push ( {
155
- type : 'sourcemap' ,
156
- code_file : absPath ,
157
- debug_id : absPathDebugIdMap [ absPath ] ,
138
+ // Get a Set of abs_paths in the stack trace
139
+ const errorAbsPaths = new Set < string > ( ) ;
140
+ if ( event && event . exception && event . exception . values ) {
141
+ event . exception . values . forEach ( exception => {
142
+ if ( exception . stacktrace && exception . stacktrace . frames ) {
143
+ exception . stacktrace . frames . forEach ( frame => {
144
+ if ( frame . abs_path ) {
145
+ errorAbsPaths . add ( frame . abs_path ) ;
146
+ }
158
147
} ) ;
159
148
}
160
149
} ) ;
161
150
}
151
+
152
+ // Fill debug_meta information
153
+ event . debug_meta = event . debug_meta || { } ;
154
+ event . debug_meta . images = event . debug_meta . images || [ ] ;
155
+ const images = event . debug_meta . images ;
156
+ errorAbsPaths . forEach ( absPath => {
157
+ if ( absPathDebugIdMap [ absPath ] ) {
158
+ images . push ( {
159
+ type : 'sourcemap' ,
160
+ code_file : absPath ,
161
+ debug_id : absPathDebugIdMap [ absPath ] ,
162
+ } ) ;
163
+ }
164
+ } ) ;
162
165
}
163
166
164
167
/**
0 commit comments