add sentry
This commit is contained in:
30
src/hooks.client.ts
Normal file
30
src/hooks.client.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
||||
import * as Sentry from '@sentry/sveltekit';
|
||||
import { PUBLIC_SENTRY_DSN } from "$env/static/public";
|
||||
|
||||
Sentry.init({
|
||||
dsn: PUBLIC_SENTRY_DSN,
|
||||
|
||||
tracesSampleRate: 1.0,
|
||||
|
||||
// Enable logs to be sent to Sentry
|
||||
enableLogs: true,
|
||||
|
||||
// This sets the sample rate to be 10%. You may want this to be 100% while
|
||||
// in development and sample at a lower rate in production
|
||||
replaysSessionSampleRate: 0.1,
|
||||
|
||||
// If the entire session is not sampled, use the below sample rate to sample
|
||||
// sessions when an error occurs.
|
||||
replaysOnErrorSampleRate: 1.0,
|
||||
|
||||
// If you don't want to use Session Replay, just remove the line below:
|
||||
integrations: [replayIntegration()],
|
||||
|
||||
// Enable sending user PII (Personally Identifiable Information)
|
||||
// https://docs.sentry.io/platforms/javascript/guides/sveltekit/configuration/options/#sendDefaultPii
|
||||
sendDefaultPii: true,
|
||||
});
|
||||
|
||||
// If you have a custom error handler, pass it to `handleErrorWithSentry`
|
||||
export const handleError = handleErrorWithSentry();
|
||||
@@ -1,15 +1,27 @@
|
||||
import { sequence } from "@sveltejs/kit/hooks";
|
||||
import * as Sentry from "@sentry/sveltekit";
|
||||
import { initCloudflareSentryHandle } from "@sentry/sveltekit";
|
||||
import { PUBLIC_SENTRY_DSN } from "$env/static/public";
|
||||
import type { Handle } from "@sveltejs/kit";
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
const response = await resolve(event);
|
||||
export const handle: Handle = sequence(
|
||||
initCloudflareSentryHandle({
|
||||
dsn: PUBLIC_SENTRY_DSN,
|
||||
tracesSampleRate: 1.0,
|
||||
enableLogs: true,
|
||||
}),
|
||||
Sentry.sentryHandle(),
|
||||
async ({ event, resolve }) => {
|
||||
const response = await resolve(event);
|
||||
|
||||
// https://sqlocal.dev/guide/setup#cross-origin-isolation
|
||||
// Cross-origin isolation (needed for SharedArrayBuffer/Atomics -> sqlite-wasm OPFS)
|
||||
response.headers.set("Cross-Origin-Opener-Policy", "same-origin");
|
||||
response.headers.set("Cross-Origin-Embedder-Policy", "require-corp");
|
||||
// https://sqlocal.dev/guide/setup#cross-origin-isolation
|
||||
// Cross-origin isolation (needed for SharedArrayBuffer/Atomics -> sqlite-wasm OPFS)
|
||||
response.headers.set("Cross-Origin-Opener-Policy", "same-origin");
|
||||
response.headers.set("Cross-Origin-Embedder-Policy", "require-corp");
|
||||
|
||||
// Optional, but commonly paired
|
||||
response.headers.set("Cross-Origin-Resource-Policy", "same-origin");
|
||||
// Optional, but commonly paired
|
||||
response.headers.set("Cross-Origin-Resource-Policy", "same-origin");
|
||||
|
||||
return response;
|
||||
};
|
||||
return response;
|
||||
});
|
||||
export const handleError = Sentry.handleErrorWithSentry();
|
||||
Reference in New Issue
Block a user