🪢 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
feat(ee): add ui customization, e.g. docs, support, feedback links (#2924)
Marc Klingenf37dc514a5a2
diff --git a/.env.prod.example b/.env.prod.exampleindex 084f48fdc6..2efa287136 100644--- a/.env.prod.example+++ b/.env.prod.example@@ -107,6 +107,12 @@ ENCRYPTION_KEY="0000000000000000000000000000000000000000000000000000000000000000# Allowlisted users that can create new organizations, by default all users can create organizations+# UI Customization Options+# LANGFUSE_UI_API_HOST=https://api.example.com+# LANGFUSE_UI_DOCUMENTATION_HREF=https://docs.example.com+# LANGFUSE_UI_SUPPORT_HREF=https://support.example.com+# LANGFUSE_UI_FEEDBACK_HREF=https://feedback.example.com+### END Enterprise Edition Configurationdiff --git a/web/src/components/VersionLabel.tsx b/web/src/components/VersionLabel.tsxindex a94c71e361..c4a25a4703 100644--- a/web/src/components/VersionLabel.tsx+++ b/web/src/components/VersionLabel.tsx@@ -29,8 +29,7 @@ export const VersionLabel = ({ className }: { className?: string }) => {enabled: !env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION, // do not check for updates on Langfuse CloudonError: (error) => console.error("checkUpdate error", error), // do not render default error message});- const isEeVersion =- useIsEeEnabled() && !Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION);+ const isEeVersion = useIsEeEnabled();const hasUpdate =!env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION &&diff --git a/web/src/components/layouts/layout.tsx b/web/src/components/layouts/layout.tsxindex 88cabba1a5..7aea93211b 100644--- a/web/src/components/layouts/layout.tsx+++ b/web/src/components/layouts/layout.tsx@@ -32,6 +32,7 @@ import { ThemeToggle } from "@/src/features/theming/ThemeToggle";import { EnvLabel } from "@/src/components/EnvLabel";import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";import { useOrgEntitlements } from "@/src/features/entitlements/hooks";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";const signOutUser = async () => {localStorage.clear();@@ -115,6 +116,8 @@ export default function Layout(props: PropsWithChildren) {const entitlements = useOrgEntitlements();+ const uiCustomization = useUiCustomization();+// project info based on projectId in the URLconst { project, organization } = useQueryProjectOrOrganization();@@ -161,11 +164,22 @@ export default function Layout(props: PropsWithChildren) {const children: (NavigationItem | null)[] =route.children?.map((child) => mapNavigation(child)).filter(Boolean) ??[];++ const href = (+ route.customizableHref+ ? uiCustomization?.[route.customizableHref] ?? route.pathname+ : route.pathname+ )+ ?.replace("[projectId]", routerProjectId ?? "")+ .replace("[organizationId]", routerOrganizationId ?? "");+return {...route,- href: route.pathname- ?.replace("[projectId]", routerProjectId ?? "")- .replace("[organizationId]", routerOrganizationId ?? ""),+ href,+ newTab:+ route.customizableHref && uiCustomization?.[route.customizableHref]+ ? true+ : route.newTab,current: router.pathname === route.pathname,children:children.length > 0@@ -174,10 +188,9 @@ export default function Layout(props: PropsWithChildren) {};};- const navigationMapped: (NavigationItem | null)[] = ROUTES.map((route) =>- mapNavigation(route),- ).filter(Boolean);- const navigation = navigationMapped.filter(Boolean) as NavigationItem[]; // does not include null due to filter+ const navigation = ROUTES.map((route) => mapNavigation(route)).filter(+ (item): item is NavigationItem => Boolean(item),+ );const topNavigation = navigation.filter(({ bottom }) => !bottom);const bottomNavigation = navigation.filter(({ bottom }) => bottom);@@ -340,20 +353,32 @@ export default function Layout(props: PropsWithChildren) {<EnvLabel className="my-2" /><MainNavigation nav={topNavigation} /><MainNavigation nav={bottomNavigation} className="mt-auto" />- <FeedbackButtonWrapper- className="space-y-1"- title="Provide feedback"- description="What do you think about this project? What can be improved?"- type="feedback"- >- <li className="group -mx-2 my-1 flex cursor-pointer gap-x-3 rounded-md p-1.5 text-sm font-semibold text-primary hover:bg-primary-foreground hover:text-primary-accent">- <MessageSquarePlus- className="h-5 w-5 shrink-0 text-muted-foreground group-hover:text-primary-accent"- aria-hidden="true"- />- Feedback- </li>- </FeedbackButtonWrapper>+ {uiCustomization?.feedbackHref ? (+ <Link href={uiCustomization.feedbackHref}>+ <li className="group -mx-2 my-1 flex cursor-pointer gap-x-3 rounded-md p-1.5 text-sm font-semibold text-primary hover:bg-primary-foreground hover:text-primary-accent">+ <MessageSquarePlus+ className="h-5 w-5 shrink-0 text-muted-foreground group-hover:text-primary-accent"+ aria-hidden="true"+ />+ Feedback+ </li>+ </Link>+ ) : (+ <FeedbackButtonWrapper+ className="space-y-1"+ title="Provide feedback"+ description="What do you think about this project? What can be improved?"+ type="feedback"+ >+ <li className="group -mx-2 my-1 flex cursor-pointer gap-x-3 rounded-md p-1.5 text-sm font-semibold text-primary hover:bg-primary-foreground hover:text-primary-accent">+ <MessageSquarePlus+ className="h-5 w-5 shrink-0 text-muted-foreground group-hover:text-primary-accent"+ aria-hidden="true"+ />+ Feedback+ </li>+ </FeedbackButtonWrapper>+ )}</ul></nav>diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsxindex 12888f1085..0e1507f216 100644--- a/web/src/components/layouts/routes.tsx+++ b/web/src/components/layouts/routes.tsx@@ -18,6 +18,7 @@ import { LangfuseIcon } from "@/src/components/LangfuseLogo";import { type ReactNode } from "react";import { VersionLabel } from "@/src/components/VersionLabel";import { type Entitlement } from "@/src/features/entitlements/constants/entitlements";+import { type UiCustomizationOption } from "@/src/ee/features/ui-customization/useUiCustomization";export type Route = {name: string;@@ -30,6 +31,7 @@ export type Route = {bottom?: boolean; // bottom of the sidebar, only for first level routesnewTab?: boolean; // open in new tabentitlement?: Entitlement; // entitlement required+ customizableHref?: UiCustomizationOption; // key of useUiCustomization object to use to replace the href};export const ROUTES: Route[] = [@@ -141,11 +143,13 @@ export const ROUTES: Route[] = [icon: LibraryBig,bottom: true,newTab: true,+ customizableHref: "documentationHref",},{name: "Support",pathname: "/support",icon: LifeBuoy,bottom: true,+ customizableHref: "supportHref",},];diff --git a/web/src/ee/features/ui-customization/uiCustomizationRouter.ts b/web/src/ee/features/ui-customization/uiCustomizationRouter.tsnew file mode 100644index 0000000000..8e1ce0eefd--- /dev/null+++ b/web/src/ee/features/ui-customization/uiCustomizationRouter.ts@@ -0,0 +1,15 @@+import { env } from "@/src/env.mjs";+import { createTRPCRouter, protectedProcedure } from "@/src/server/api/trpc";++export const uiCustomizationRouter = createTRPCRouter({+ get: protectedProcedure.query(({ ctx }) => {+ if (!ctx.session.environment.eeEnabled) return null;++ return {+ hostname: env.LANGFUSE_UI_API_HOST,+ documentationHref: env.LANGFUSE_UI_DOCUMENTATION_HREF,+ supportHref: env.LANGFUSE_UI_SUPPORT_HREF,+ feedbackHref: env.LANGFUSE_UI_FEEDBACK_HREF,+ };+ }),+});diff --git a/web/src/ee/features/ui-customization/useUiCustomization.ts b/web/src/ee/features/ui-customization/useUiCustomization.tsnew file mode 100644index 0000000000..4c9b4e8901--- /dev/null+++ b/web/src/ee/features/ui-customization/useUiCustomization.ts@@ -0,0 +1,19 @@+import { useIsEeEnabled } from "@/src/ee/utils/useIsEeEnabled";+import { api } from "@/src/utils/api";++export const useUiCustomization = () => {+ const isEeVersion = useIsEeEnabled();+ const customization = api.uiCustomization.get.useQuery(undefined, {+ enabled: isEeVersion,+ refetchOnMount: false,+ refetchOnWindowFocus: false,+ refetchOnReconnect: false,+ });++ if (!isEeVersion) return null;+ return customization.data ?? null;+};++export type UiCustomizationOption = keyof NonNullable<+ ReturnType<typeof useUiCustomization>+>;diff --git a/web/src/ee/utils/useIsEeEnabled.ts b/web/src/ee/utils/useIsEeEnabled.tsindex 30ecba754a..d9b977d9a5 100644--- a/web/src/ee/utils/useIsEeEnabled.ts+++ b/web/src/ee/utils/useIsEeEnabled.ts@@ -1,20 +1,10 @@-import { env } from "@/src/env.mjs";import { useSession } from "next-auth/react";/*** Custom React frontend hook to determine if the enterprise edition (EE) features are enabled.- *- * This hook checks two conditions:- * 1. If Langfuse is running on Langfuse Cloud- * 2. If EE license is provided based on the user's session- *- * @returns {boolean}*/export const useIsEeEnabled: () => boolean = () => {const session = useSession();- return (- Boolean(env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) ||- Boolean(session.data?.environment.eeEnabled)- );+ return Boolean(session.data?.environment.eeEnabled);};diff --git a/web/src/env.mjs b/web/src/env.mjsindex b3e8b9e837..fd88a79449 100644--- a/web/src/env.mjs+++ b/web/src/env.mjs@@ -115,6 +115,11 @@ export const env = createEnv({CLICKHOUSE_URL: z.string().optional(),CLICKHOUSE_USER: z.string().optional(),CLICKHOUSE_PASSWORD: z.string().optional(),+ // EE ui customization+ LANGFUSE_UI_API_HOST: z.string().optional(),+ LANGFUSE_UI_DOCUMENTATION_HREF: z.string().url().optional(),+ LANGFUSE_UI_SUPPORT_HREF: z.string().url().optional(),+ LANGFUSE_UI_FEEDBACK_HREF: z.string().url().optional(),// EE LicenseLANGFUSE_EE_LICENSE_KEY: z.string().optional(),ADMIN_API_KEY: z.string().optional(),@@ -273,6 +278,11 @@ export const env = createEnv({CLICKHOUSE_URL: process.env.CLICKHOUSE_URL,CLICKHOUSE_USER: process.env.CLICKHOUSE_USER,CLICKHOUSE_PASSWORD: process.env.CLICKHOUSE_PASSWORD,+ // EE ui customization+ LANGFUSE_UI_API_HOST: process.env.LANGFUSE_UI_API_HOST,+ LANGFUSE_UI_DOCUMENTATION_HREF: process.env.LANGFUSE_UI_DOCUMENTATION_HREF,+ LANGFUSE_UI_SUPPORT_HREF: process.env.LANGFUSE_UI_SUPPORT_HREF,+ LANGFUSE_UI_FEEDBACK_HREF: process.env.LANGFUSE_UI_FEEDBACK_HREF,// EE LicenseLANGFUSE_EE_LICENSE_KEY: process.env.LANGFUSE_EE_LICENSE_KEY,ADMIN_API_KEY: process.env.ADMIN_API_KEY,diff --git a/web/src/features/projects/components/HostNameProject.tsx b/web/src/features/projects/components/HostNameProject.tsxindex a8f8e5a6cd..d5f2de143e 100644--- a/web/src/features/projects/components/HostNameProject.tsx+++ b/web/src/features/projects/components/HostNameProject.tsx@@ -1,8 +1,10 @@import { Card } from "@/src/components/ui/card";import { CodeView } from "@/src/components/ui/CodeJsonViewer";import Header from "@/src/components/layouts/header";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";export function HostNameProject() {+ const uiCustomization = useUiCustomization();return (<div><Header title="Host Name" level="h3" />@@ -11,7 +13,7 @@ export function HostNameProject() {<div className="mb-2 text-sm">When connecting to Langfuse, use this hostname / baseurl.</div>- <CodeView content={window.origin} />+ <CodeView content={uiCustomization?.hostname ?? window.origin} /></div></Card></div>diff --git a/web/src/features/public-api/components/CreateApiKeyButton.tsx b/web/src/features/public-api/components/CreateApiKeyButton.tsxindex 441358e2d5..5a716abdff 100644--- a/web/src/features/public-api/components/CreateApiKeyButton.tsx+++ b/web/src/features/public-api/components/CreateApiKeyButton.tsx@@ -12,6 +12,7 @@ import { CodeView } from "@/src/components/ui/CodeJsonViewer";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { QuickstartExamples } from "@/src/features/public-api/components/QuickstartExamples";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";export function CreateApiKeyButton(props: { projectId: string }) {const utils = api.useUtils();@@ -71,12 +72,11 @@ export function CreateApiKeyButton(props: { projectId: string }) {<div className="shrink overflow-x-hidden overflow-y-scroll"><ApiKeyRender generatedKeys={generatedKeys ?? undefined} />{generatedKeys && (- <div className="mb-2 max-w-full">+ <div className="mt-4 max-w-full"><div className="text-md my-2 font-semibold">Usage</div><QuickstartExamplessecretKey={generatedKeys.secretKey}publicKey={generatedKeys.publicKey}- host={window.origin}/></div>)}@@ -91,6 +91,7 @@ export const ApiKeyRender = ({}: {generatedKeys?: { secretKey: string; publicKey: string };}) => {+ const uiCustomization = useUiCustomization();return (<><div className="mb-4">@@ -107,7 +108,7 @@ export const ApiKeyRender = ({</div><div><div className="text-md mb-2 font-semibold">Host</div>- <CodeView content={window.origin} />+ <CodeView content={uiCustomization?.hostname ?? window.origin} /></div></>);diff --git a/web/src/features/public-api/components/QuickstartExamples.tsx b/web/src/features/public-api/components/QuickstartExamples.tsxindex 72d30f6d4d..4caffb4c17 100644--- a/web/src/features/public-api/components/QuickstartExamples.tsx+++ b/web/src/features/public-api/components/QuickstartExamples.tsx@@ -5,17 +5,18 @@ import {TabsContent,TabsTrigger,} from "@/src/components/ui/tabs";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import Link from "next/link";export const QuickstartExamples = ({secretKey,publicKey,- host,}: {secretKey: string;publicKey: string;- host: string;}) => {+ const uiCustomization = useUiCustomization();const capture = usePostHogClientCapture();const tabs = [{ value: "python", label: "Python" },@@ -26,6 +27,24 @@ export const QuickstartExamples = ({{ value: "llamaindex", label: "LlamaIndex" },{ value: "other", label: "Other" },];+ const host = uiCustomization?.hostname ?? window.origin;++ // if custom docs link, do not show quickstart examples but refer to docs+ if (uiCustomization?.documentationHref) {+ return (+ <p className="mb-2">+ See your{" "}+ <Link+ href={uiCustomization.documentationHref}+ target="_blank"+ className="underline"+ >+ internal documentation+ </Link>{" "}+ for details on how to set up Langfuse in your organization.+ </p>+ );+ }return (<Tabs defaultValue="python" className="relative max-w-full">diff --git a/web/src/features/setup/components/SetupPage.tsx b/web/src/features/setup/components/SetupPage.tsxindex 2306bd96e8..181fd6dc50 100644--- a/web/src/features/setup/components/SetupPage.tsx+++ b/web/src/features/setup/components/SetupPage.tsx@@ -252,7 +252,6 @@ const TracingSetup = ({<QuickstartExamplessecretKey={apiKeys.secretKey}publicKey={apiKeys.publicKey}- host={window.origin}/></div>)}diff --git a/web/src/pages/project/[projectId]/index.tsx b/web/src/pages/project/[projectId]/index.tsxindex f9b608ae22..79483a2d84 100644--- a/web/src/pages/project/[projectId]/index.tsx+++ b/web/src/pages/project/[projectId]/index.tsx@@ -24,6 +24,7 @@ import { findClosestDashboardInterval } from "@/src/utils/date-range-utils";import { useDashboardDateRange } from "@/src/hooks/useDashboardDateRange";import { useDebounce } from "@/src/hooks/useDebounce";import SetupTracingButton from "@/src/features/setup/components/SetupTracingButton";+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";export default function Dashboard() {const router = useRouter();@@ -31,6 +32,8 @@ export default function Dashboard() {const { selectedOption, dateRange, setDateRangeAndOption } =useDashboardDateRange();+ const uiCustomization = useUiCustomization();+const session = useSession();const disableExpensiveDashboardComponents =session.data?.environment.disableExpensivePostgresQueries ?? true;@@ -147,26 +150,28 @@ export default function Dashboard() {onChange={useDebounce(setUserFilterState)}/></div>- <FeedbackButtonWrapper- title="Request Chart"- description="Your feedback matters! Let the Langfuse team know what additional data or metrics you'd like to see in your dashboard."- type="dashboard"- className="hidden lg:flex"- >- <Button- id="date"- variant={"outline"}- className={- "group justify-start gap-x-3 text-left font-semibold text-primary hover:bg-primary-foreground hover:text-primary-accent"- }+ {uiCustomization?.feedbackHref === undefined && (+ <FeedbackButtonWrapper+ title="Request Chart"+ description="Your feedback matters! Let the Langfuse team know what additional data or metrics you'd like to see in your dashboard."+ type="dashboard"+ className="hidden lg:flex">- <BarChart2- className="hidden h-6 w-6 shrink-0 text-primary group-hover:text-primary-accent lg:block"- aria-hidden="true"- />- Request Chart- </Button>- </FeedbackButtonWrapper>+ <Button+ id="date"+ variant={"outline"}+ className={+ "group justify-start gap-x-3 text-left font-semibold text-primary hover:bg-primary-foreground hover:text-primary-accent"+ }+ >+ <BarChart2+ className="hidden h-6 w-6 shrink-0 text-primary group-hover:text-primary-accent lg:block"+ aria-hidden="true"+ />+ Request Chart+ </Button>+ </FeedbackButtonWrapper>+ )}</div><div className="grid w-full grid-cols-1 gap-4 overflow-hidden lg:grid-cols-2 xl:grid-cols-6"><TracesBarListChartdiff --git a/web/src/server/api/root.ts b/web/src/server/api/root.tsindex 380700d0d6..c04076b2c0 100644--- a/web/src/server/api/root.ts+++ b/web/src/server/api/root.ts@@ -22,6 +22,7 @@ import { publicRouter } from "@/src/server/api/routers/public";import { credentialsRouter } from "@/src/features/auth-credentials/server/credentialsRouter";import { batchExportRouter } from "@/src/server/api/routers/batchExport";import { utilsRouter } from "@/src/server/api/routers/utilities";+import { uiCustomizationRouter } from "@/src/ee/features/ui-customization/uiCustomizationRouter";/*** This is the primary router for your server.@@ -52,6 +53,7 @@ export const appRouter = createTRPCRouter({public: publicRouter,credentials: credentialsRouter,utilities: utilsRouter,+ uiCustomization: uiCustomizationRouter,});// export type definition of API