MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / applyDebugMeta

Function applyDebugMeta

packages/core/src/utils/prepareEvent.ts:178–209  ·  view source on GitHub ↗
(event: Event)

Source from the content-addressed store, hash-verified

176 * Moves debug IDs from the stack frames of an error event into the debug_meta field.
177 */
178export 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.

Callers 2

prepareEventFunction · 0.70

Calls 4

pushMethod · 0.80
forEachMethod · 0.65
keysMethod · 0.65
entriesMethod · 0.65

Tested by

no test coverage detected