Skip to content

Commit 39517d7

Browse files
codercatdevAlex Patterson
andauthored
Feature/sentry (CodingCatDev#506)
* add sentry * add sentry environments --------- Co-authored-by: Alex Patterson <alex.patterson@fusionauth.io>
1 parent 5f34cac commit 39517d7

File tree

6 files changed

+372
-122
lines changed

6 files changed

+372
-122
lines changed

apps/codingcatdev/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ node_modules
99
vite.config.js.timestamp-*
1010
vite.config.ts.timestamp-*
1111
.vercel
12+
13+
# Sentry Config File
14+
.sentryclirc

apps/codingcatdev/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"@cloudinary/html": "^1.11.2",
5757
"@cloudinary/url-gen": "^1.11.2",
5858
"@floating-ui/dom": "^1.5.3",
59+
"@sentry/sveltekit": "^7.78.0",
5960
"@steeze-ui/material-design-icons": "^1.1.2",
6061
"esm-env": "^1.0.0",
6162
"firebase": "^10.4.0",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { handleErrorWithSentry, Replay } from '@sentry/sveltekit';
2+
import * as Sentry from '@sentry/sveltekit';
3+
import { env } from '$env/dynamic/private';
4+
5+
Sentry.init({
6+
dsn: 'https://518fe25472568a2e47252e6f29583c6b@o1029244.ingest.sentry.io/4506190917206016',
7+
tracesSampleRate: 1.0,
8+
9+
// This sets the sample rate to be 10%. You may want this to be 100% while
10+
// in development and sample at a lower rate in production
11+
replaysSessionSampleRate: 0.1,
12+
13+
// If the entire session is not sampled, use the below sample rate to sample
14+
// sessions when an error occurs.
15+
replaysOnErrorSampleRate: 1.0,
16+
17+
// If you don't want to use Session Replay, just remove the line below:
18+
integrations: [new Replay()],
19+
environment: env.VERCEL_ENV || 'local'
20+
});
21+
22+
// If you have a custom error handler, pass it to `handleErrorWithSentry`
23+
export const handleError = handleErrorWithSentry();
Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1+
import { sequence } from '@sveltejs/kit/hooks';
2+
import * as Sentry from '@sentry/sveltekit';
13
import { redirect, type Handle } from '@sveltejs/kit';
4+
import { env } from '$env/dynamic/private';
25

3-
export const handle = (async ({ event, resolve }) => {
4-
if (event.url.pathname.startsWith('/tutorials')) {
5-
throw redirect(301, '/posts');
6-
}
6+
Sentry.init({
7+
dsn: 'https://518fe25472568a2e47252e6f29583c6b@o1029244.ingest.sentry.io/4506190917206016',
8+
tracesSampleRate: 1,
9+
environment: env.VERCEL_ENV || 'local'
10+
});
711

8-
if (event.url.pathname.startsWith('/tutorial')) {
9-
throw redirect(301, `/post/${event.url.pathname.split('/').at(-1)}`);
10-
}
12+
export const handle = sequence(Sentry.sentryHandle(), (async ({ event, resolve }) => {
13+
if (event.url.pathname.startsWith('/tutorials')) {
14+
throw redirect(301, '/posts');
15+
}
1116

12-
const response = await resolve(event);
13-
return response;
14-
}) satisfies Handle;
17+
if (event.url.pathname.startsWith('/tutorial')) {
18+
throw redirect(301, `/post/${event.url.pathname.split('/').at(-1)}`);
19+
}
20+
21+
const response = await resolve(event);
22+
return response;
23+
}) satisfies Handle);
24+
export const handleError = Sentry.handleErrorWithSentry();

apps/codingcatdev/vite.config.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1+
import { sentrySvelteKit } from "@sentry/sveltekit";
12
import { sveltekit } from '@sveltejs/kit/vite';
23

34
/** @type {import('vite').UserConfig} */
45
const config = {
5-
plugins: [sveltekit()],
6-
test: {
6+
plugins: [sentrySvelteKit({
7+
sourceMapsUploadOptions: {
8+
org: "codingcatdev",
9+
project: "codingcatdev-main"
10+
}
11+
}), sveltekit()],
12+
13+
test: {
714
include: ['src/**/*.{test,spec}.{js,ts}']
815
},
9-
ssr: {
16+
17+
ssr: {
1018
noExternal: ['gsap', '@gsap/shockingly', '@cloudinary/html']
1119
}
1220
};
1321

14-
export default config;
22+
export default config;

0 commit comments

Comments
 (0)