Skip to content

fix(core): Ensure ignoreErrors only applies to error events #7573

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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