diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index fec0265e499b..ca4135545c39 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -194,7 +194,7 @@ export class InboundFilters implements Integration { for (let i = frames.length - 1; i >= 0; i--) { const frame = frames[i]; - if (frame?.filename !== '') { + if (frame?.filename !== '' && frame?.filename !== '[native code]') { return frame.filename || null; } } diff --git a/packages/core/test/lib/integrations/inboundfilters.test.ts b/packages/core/test/lib/integrations/inboundfilters.test.ts index 283ae7404140..f711f4725a0b 100644 --- a/packages/core/test/lib/integrations/inboundfilters.test.ts +++ b/packages/core/test/lib/integrations/inboundfilters.test.ts @@ -487,5 +487,36 @@ describe('InboundFilters', () => { ), ).toBe(true); }); + + it('should search for script names when the last frame is from native code', () => { + const messageEvent = { + message: 'any', + stacktrace: { + frames: [ + { filename: 'https://our-side.com/js/bundle.js' }, + { filename: 'https://awesome-analytics.io/some/file.js' }, + { filename: '[native code]' }, + ], + }, + }; + + expect( + inboundFilters._isAllowedUrl( + messageEvent, + inboundFilters._mergeOptions({ + allowUrls: ['https://awesome-analytics.io/some/file.js'], + }), + ), + ).toBe(true); + + expect( + inboundFilters._isDeniedUrl( + messageEvent, + inboundFilters._mergeOptions({ + denyUrls: ['https://awesome-analytics.io/some/file.js'], + }), + ), + ).toBe(true); + }); }); });