Skip to content

Commit ad3c36e

Browse files
authored
fix: Use correct frame for inboundFilter methods (#1893)
1 parent 2f5ce39 commit ad3c36e

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

packages/core/src/integrations/inboundfilters.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,12 @@ export class InboundFilters implements Integration {
178178
try {
179179
if (event.stacktrace) {
180180
// tslint:disable-next-line:no-unsafe-any
181-
return (event as any).stacktrace.frames[0].filename;
181+
const frames = (event as any).stacktrace.frames;
182+
return frames[frames.length - 1].filename;
182183
} else if (event.exception) {
183184
// tslint:disable-next-line:no-unsafe-any
184-
return (event as any).exception.values[0].stacktrace.frames[0].filename;
185+
const frames = (event as any).exception.values[0].stacktrace.frames;
186+
return frames[frames.length - 1].filename;
185187
} else {
186188
return null;
187189
}

packages/core/test/lib/integrations/inboundfilters.test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,28 @@ describe('InboundFilters', () => {
255255
const messageEvent = {
256256
message: 'wat',
257257
stacktrace: {
258+
// Frames are always in the reverse order, as this is how Sentry expect them to come.
259+
// Frame that crashed is the last one, the one from awesome-analytics
258260
frames: [
259-
{
260-
filename: 'https://awesome-analytics.io/some/file.js',
261-
},
261+
{ filename: 'https://our-side.com/js/bundle.js' },
262+
{ filename: 'https://our-side.com/js/bundle.js' },
263+
{ filename: 'https://awesome-analytics.io/some/file.js' },
262264
],
263265
},
264266
};
265267
const exceptionEvent = {
266268
exception: {
267269
values: [
268270
{
269-
stacktrace: { frames: [{ filename: 'https://awesome-analytics.io/some/file.js' }] },
271+
stacktrace: {
272+
// Frames are always in the reverse order, as this is how Sentry expect them to come.
273+
// Frame that crashed is the last one, the one from awesome-analytics
274+
frames: [
275+
{ filename: 'https://our-side.com/js/bundle.js' },
276+
{ filename: 'https://our-side.com/js/bundle.js' },
277+
{ filename: 'https://awesome-analytics.io/some/file.js' },
278+
],
279+
},
270280
},
271281
],
272282
},

0 commit comments

Comments
 (0)