From b1bdb7ea38d41b558793143e4eba53fd9281d62c Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Wed, 28 Feb 2024 15:57:24 +0100 Subject: [PATCH 1/3] feat: Ignore ResizeObserver and undefined error --- .../core/src/integrations/inboundfilters.ts | 2 +- .../lib/integrations/inboundfilters.test.ts | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index 7d42d57f81ed..8b15798349b4 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -6,7 +6,7 @@ import { convertIntegrationFnToClass, defineIntegration } from '../integration'; // "Script error." is hard coded into browsers for errors that it can't read. // this is the result of a script being pulled in from an external domain and CORS. -const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/]; +const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/, /^ResizeObserver loop completed with undelivered notifications.$/, /^undefined$/]; /** Options for the InboundFilters integration */ export interface InboundFiltersOptions { diff --git a/packages/core/test/lib/integrations/inboundfilters.test.ts b/packages/core/test/lib/integrations/inboundfilters.test.ts index 012c3f5f5f0d..f871455d3aea 100644 --- a/packages/core/test/lib/integrations/inboundfilters.test.ts +++ b/packages/core/test/lib/integrations/inboundfilters.test.ts @@ -177,6 +177,18 @@ const SENTRY_EVENT: Event = { }, }; +const BOGUS_EVENT: Event = { + message: '', + exception: { + values: [ + { + type: 'Error', + value: 'undefined', + }, + ], + }, +}; + const SCRIPT_ERROR_EVENT: Event = { exception: { values: [ @@ -188,6 +200,17 @@ const SCRIPT_ERROR_EVENT: Event = { }, }; +const RESIZEOBSERVER_EVENT: Event = { + exception: { + values: [ + { + type: 'Error', + value: 'ResizeObserver loop completed with undelivered notifications.', + }, + ], + }, +}; + const MALFORMED_EVENT: Event = { exception: { values: [ @@ -294,6 +317,16 @@ describe('InboundFilters', () => { expect(eventProcessor(SCRIPT_ERROR_EVENT, {})).toBe(null); }); + it('uses default filters Resize', () => { + const eventProcessor = createInboundFiltersEventProcessor(); + expect(eventProcessor(RESIZEOBSERVER_EVENT, {})).toBe(null); + }); + + it('uses default filters Empty', () => { + const eventProcessor = createInboundFiltersEventProcessor(); + expect(eventProcessor(BOGUS_EVENT, {})).toBe(null); + }); + it('filters on last exception when multiple present', () => { const eventProcessor = createInboundFiltersEventProcessor({ ignoreErrors: ['incorrect type given for parameter `chewToy`'], From b808fc3313da7ba7f7db3aa06a8c9ed09323ba83 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Thu, 29 Feb 2024 19:46:16 +0100 Subject: [PATCH 2/3] Remove undefined --- .../core/src/integrations/inboundfilters.ts | 2 +- .../lib/integrations/inboundfilters.test.ts | 19 +------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index 8b15798349b4..bc6e1a52de92 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -6,7 +6,7 @@ import { convertIntegrationFnToClass, defineIntegration } from '../integration'; // "Script error." is hard coded into browsers for errors that it can't read. // this is the result of a script being pulled in from an external domain and CORS. -const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/, /^ResizeObserver loop completed with undelivered notifications.$/, /^undefined$/]; +const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/, /^ResizeObserver loop completed with undelivered notifications.$/]; /** Options for the InboundFilters integration */ export interface InboundFiltersOptions { diff --git a/packages/core/test/lib/integrations/inboundfilters.test.ts b/packages/core/test/lib/integrations/inboundfilters.test.ts index f871455d3aea..f3c29b0398d2 100644 --- a/packages/core/test/lib/integrations/inboundfilters.test.ts +++ b/packages/core/test/lib/integrations/inboundfilters.test.ts @@ -177,18 +177,6 @@ const SENTRY_EVENT: Event = { }, }; -const BOGUS_EVENT: Event = { - message: '', - exception: { - values: [ - { - type: 'Error', - value: 'undefined', - }, - ], - }, -}; - const SCRIPT_ERROR_EVENT: Event = { exception: { values: [ @@ -317,16 +305,11 @@ describe('InboundFilters', () => { expect(eventProcessor(SCRIPT_ERROR_EVENT, {})).toBe(null); }); - it('uses default filters Resize', () => { + it('uses default filters ResizeObserver', () => { const eventProcessor = createInboundFiltersEventProcessor(); expect(eventProcessor(RESIZEOBSERVER_EVENT, {})).toBe(null); }); - it('uses default filters Empty', () => { - const eventProcessor = createInboundFiltersEventProcessor(); - expect(eventProcessor(BOGUS_EVENT, {})).toBe(null); - }); - it('filters on last exception when multiple present', () => { const eventProcessor = createInboundFiltersEventProcessor({ ignoreErrors: ['incorrect type given for parameter `chewToy`'], From 69aafee18631905c4082c911bcbf0e8e2f610cc2 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Fri, 1 Mar 2024 09:23:35 +0100 Subject: [PATCH 3/3] fix lint --- packages/core/src/integrations/inboundfilters.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index bc6e1a52de92..ac89c7d222c6 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -6,7 +6,11 @@ import { convertIntegrationFnToClass, defineIntegration } from '../integration'; // "Script error." is hard coded into browsers for errors that it can't read. // this is the result of a script being pulled in from an external domain and CORS. -const DEFAULT_IGNORE_ERRORS = [/^Script error\.?$/, /^Javascript error: Script error\.? on line 0$/, /^ResizeObserver loop completed with undelivered notifications.$/]; +const DEFAULT_IGNORE_ERRORS = [ + /^Script error\.?$/, + /^Javascript error: Script error\.? on line 0$/, + /^ResizeObserver loop completed with undelivered notifications.$/, +]; /** Options for the InboundFilters integration */ export interface InboundFiltersOptions {