diff --git a/apps/web/next.config.js b/apps/web/next.config.js index c63cbe02a6..c2df7ed2a3 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -3,6 +3,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin"); const os = require("os"); const englishTranslation = require("./public/static/locales/en/common.json"); const { withAxiom } = require("next-axiom"); +const { withSentryConfig } = require("@sentry/nextjs"); const { version } = require("./package.json"); const { i18n } = require("./next-i18next.config"); const { @@ -92,6 +93,11 @@ if (process.env.ANALYZE === "true") { } plugins.push(withAxiom); + +if (!!process.env.NEXT_PUBLIC_SENTRY_DSN) { + plugins.push(withSentryConfig); +} + const matcherConfigRootPath = { has: [ { @@ -149,6 +155,10 @@ const nextConfig = { localeDetection: false, }, productionBrowserSourceMaps: true, + sentry: { + autoInstrumentServerFunctions: true, + hideSourceMaps: true, + }, /* We already do type check on GH actions */ typescript: { ignoreBuildErrors: !!process.env.CI, diff --git a/apps/web/pages/api/trpc/slots/[trpc].ts b/apps/web/pages/api/trpc/slots/[trpc].ts index c220bf20f7..65d5683576 100644 --- a/apps/web/pages/api/trpc/slots/[trpc].ts +++ b/apps/web/pages/api/trpc/slots/[trpc].ts @@ -1,4 +1,6 @@ +import { wrapApiHandlerWithSentry } from "@sentry/nextjs"; + import { createNextApiHandler } from "@calcom/trpc/server/createNextApiHandler"; import { slotsRouter } from "@calcom/trpc/server/routers/viewer/slots/_router"; -export default createNextApiHandler(slotsRouter); +export default wrapApiHandlerWithSentry(createNextApiHandler(slotsRouter, "/api/trpc/slots/[trpc]")); diff --git a/apps/web/sentry.client.config.ts b/apps/web/sentry.client.config.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/web/sentry.edge.config.ts b/apps/web/sentry.edge.config.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/apps/web/sentry.server.config.ts b/apps/web/sentry.server.config.ts new file mode 100644 index 0000000000..55fe566090 --- /dev/null +++ b/apps/web/sentry.server.config.ts @@ -0,0 +1,6 @@ +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + tracesSampleRate: 0, +}); diff --git a/turbo.json b/turbo.json index 849d70f2fe..4463f6faf0 100644 --- a/turbo.json +++ b/turbo.json @@ -26,6 +26,7 @@ "outputs": [".next/**"], "env": [ "NEXT_PUBLIC_IS_E2E", + "NEXT_PUBLIC_SENTRY_DSN", "NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRICE_MONTHLY", "NEXT_PUBLIC_STRIPE_PREMIUM_PLAN_PRODUCT_ID", "NEXT_PUBLIC_STRIPE_PUBLIC_KEY",