mirror of
https://github.com/danbulant/Mangades
synced 2026-06-21 07:31:46 +00:00
sentry handle errors
This commit is contained in:
parent
c5fe79c15d
commit
6c7df61f56
3 changed files with 36 additions and 5 deletions
|
|
@ -28,12 +28,12 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@sentry/browser": "^7.25.0",
|
||||
"@sentry/node": "^7.25.0",
|
||||
"fflate": "^0.6.10",
|
||||
"streamsaver": "^2.0.6",
|
||||
"svelte-local-storage-store": "^0.3.1",
|
||||
"svelte-markdown": "^0.2.3",
|
||||
"swiper": "^8.3.2",
|
||||
"toucan-js": "^3.0.0",
|
||||
"vite": "^3.0.9"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,37 @@
|
|||
import * as Sentry from "@sentry/node";
|
||||
import { Toucan } from 'toucan-js';
|
||||
|
||||
/** @type {import('@sveltejs/kit').HandleClientError} */
|
||||
export function handleError({ error, event }) {
|
||||
// @ts-ignore
|
||||
Sentry.captureException(error, { event });
|
||||
|
||||
// @ts-ignore
|
||||
if(import.meta.env.VITE_SENTRY_DSN !== undefined) {
|
||||
const sentry = new Toucan({
|
||||
// @ts-ignore
|
||||
dsn: import.meta.env.VITE_SENTRY_DSN,
|
||||
|
||||
// @ts-ignore
|
||||
environment: import.meta.env.VITE_SENTRY_ENVIRONMENT,
|
||||
// @ts-ignore
|
||||
release: import.meta.env.VITE_SENTRY_RELEASE,
|
||||
request: event.request,
|
||||
requestDataOptions: {
|
||||
allowedHeaders: [
|
||||
'user-agent',
|
||||
'cf-challenge',
|
||||
'accept-encoding',
|
||||
'accept-language',
|
||||
'cf-ray',
|
||||
'content-length',
|
||||
'content-type',
|
||||
'x-real-ip',
|
||||
'host',
|
||||
],
|
||||
allowedSearchParams: /(.*)/
|
||||
}
|
||||
});
|
||||
|
||||
sentry.captureException(error);
|
||||
}
|
||||
|
||||
return {
|
||||
...error,
|
||||
code: error?.code ?? 'UNKNOWN'
|
||||
|
|
|
|||
3
src/routes/error/+page.ts
Normal file
3
src/routes/error/+page.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export function load() {
|
||||
throw new Error("Test error");
|
||||
}
|
||||
Loading…
Reference in a new issue