From 2352bb107543095b1e110db4825549dfd8a07aac Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Tue, 12 Dec 2023 14:57:39 -0800 Subject: [PATCH] chore: Wire up Sentry for API (#12756) --- apps/api/next.config.js | 17 +++++++++++++++-- apps/api/sentry.client.config.ts | 1 + apps/api/sentry.edge.config.ts | 5 +++++ apps/api/sentry.server.config.ts | 6 ++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 apps/api/sentry.client.config.ts create mode 100644 apps/api/sentry.edge.config.ts create mode 100644 apps/api/sentry.server.config.ts diff --git a/apps/api/next.config.js b/apps/api/next.config.js index ba2dcbf89b..4d861ce3c3 100644 --- a/apps/api/next.config.js +++ b/apps/api/next.config.js @@ -1,6 +1,8 @@ const { withAxiom } = require("next-axiom"); +const { withSentryConfig } = require("@sentry/nextjs"); -module.exports = withAxiom({ +const plugins = [withAxiom]; +const nextConfig = { transpilePackages: [ "@calcom/app-store", "@calcom/core", @@ -66,4 +68,15 @@ module.exports = withAxiom({ ], }; }, -}); +}; + +if (!!process.env.NEXT_PUBLIC_SENTRY_DSN) { + nextConfig["sentry"] = { + autoInstrumentServerFunctions: true, + hideSourceMaps: true, + }; + + plugins.push(withSentryConfig); +} + +module.exports = () => plugins.reduce((acc, next) => next(acc), nextConfig); diff --git a/apps/api/sentry.client.config.ts b/apps/api/sentry.client.config.ts new file mode 100644 index 0000000000..cb0ff5c3b5 --- /dev/null +++ b/apps/api/sentry.client.config.ts @@ -0,0 +1 @@ +export {}; diff --git a/apps/api/sentry.edge.config.ts b/apps/api/sentry.edge.config.ts new file mode 100644 index 0000000000..842f09fccc --- /dev/null +++ b/apps/api/sentry.edge.config.ts @@ -0,0 +1,5 @@ +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, +}); diff --git a/apps/api/sentry.server.config.ts b/apps/api/sentry.server.config.ts new file mode 100644 index 0000000000..a429088bd9 --- /dev/null +++ b/apps/api/sentry.server.config.ts @@ -0,0 +1,6 @@ +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + tracesSampleRate: 1.0, +});