From 7745aa8626b11ff3496c0db32c3ba2e5d2f73562 Mon Sep 17 00:00:00 2001 From: Gerard Wilkinson Date: Mon, 24 Feb 2025 14:49:41 +0000 Subject: [PATCH 1/2] fix(nuxt): ignore 300-400 status codes on app errors in Nuxt --- packages/nuxt/src/runtime/plugins/sentry.client.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/runtime/plugins/sentry.client.ts b/packages/nuxt/src/runtime/plugins/sentry.client.ts index 39d62737f645..dc0eee919a2d 100644 --- a/packages/nuxt/src/runtime/plugins/sentry.client.ts +++ b/packages/nuxt/src/runtime/plugins/sentry.client.ts @@ -1,6 +1,6 @@ import { GLOBAL_OBJ, getClient } from '@sentry/core'; import { browserTracingIntegration, vueIntegration } from '@sentry/vue'; -import { defineNuxtPlugin } from 'nuxt/app'; +import { defineNuxtPlugin, isNuxtError } from 'nuxt/app'; import type { GlobalObjWithIntegrationOptions } from '../../client/vueIntegration'; import { reportNuxtError } from '../utils'; @@ -66,6 +66,13 @@ export default defineNuxtPlugin({ }); nuxtApp.hook('app:error', error => { + // Do not handle 404 and 422 + if (isNuxtError(error)) { + // Do not report if status code is 3xx or 4xx + if (error.statusCode >= 300 && error.statusCode < 500) { + return; + } + } reportNuxtError({ error }); }); From 26c4471733f80846971ca9120fc87bb5173f8b8b Mon Sep 17 00:00:00 2001 From: Gerard Wilkinson Date: Mon, 24 Feb 2025 15:03:18 +0000 Subject: [PATCH 2/2] clean up comment --- packages/nuxt/src/runtime/plugins/sentry.client.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/nuxt/src/runtime/plugins/sentry.client.ts b/packages/nuxt/src/runtime/plugins/sentry.client.ts index dc0eee919a2d..b15bff19f099 100644 --- a/packages/nuxt/src/runtime/plugins/sentry.client.ts +++ b/packages/nuxt/src/runtime/plugins/sentry.client.ts @@ -66,7 +66,6 @@ export default defineNuxtPlugin({ }); nuxtApp.hook('app:error', error => { - // Do not handle 404 and 422 if (isNuxtError(error)) { // Do not report if status code is 3xx or 4xx if (error.statusCode >= 300 && error.statusCode < 500) {