fix: add withSentryConfig to enable Sentry tracing in production (#26743)
This adds the withSentryConfig wrapper to the Next.js configuration, which is required for Sentry tracing to work properly. The wrapper is only applied in production when both NEXT_PUBLIC_SENTRY_DSN and SENTRY_TRACES_SAMPLE_RATE environment variables are set. Without this wrapper, Sentry cannot properly instrument the build for performance monitoring, causing spans (including calendar telemetry) to not be recorded despite the SDK being initialized. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
6fb42b63e0
commit
dd4e8344c9
+22
-2
@@ -1,16 +1,17 @@
|
||||
import process from "node:process";
|
||||
import { withSentryConfig } from "@sentry/nextjs";
|
||||
import { withBotId } from "botid/next/config";
|
||||
import { config as dotenvConfig } from "dotenv";
|
||||
import type { NextConfig } from "next";
|
||||
import type { RouteHas } from "next/dist/lib/load-custom-routes";
|
||||
import { withAxiom } from "next-axiom";
|
||||
|
||||
import i18nConfig from "./next-i18next.config";
|
||||
import packageJson from "./package.json";
|
||||
import {
|
||||
nextJsOrgRewriteConfig,
|
||||
orgUserRoutePath,
|
||||
orgUserTypeRoutePath,
|
||||
orgUserTypeEmbedRoutePath,
|
||||
orgUserTypeRoutePath,
|
||||
} from "./pagesAndRewritePaths";
|
||||
|
||||
dotenvConfig({ path: "../../.env" });
|
||||
@@ -139,6 +140,25 @@ if (process.env.NEXT_PUBLIC_VERCEL_USE_BOTID_IN_BOOKER === "1") {
|
||||
plugins.push(withBotId);
|
||||
}
|
||||
|
||||
const sentryTracesSampleRate = parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE ?? "0.0") || 0.0;
|
||||
const isSentryEnabled =
|
||||
process.env.NODE_ENV === "production" &&
|
||||
process.env.NEXT_PUBLIC_SENTRY_DSN &&
|
||||
sentryTracesSampleRate > 0;
|
||||
|
||||
if (isSentryEnabled) {
|
||||
plugins.push((config) =>
|
||||
withSentryConfig(config, {
|
||||
silent: !process.env.SENTRY_DEBUG,
|
||||
org: process.env.SENTRY_ORG,
|
||||
project: process.env.SENTRY_PROJECT,
|
||||
authToken: process.env.SENTRY_AUTH_TOKEN,
|
||||
widenClientFileUpload: true,
|
||||
disableLogger: true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
interface OrgDomainMatcher {
|
||||
has: RouteHas[];
|
||||
source: string;
|
||||
|
||||
Reference in New Issue
Block a user