From 88fbacd08c658db23debf98df017e23fb67fbc06 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 27 Feb 2025 16:24:41 +0100 Subject: [PATCH 1/3] replace existing filter with regex --- packages/core/src/integrations/eventFilters.ts | 2 +- .../core/test/lib/integrations/eventFilters.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/core/src/integrations/eventFilters.ts b/packages/core/src/integrations/eventFilters.ts index 087623367e28..c6df6ae50cdf 100644 --- a/packages/core/src/integrations/eventFilters.ts +++ b/packages/core/src/integrations/eventFilters.ts @@ -15,7 +15,7 @@ const DEFAULT_IGNORE_ERRORS = [ /^ResizeObserver loop completed with undelivered notifications.$/, // The browser logs this when a ResizeObserver handler takes a bit longer. Usually this is not an actual issue though. It indicates slowness. /^Cannot redefine property: googletag$/, // This is thrown when google tag manager is used in combination with an ad blocker /^Can't find variable: gmo$/, // Error from Google Search App https://issuetracker.google.com/issues/396043331 - "undefined is not an object (evaluating 'a.L')", // Random error that happens but not actionable or noticeable to end-users. + /^undefined is not an object \(evaluating 'a\.[A-Z]'\)$/, // Random error that happens but not actionable or noticeable to end-users. 'can\'t redefine non-configurable property "solana"', // Probably a browser extension or custom browser (Brave) throwing this error "vv().getRestrictions is not a function. (In 'vv().getRestrictions(1,a)', 'vv().getRestrictions' is undefined)", // Error thrown by GTM, seemingly not affecting end-users "Can't find variable: _AutofillCallbackHandler", // Unactionable error in instagram webview https://developers.facebook.com/community/threads/320013549791141/ diff --git a/packages/core/test/lib/integrations/eventFilters.test.ts b/packages/core/test/lib/integrations/eventFilters.test.ts index b89f0f97a8e7..de1a4a524db2 100644 --- a/packages/core/test/lib/integrations/eventFilters.test.ts +++ b/packages/core/test/lib/integrations/eventFilters.test.ts @@ -332,6 +332,12 @@ const TRANSACTION_EVENT_3: Event = { type: 'transaction', }; +const UNDEFINED_IS_NOT_AN_OBJECT_EVENT: Event = { + exception: { + values: [{ type: 'TypeError', value: "undefined is not an object (evaluating 'a.L')" }], + }, +}; + describe.each([ // eslint-disable-next-line deprecation/deprecation ['InboundFilters', inboundFiltersIntegration], @@ -439,6 +445,11 @@ describe.each([ expect(eventProcessor(FB_MOBILE_BROWSER_EVENT, {})).toBe(null); }); + it("uses default filters (undefined is not an object (evaluating 'a.K'))", () => { + const eventProcessor = createEventFiltersEventProcessor(integrationFn); + expect(eventProcessor(UNDEFINED_IS_NOT_AN_OBJECT_EVENT, {})).toBe(null); + }); + it('filters on last exception when multiple present', () => { const eventProcessor = createEventFiltersEventProcessor(integrationFn, { ignoreErrors: ['incorrect type given for parameter `chewToy`'], From e681163c05c6f83a38ba24a83895748655664b87 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 27 Feb 2025 16:29:13 +0100 Subject: [PATCH 2/3] . --- packages/core/test/lib/integrations/eventFilters.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/test/lib/integrations/eventFilters.test.ts b/packages/core/test/lib/integrations/eventFilters.test.ts index de1a4a524db2..29c2611e2ab8 100644 --- a/packages/core/test/lib/integrations/eventFilters.test.ts +++ b/packages/core/test/lib/integrations/eventFilters.test.ts @@ -445,7 +445,7 @@ describe.each([ expect(eventProcessor(FB_MOBILE_BROWSER_EVENT, {})).toBe(null); }); - it("uses default filters (undefined is not an object (evaluating 'a.K'))", () => { + it("uses default filters (undefined is not an object (evaluating 'a.L'))", () => { const eventProcessor = createEventFiltersEventProcessor(integrationFn); expect(eventProcessor(UNDEFINED_IS_NOT_AN_OBJECT_EVENT, {})).toBe(null); }); From 5c259bcae3e6f055a119679ae30041048ebb025b Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 27 Feb 2025 16:44:35 +0100 Subject: [PATCH 3/3] add more real life test cases --- .../lib/integrations/eventFilters.test.ts | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/core/test/lib/integrations/eventFilters.test.ts b/packages/core/test/lib/integrations/eventFilters.test.ts index 29c2611e2ab8..ae0076789f46 100644 --- a/packages/core/test/lib/integrations/eventFilters.test.ts +++ b/packages/core/test/lib/integrations/eventFilters.test.ts @@ -332,11 +332,13 @@ const TRANSACTION_EVENT_3: Event = { type: 'transaction', }; -const UNDEFINED_IS_NOT_AN_OBJECT_EVENT: Event = { - exception: { - values: [{ type: 'TypeError', value: "undefined is not an object (evaluating 'a.L')" }], - }, -}; +function createUndefinedIsNotAnObjectEvent(evaluatingStr: string): Event { + return { + exception: { + values: [{ type: 'TypeError', value: `undefined is not an object (evaluating '${evaluatingStr}')` }], + }, + }; +} describe.each([ // eslint-disable-next-line deprecation/deprecation @@ -447,7 +449,24 @@ describe.each([ it("uses default filters (undefined is not an object (evaluating 'a.L'))", () => { const eventProcessor = createEventFiltersEventProcessor(integrationFn); - expect(eventProcessor(UNDEFINED_IS_NOT_AN_OBJECT_EVENT, {})).toBe(null); + expect(eventProcessor(createUndefinedIsNotAnObjectEvent('a.L'), {})).toBe(null); + }); + + it("uses default filters (undefined is not an object (evaluating 'a.K'))", () => { + const eventProcessor = createEventFiltersEventProcessor(integrationFn); + expect(eventProcessor(createUndefinedIsNotAnObjectEvent('a.K'), {})).toBe(null); + }); + + it("doesn't use default filters for (undefined is not an object (evaluating 'a.store'))", () => { + const eventProcessor = createEventFiltersEventProcessor(integrationFn); + const event = createUndefinedIsNotAnObjectEvent('a.store'); + expect(eventProcessor(event, {})).toBe(event); + }); + + it("doesn't use default filters for (undefined is not an object (evaluating 'this._perf.domInteractive'))", () => { + const eventProcessor = createEventFiltersEventProcessor(integrationFn); + const event = createUndefinedIsNotAnObjectEvent('a.store'); + expect(eventProcessor(event, {})).toBe(event); }); it('filters on last exception when multiple present', () => {