Skip to content

Commit

Permalink
feat(v7/core): Backport ResizeObserver and googletag default filt…
Browse files Browse the repository at this point in the history
…ers (#11210)

Backport two additional default error event filters to our
`inboundFilters` integration:

* #10845 
* #11208
  • Loading branch information
Lms24 committed Mar 20, 2024
1 parent c7306da commit 4caa946
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .size-limit.js
Expand Up @@ -52,7 +52,7 @@ module.exports = [
path: 'packages/browser/build/npm/esm/index.js',
import: '{ init, browserTracingIntegration }',
gzip: true,
limit: '36 KB',
limit: '37 KB',
},
{
name: '@sentry/browser (incl. Feedback) - Webpack (gzipped)',
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/integrations/inboundfilters.ts
Expand Up @@ -6,7 +6,12 @@ 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.$/,
/^Cannot redefine property: googletag$/,
];

const DEFAULT_IGNORE_TRANSACTIONS = [
/^.*\/healthcheck$/,
Expand Down
34 changes: 33 additions & 1 deletion packages/core/test/lib/integrations/inboundfilters.test.ts
Expand Up @@ -188,6 +188,28 @@ const SCRIPT_ERROR_EVENT: Event = {
},
};

const RESIZEOBSERVER_EVENT: Event = {
exception: {
values: [
{
type: 'Error',
value: 'ResizeObserver loop completed with undelivered notifications.',
},
],
},
};

const GOOGLETAG_EVENT: Event = {
exception: {
values: [
{
type: 'TypeError',
value: 'Cannot redefine property: googletag',
},
],
},
};

const MALFORMED_EVENT: Event = {
exception: {
values: [
Expand Down Expand Up @@ -304,11 +326,21 @@ describe('InboundFilters', () => {
expect(eventProcessor(EXCEPTION_EVENT, {})).toBe(null);
});

it('uses default filters', () => {
it('uses default filters (script error)', () => {
const eventProcessor = createInboundFiltersEventProcessor();
expect(eventProcessor(SCRIPT_ERROR_EVENT, {})).toBe(null);
});

it('uses default filters (ResizeObserver)', () => {
const eventProcessor = createInboundFiltersEventProcessor();
expect(eventProcessor(RESIZEOBSERVER_EVENT, {})).toBe(null);
});

it('uses default filters (googletag)', () => {
const eventProcessor = createInboundFiltersEventProcessor();
expect(eventProcessor(GOOGLETAG_EVENT, {})).toBe(null);
});

it('filters on last exception when multiple present', () => {
const eventProcessor = createInboundFiltersEventProcessor({
ignoreErrors: ['incorrect type given for parameter `chewToy`'],
Expand Down

0 comments on commit 4caa946

Please sign in to comment.