From 949602623ca4efc23b437b97af34990c4ed0684d Mon Sep 17 00:00:00 2001 From: Luke Hagar Date: Tue, 6 Feb 2024 21:53:39 -0600 Subject: [PATCH] Added Sentry --- .gitignore | 3 +++ package.json | 10 ++++++++-- src/app.postcss | 4 ++++ src/hooks.client.ts | 21 +++++++++++++++++++++ src/hooks.server.ts | 14 ++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/hooks.client.ts create mode 100644 src/hooks.server.ts diff --git a/.gitignore b/.gitignore index 6635cf5..9db7db8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,6 @@ node_modules !.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* + +# Sentry Config File +.sentryclirc diff --git a/package.json b/package.json index 33a5e6d..51c398e 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "format": "prettier --plugin-search-dir . --write ." }, "devDependencies": { + "@floating-ui/dom": "^1.6.1", "@skeletonlabs/skeleton": "^2.7.0", "@skeletonlabs/tw-plugin": "^0.3.1", "@sveltejs/adapter-auto": "^3.0.0", @@ -32,12 +33,17 @@ "prettier-plugin-svelte": "^3.1.2", "svelte": "^4.2.8", "svelte-check": "^3.6.3", - "svelte-jsoneditor": "^0.21.2", + "svelte-jsoneditor": "^0.21.5", "tailwindcss": "^3.4.1", "tslib": "^2.6.2", "typescript": "^5.3.3", "vite": "^5.0.0", + "vite-plugin-tailwind-purgecss": "^0.2.0", "yaml": "^2.3.4" }, - "type": "module" + "type": "module", + "dependencies": { + "@sentry/sveltekit": "^7.99.0", + "highlight.js": "^11.9.0" + } } diff --git a/src/app.postcss b/src/app.postcss index 7000124..6af0300 100644 --- a/src/app.postcss +++ b/src/app.postcss @@ -8,3 +8,7 @@ html, body { @apply h-full overflow-hidden; } + +.codeblock-pre { + @apply overflow-y-auto h-[83vh]; +} diff --git a/src/hooks.client.ts b/src/hooks.client.ts new file mode 100644 index 0000000..8eaebea --- /dev/null +++ b/src/hooks.client.ts @@ -0,0 +1,21 @@ +import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit"; +import * as Sentry from '@sentry/sveltekit'; + +Sentry.init({ + dsn: 'https://6c7cfa3b76b1700cb23c34ae2fcab4ad@sentry.plygrnd.org/3', + tracesSampleRate: 1.0, + + // 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()], +}); + +// If you have a custom error handler, pass it to `handleErrorWithSentry` +export const handleError = handleErrorWithSentry(); diff --git a/src/hooks.server.ts b/src/hooks.server.ts new file mode 100644 index 0000000..b701060 --- /dev/null +++ b/src/hooks.server.ts @@ -0,0 +1,14 @@ +import { sequence } from "@sveltejs/kit/hooks"; +import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit"; +import * as Sentry from '@sentry/sveltekit'; + +Sentry.init({ + dsn: 'https://6c7cfa3b76b1700cb23c34ae2fcab4ad@sentry.plygrnd.org/3', + tracesSampleRate: 1.0, +}); + +// If you have custom handlers, make sure to place them after `sentryHandle()` in the `sequence` function. +export const handle = sequence(sentryHandle()); + +// If you have a custom error handler, pass it to `handleErrorWithSentry` +export const handleError = handleErrorWithSentry();