🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: add sentry error capturing to multi-tenant sso (#2723)
Marc Klingene2c5c9b5cc8a
diff --git a/web/src/ee/features/multi-tenant-sso/utils.ts b/web/src/ee/features/multi-tenant-sso/utils.tsindex fd03f72ca0..60d78759a2 100644--- a/web/src/ee/features/multi-tenant-sso/utils.ts+++ b/web/src/ee/features/multi-tenant-sso/utils.ts@@ -10,6 +10,7 @@ import { type SsoConfig, prisma } from "@langfuse/shared/src/db";import { decrypt } from "@langfuse/shared/encryption";import { SsoProviderSchema } from "./types";import { CustomSSOProvider } from "@langfuse/shared/src/server";+import * as Sentry from "@sentry/node";// Local cache for SSO configurationslet cachedSsoConfigs: {@@ -44,14 +45,9 @@ async function getSsoConfigs(): Promise<SsoProviderSchema[]> {},);} catch (e) {- // cache empty array to prevent repeated DB calls on error- cachedSsoConfigs = {- data: [],- timestamp: Date.now(),- };-- // caught and logged in the caller- throw e;+ // empty array will be cached to prevent repeated DB queries+ console.error("Failed to load SSO configs from the database", e);+ Sentry.captureException(e);}// transform into zod object@@ -65,6 +61,7 @@ async function getSsoConfigs(): Promise<SsoProviderSchema[]> {`Failed to parse SSO provider config for domain ${v.domain}`,e,);+ Sentry.captureException(e);return null;}})@@ -185,9 +182,15 @@ const dbToNextAuthProvider = (provider: SsoProviderSchema): Provider | null => {// Type check to ensure we handle all providers// eslint-disable-next-line @typescript-eslint/no-unused-varsconst _: never = provider;- throw new Error(+ console.error(`Unrecognized SSO provider for domain ${(provider as any).domain}`,);+ Sentry.captureException(+ new Error(+ `Unrecognized SSO provider for domain ${(provider as any).domain}`,+ ),+ );+ return null;}};diff --git a/web/src/server/auth.ts b/web/src/server/auth.tsindex 514ac4f099..430ea95fb5 100644--- a/web/src/server/auth.ts+++ b/web/src/server/auth.ts@@ -354,9 +354,11 @@ export async function getAuthOptions(): Promise<NextAuthOptions> {// Block sign in without valid user.emailconst email = user.email?.toLowerCase();if (!email) {+ console.error("No email found in user object");throw new Error("No email found in user object");}if (z.string().email().safeParse(email).success === false) {+ console.error("Invalid email found in user object");throw new Error("Invalid email found in user object");}@@ -365,6 +367,9 @@ export async function getAuthOptions(): Promise<NextAuthOptions> {const domain = email.split("@")[1];const customSsoProvider = await getSsoAuthProviderIdForDomain(domain);if (customSsoProvider && account?.provider !== customSsoProvider) {+ console.log(+ "Custom SSO provider enforced for domain, user signed in with other provider",+ );throw new Error(`You must sign in via SSO for this domain.`);}