Enhance Sentry Client Configuration for Improved Error Handling

- Updated the `beforeSend` function in `sentry.client.config.ts` to improve error filtering by introducing checks for chunk loading errors and validation exceptions. This prevents unnecessary error reporting to Sentry, enhancing the relevance of logged errors.
- Refactored user information retrieval to use a local variable for better clarity and maintainability.

These changes aim to streamline error reporting and improve the overall reliability of the Sentry integration in the client application.
This commit is contained in:
JhumanJ
2025-05-16 12:30:31 +02:00
parent 0dfec52cf8
commit 29b513a6f6
2 changed files with 43 additions and 8 deletions

View File

@@ -0,0 +1,21 @@
export default defineNuxtPlugin((nuxtApp) => {
const router = useRouter()
router.onError((error) => {
if (
error.message.includes('Failed to fetch dynamically imported module') ||
error.message.includes('Failed to load resource')
) {
window.location.reload()
}
})
nuxtApp.hook('app:error', (error) => {
if (
error.message.includes('Loading chunk') ||
error.message.includes('Failed to load resource')
) {
window.location.reload()
}
})
})