diff --git a/backend/danswer/background/celery/apps/app_base.py b/backend/danswer/background/celery/apps/app_base.py index b74cba1df..add04c91a 100644 --- a/backend/danswer/background/celery/apps/app_base.py +++ b/backend/danswer/background/celery/apps/app_base.py @@ -36,7 +36,7 @@ if SENTRY_DSN: sentry_sdk.init( dsn=SENTRY_DSN, integrations=[CeleryIntegration()], - traces_sample_rate=0.5, + traces_sample_rate=0.1, ) logger.info("Sentry initialized") else: diff --git a/backend/danswer/configs/app_configs.py b/backend/danswer/configs/app_configs.py index 5be2b68d2..8710569ea 100644 --- a/backend/danswer/configs/app_configs.py +++ b/backend/danswer/configs/app_configs.py @@ -134,7 +134,6 @@ try: except ValueError: INDEX_BATCH_SIZE = 16 - # Below are intended to match the env variables names used by the official postgres docker image # https://hub.docker.com/_/postgres POSTGRES_USER = os.environ.get("POSTGRES_USER") or "postgres" diff --git a/backend/danswer/main.py b/backend/danswer/main.py index a6a338b4c..ef262b2fa 100644 --- a/backend/danswer/main.py +++ b/backend/danswer/main.py @@ -213,7 +213,7 @@ def get_application() -> FastAPI: sentry_sdk.init( dsn=SENTRY_DSN, integrations=[StarletteIntegration(), FastApiIntegration()], - traces_sample_rate=0.5, + traces_sample_rate=0.1, ) logger.info("Sentry initialized") else: diff --git a/backend/model_server/main.py b/backend/model_server/main.py index 5505bbc8c..ce9cc724a 100644 --- a/backend/model_server/main.py +++ b/backend/model_server/main.py @@ -89,7 +89,7 @@ def get_model_app() -> FastAPI: sentry_sdk.init( dsn=SENTRY_DSN, integrations=[StarletteIntegration(), FastApiIntegration()], - traces_sample_rate=0.5, + traces_sample_rate=0.1, ) logger.info("Sentry initialized") else: diff --git a/web/next.config.js b/web/next.config.js index 684b43ffc..950ab2167 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -15,12 +15,15 @@ const nextConfig = { const { withSentryConfig } = require("@sentry/nextjs"); +// Sentry configuration for error monitoring: +// - Without SENTRY_AUTH_TOKEN and NEXT_PUBLIC_SENTRY_DSN: Sentry is completely disabled +// - With both configured: Only unhandled errors are captured (no performance/session tracking) module.exports = withSentryConfig(nextConfig, { - org: "danswer", - project: "javascript-nextjs", - - // An auth token is required for uploading source maps. + org: process.env.SENTRY_ORG || "danswer", + project: process.env.SENTRY_PROJECT || "data-plane-web", authToken: process.env.SENTRY_AUTH_TOKEN, - - silent: false, // Can be used to suppress logs + silent: false, + sourceMaps: { + skipUpload: !process.env.SENTRY_AUTH_TOKEN, + }, }); diff --git a/web/sentry.client.config.ts b/web/sentry.client.config.ts index f6e0e7d1a..0a0fe92c4 100644 --- a/web/sentry.client.config.ts +++ b/web/sentry.client.config.ts @@ -3,21 +3,12 @@ import * as Sentry from "@sentry/nextjs"; if (process.env.NEXT_PUBLIC_SENTRY_DSN) { Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - // Replay may only be enabled for the client-side - integrations: [Sentry.replayIntegration()], - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, - - // Capture Replay for 10% of all sessions, - // plus for 100% of sessions with an error - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, - - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps + // Only capture unhandled exceptions + enableTracing: false, + integrations: [], + tracesSampleRate: 0, + replaysSessionSampleRate: 0, + replaysOnErrorSampleRate: 0, + autoSessionTracking: false, }); } diff --git a/web/sentry.edge.config.ts b/web/sentry.edge.config.ts index 4c0eac9e3..6a412ea21 100644 --- a/web/sentry.edge.config.ts +++ b/web/sentry.edge.config.ts @@ -3,14 +3,9 @@ import * as Sentry from "@sentry/nextjs"; if (process.env.NEXT_PUBLIC_SENTRY_DSN) { Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, - - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps + // Only capture unhandled exceptions + tracesSampleRate: 0, + enableTracing: false, + autoSessionTracking: false, }); } diff --git a/web/sentry.server.config.ts b/web/sentry.server.config.ts index 4c0eac9e3..3cc7749a7 100644 --- a/web/sentry.server.config.ts +++ b/web/sentry.server.config.ts @@ -4,10 +4,12 @@ if (process.env.NEXT_PUBLIC_SENTRY_DSN) { Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for tracing. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, + // Only capture unhandled exceptions and errors + tracesSampleRate: 0, + enableTracing: false, + + // Disable performance monitoring and only capture errors + profilesSampleRate: 0, // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 2ce657b2c..467a03dee 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -50,7 +50,6 @@ import { useContext, useEffect, useLayoutEffect, - useMemo, useRef, useState, } from "react"; @@ -2392,6 +2391,7 @@ export function ChatPage({ {/* Some padding at the bottom so the search bar has space at the bottom to not cover the last message*/}
+
diff --git a/web/src/app/global-error.tsx b/web/src/app/global-error.tsx index 1ef2941b2..6fbb642c7 100644 --- a/web/src/app/global-error.tsx +++ b/web/src/app/global-error.tsx @@ -11,7 +11,9 @@ export default function GlobalError({ error: Error & { digest?: string }; }) { useEffect(() => { - Sentry.captureException(error); + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { + Sentry.captureException(error); + } }, [error]); return (