🪢 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
refactor(integrations): share prisma not found classifier (#15926)
Max Deichmannac6020bb4f5e
diff --git a/web/src/features/analytics-integrations/server/isPrismaRecordNotFoundError.ts b/web/src/features/analytics-integrations/server/isPrismaRecordNotFoundError.tsnew file mode 100644index 0000000000..cd6299b502--- /dev/null+++ b/web/src/features/analytics-integrations/server/isPrismaRecordNotFoundError.ts@@ -0,0 +1,5 @@+import { Prisma } from "@langfuse/shared/src/db";++export const isPrismaRecordNotFoundError = (error: unknown): boolean =>+ error instanceof Prisma.PrismaClientKnownRequestError &&+ error.code === "P2025";diff --git a/web/src/features/mixpanel-integration/mixpanel-integration-router.ts b/web/src/features/mixpanel-integration/mixpanel-integration-router.tsindex 0a2baf6198..722669618d 100644--- a/web/src/features/mixpanel-integration/mixpanel-integration-router.ts+++ b/web/src/features/mixpanel-integration/mixpanel-integration-router.ts@@ -2,6 +2,7 @@ import { z } from "zod";import { auditLog } from "@/src/features/audit-logs/auditLog";import { assertExportSourceAllowed } from "@/src/features/analytics-integrations/server/assertExportSourceAllowed";+import { isPrismaRecordNotFoundError } from "@/src/features/analytics-integrations/server/isPrismaRecordNotFoundError";import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,@@ -19,11 +20,6 @@ import {LangfuseNotFoundError,validateExportSource,} from "@langfuse/shared";-import { Prisma } from "@langfuse/shared/src/db";--const isMixpanelIntegrationNotFoundError = (error: unknown): boolean =>- error instanceof Prisma.PrismaClientKnownRequestError &&- error.code === "P2025";export const mixpanelIntegrationRouter = createTRPCRouter({get: protectedProjectProcedure@@ -232,7 +228,7 @@ export const mixpanelIntegrationRouter = createTRPCRouter({},});} catch (error) {- if (isMixpanelIntegrationNotFoundError(error)) {+ if (isPrismaRecordNotFoundError(error)) {throw new LangfuseNotFoundError("Mixpanel integration not found");}diff --git a/web/src/features/posthog-integration/posthog-integration-router.ts b/web/src/features/posthog-integration/posthog-integration-router.tsindex f678eff626..bfc4c86f8c 100644--- a/web/src/features/posthog-integration/posthog-integration-router.ts+++ b/web/src/features/posthog-integration/posthog-integration-router.ts@@ -2,6 +2,7 @@ import { z } from "zod";import { auditLog } from "@/src/features/audit-logs/auditLog";import { assertExportSourceAllowed } from "@/src/features/analytics-integrations/server/assertExportSourceAllowed";+import { isPrismaRecordNotFoundError } from "@/src/features/analytics-integrations/server/isPrismaRecordNotFoundError";import { throwIfNoProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import {createTRPCRouter,@@ -20,11 +21,6 @@ import {LangfuseNotFoundError,validateExportSource,} from "@langfuse/shared";-import { Prisma } from "@langfuse/shared/src/db";--const isPostHogIntegrationNotFoundError = (error: unknown): boolean =>- error instanceof Prisma.PrismaClientKnownRequestError &&- error.code === "P2025";export const posthogIntegrationRouter = createTRPCRouter({get: protectedProjectProcedure@@ -245,7 +241,7 @@ export const posthogIntegrationRouter = createTRPCRouter({},});} catch (error) {- if (isPostHogIntegrationNotFoundError(error)) {+ if (isPrismaRecordNotFoundError(error)) {throw new LangfuseNotFoundError("PostHog integration not found");}