diff --git a/apps/api/src/routes/api/v1/handlers.ts b/apps/api/src/routes/api/v1/handlers.ts index ffd3ddb05..b7b3ba55a 100644 --- a/apps/api/src/routes/api/v1/handlers.ts +++ b/apps/api/src/routes/api/v1/handlers.ts @@ -13,6 +13,7 @@ import { prisma, uniqueName, version, + sentryDSN, } from "../../../lib/common"; import { scheduler } from "../../../lib/scheduler"; import type { FastifyReply, FastifyRequest } from "fastify"; @@ -398,7 +399,8 @@ export async function getCurrentUser( } const pendingInvitations = await prisma.teamInvitation.findMany({ where: { uid: request.user.userId } }) return { - settings: await prisma.setting.findFirst(), + settings: await prisma.setting.findUnique({ where: { id: "0" } }), + sentryDSN, pendingInvitations, token, ...request.user, diff --git a/apps/ui/package.json b/apps/ui/package.json index 1cadeffd8..d40dba2a0 100644 --- a/apps/ui/package.json +++ b/apps/ui/package.json @@ -42,6 +42,8 @@ }, "type": "module", "dependencies": { + "@sentry/svelte": "7.21.1", + "@sentry/tracing": "7.21.1", "@sveltejs/adapter-static": "1.0.0-next.48", "@tailwindcss/typography": "0.5.8", "cuid": "2.1.8", diff --git a/apps/ui/src/hooks.ts b/apps/ui/src/hooks.ts index 30c352baa..df3284d5a 100644 --- a/apps/ui/src/hooks.ts +++ b/apps/ui/src/hooks.ts @@ -1,4 +1,13 @@ +import * as Sentry from '@sentry/svelte'; export async function handle({ event, resolve }) { const response = await resolve(event, { ssr: false }); return response; -} \ No newline at end of file +} +export const handleError = ({ error, event }) => { + Sentry.captureException(error, { event }); + + return { + message: 'Whoops!', + code: error?.code ?? 'UNKNOWN' + }; +}; \ No newline at end of file diff --git a/apps/ui/src/routes/__layout.svelte b/apps/ui/src/routes/__layout.svelte index 0ac80eebd..4cd58e800 100644 --- a/apps/ui/src/routes/__layout.svelte +++ b/apps/ui/src/routes/__layout.svelte @@ -64,6 +64,8 @@