Skip to content

Commit

Permalink
fix(core): Ensure ignoreErrors only applies to error events (#7573)
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Mar 23, 2023
1 parent 551aedc commit 0a1a567
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/integrations/inboundfilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export function _shouldDropEvent(event: Event, options: Partial<InboundFiltersOp
}

function _isIgnoredError(event: Event, ignoreErrors?: Array<string | RegExp>): boolean {
if (!ignoreErrors || !ignoreErrors.length) {
// If event.type, this is not an error
if (event.type || !ignoreErrors || !ignoreErrors.length) {
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions packages/core/test/lib/integrations/inboundfilters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ const MALFORMED_EVENT: Event = {
},
};

const TRANSACTION_EVENT: Event = {
message: 'transaction message',
type: 'transaction',
};

describe('InboundFilters', () => {
describe('_isSentryError', () => {
it('should work as expected', () => {
Expand All @@ -202,6 +207,13 @@ describe('InboundFilters', () => {
expect(eventProcessor(MESSAGE_EVENT, {})).toBe(null);
});

it('ignores transaction event for filtering', () => {
const eventProcessor = createInboundFiltersEventProcessor({
ignoreErrors: ['transaction'],
});
expect(eventProcessor(TRANSACTION_EVENT, {})).toBe(TRANSACTION_EVENT);
});

it('string filter with exact match', () => {
const eventProcessor = createInboundFiltersEventProcessor({
ignoreErrors: ['captureMessage'],
Expand Down

0 comments on commit 0a1a567

Please sign in to comment.