I have a Sentry integration with SvelteKit hooks.server.js
.
Errors are correctly logged in Sentry, but HTTP request metadata like user agent, request URL, IP addresses and such are missing, as seen in the issue screenshot below. These are quite important to troubleshoot many issues.
I am using the following hooks.server.js
integration code (based on Sentry’s example):
import { sequence } from '@sveltejs/kit/hooks';
import * as Sentry from '@sentry/sveltekit';
import { dev } from '$app/environment';
import { env } from '$env/dynamic/private';
if(!dev) {
Sentry.init({
dsn: env.SENTRY_DSN,
environment: dev ? "dev" : "production",
// https://github.com/getsentry/sentry-javascript/issues/8925#issue-1876274074
ignoreErrors: [
"TypeError: Failed to fetch dynamically imported module",
"Load failed",
"TypeError: Load failed",
"TypeError: Failed to fetch",
"Failed to fetch",
"TypeError: NetworkError when attempting to fetch resource",
"TypeError: Importing a module script failed",
"TypeError: error loading dynamically imported module",
"RollupError: Expected unicode escape"
],
});
}
export const handleError = Sentry.handleErrorWithSentry((async ({ error }) => {
const eventId = Sentry.lastEventId();
if (eventId) {
return { message: 'Internal Server Error', eventId };
}
}));
// prettier-ignore
let handle;
if(!dev) {
handle = sequence(
Sentry.sentryHandle(),
# ... rest
);
} else {
handle = handle = sequence(
# ... rest
);
}
export default handle;
- What could be the cause that SvelteKit integration for Sentry does not correctly log these?