Skip to content
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
8 changes: 8 additions & 0 deletions packages/nuxt/src/server/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ export function lowQualityTransactionsFilter(options: SentryNuxtServerOptions):
if (event.type !== 'transaction' || !event.transaction) {
return event;
}

// Check if this looks like a parametrized route (contains :param or :param() patterns)
const hasRouteParameters = /\/:[^(/\s]*(\([^)]*\))?[^/\s]*/.test(event.transaction);

if (hasRouteParameters) {
return event;
}

// We don't want to send transaction for file requests, so everything ending with a *.someExtension should be filtered out
// path.extname will return an empty string for normal page requests
if (path.extname(event.transaction)) {
Expand Down
5 changes: 3 additions & 2 deletions packages/nuxt/test/server/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Nuxt Server SDK', () => {
expect(init({})).not.toBeUndefined();
});

describe('low quality transactions filter (%s)', () => {
describe('lowQualityTransactionsFilter (%s)', () => {
const beforeSendEvent = vi.fn(event => event);
const client = init({
dsn: 'https://[email protected]/1337',
Expand All @@ -63,7 +63,8 @@ describe('Nuxt Server SDK', () => {
expect(beforeSendEvent).not.toHaveBeenCalled();
});

it.each(['GET /', 'POST /_server'])(
// Nuxt parametrizes routes sometimes in a special way - especially catchAll o.O
it.each(['GET /', 'POST /_server', 'GET /catchAll/:id(.*)*', 'GET /article/:slug()', 'GET /user/:id'])(
'does not filter out high quality or route transactions (%s)',
async transaction => {
client.captureEvent({ type: 'transaction', transaction });
Expand Down
Loading