(event: Event)
| 176 | * Moves debug IDs from the stack frames of an error event into the debug_meta field. |
| 177 | */ |
| 178 | export function applyDebugMeta(event: Event): void { |
| 179 | // Extract debug IDs and filenames from the stack frames on the event. |
| 180 | const filenameDebugIdMap: Record<string, string> = {}; |
| 181 | event.exception?.values?.forEach(exception => { |
| 182 | exception.stacktrace?.frames?.forEach(frame => { |
| 183 | if (frame.debug_id) { |
| 184 | if (frame.abs_path) { |
| 185 | filenameDebugIdMap[frame.abs_path] = frame.debug_id; |
| 186 | } else if (frame.filename) { |
| 187 | filenameDebugIdMap[frame.filename] = frame.debug_id; |
| 188 | } |
| 189 | delete frame.debug_id; |
| 190 | } |
| 191 | }); |
| 192 | }); |
| 193 | |
| 194 | if (Object.keys(filenameDebugIdMap).length === 0) { |
| 195 | return; |
| 196 | } |
| 197 | |
| 198 | // Fill debug_meta information |
| 199 | event.debug_meta = event.debug_meta || {}; |
| 200 | event.debug_meta.images = event.debug_meta.images || []; |
| 201 | const images = event.debug_meta.images; |
| 202 | Object.entries(filenameDebugIdMap).forEach(([filename, debug_id]) => { |
| 203 | images.push({ |
| 204 | type: 'sourcemap', |
| 205 | code_file: filename, |
| 206 | debug_id, |
| 207 | }); |
| 208 | }); |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * This function adds all used integrations to the SDK info in the event. |
no test coverage detected