From ec29664a60bb31e9ace377a23f6a5b8c1661a5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20J=C3=A4derberg?= Date: Fri, 16 May 2025 11:44:25 +0000 Subject: [PATCH] Merged in fix/capture-errors-in-trpc (pull request #2103) Fix/capture errors in trpc * fix: import @sentry/nextjs, not @sentry/node * add sentry logging for errors in trpc Approved-by: Linus Flood --- apps/scandic-web/lib/trpc/server.ts | 14 ++++++++++++++ apps/scandic-web/server/trpc.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/scandic-web/lib/trpc/server.ts b/apps/scandic-web/lib/trpc/server.ts index 5d8539a8a..70a417749 100644 --- a/apps/scandic-web/lib/trpc/server.ts +++ b/apps/scandic-web/lib/trpc/server.ts @@ -1,3 +1,4 @@ +import * as Sentry from "@sentry/nextjs" import { TRPCError } from "@trpc/server" import { redirect } from "next/navigation" @@ -49,6 +50,19 @@ export function serverClient() { redirect(redirectUrl) } } + + Sentry.captureException(error, { + extra: { + input, + path, + type, + url: ctx?.url, + lang: ctx?.lang, + pathname: ctx?.pathname, + contentType: ctx?.contentType, + uid: ctx?.uid, + }, + }) }, }) } diff --git a/apps/scandic-web/server/trpc.ts b/apps/scandic-web/server/trpc.ts index 44a30fda9..f33e06f1f 100644 --- a/apps/scandic-web/server/trpc.ts +++ b/apps/scandic-web/server/trpc.ts @@ -1,4 +1,4 @@ -import * as Sentry from "@sentry/node" +import * as Sentry from "@sentry/nextjs" import { initTRPC } from "@trpc/server" import { experimental_nextAppDirCaller } from "@trpc/server/adapters/next-app-dir" import { ZodError } from "zod"