mirror of
https://github.com/danbulant/Mangades
synced 2026-06-19 22:31:30 +00:00
move error handling into layout
This commit is contained in:
parent
81be1414ef
commit
02af454047
2 changed files with 49 additions and 12 deletions
|
|
@ -2,17 +2,8 @@
|
|||
import { afterNavigate } from "$app/navigation";
|
||||
import { logs } from "$lib/util/logs";
|
||||
import PageTransition from "./pageTransition.svelte";
|
||||
import * as Sentry from '@sentry/browser';
|
||||
|
||||
export var data;
|
||||
|
||||
if (typeof window !== "undefined" && import.meta.env.VITE_SENTRY_DSN) {
|
||||
Sentry.init({
|
||||
dsn: import.meta.env.VITE_SENTRY_DSN,
|
||||
environment: import.meta.env.VITE_SENTRY_ENVIRONMENT,
|
||||
release: import.meta.env.VITE_SENTRY_RELEASE,
|
||||
});
|
||||
}
|
||||
|
||||
let skipFirst = true;
|
||||
let last = typeof window !== "undefined" && window.location.pathname;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,52 @@
|
|||
|
||||
import { Toucan } from "toucan-js";
|
||||
import * as Sentry from '@sentry/browser';
|
||||
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
export function load({ url }) {
|
||||
return { url: url.pathname };
|
||||
export function load({ url, event }) {
|
||||
let sentry;
|
||||
// @ts-ignore
|
||||
if(import.meta.env.VITE_SENTRY_DSN) if(typeof window === 'undefined') {
|
||||
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: /(.*)/
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sentry = Sentry;
|
||||
if(!sentry.isInitalized) {
|
||||
Sentry.init({
|
||||
// @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
|
||||
});
|
||||
|
||||
sentry.isInitalized = true;
|
||||
}
|
||||
}
|
||||
return {
|
||||
url: url.pathname,
|
||||
sentry
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue