Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(ui-ee): show/hide product modules in main menu via LANGFUSE_UI_VISIBLE/HIDDEN_PRODUCT_MODULES (#6841)

Marc Klingenadc05eeef46f
diff --git a/.env.prod.example b/.env.prod.example
index 277301bbf8..c932dd210e 100644
--- a/.env.prod.example
+++ b/.env.prod.example
@@ -211,6 +211,8 @@ OTEL_SERVICE_NAME="langfuse"
# LANGFUSE_UI_DEFAULT_BASE_URL_OPENAI=https://api.openai.com/v1
# LANGFUSE_UI_DEFAULT_BASE_URL_ANTHROPIC=https://api.anthropic.com
# LANGFUSE_UI_DEFAULT_BASE_URL_AZURE_OPENAI=https://{instanceName}.openai.azure.com/openai/deployments
+# LANGFUSE_UI_VISIBLE_PRODUCT_MODULES=
+# LANGFUSE_UI_HIDDEN_PRODUCT_MODULES=
### END Enterprise Edition Configuration
diff --git a/web/src/components/layouts/layout.tsx b/web/src/components/layouts/layout.tsx
index d77570884b..56f113d230 100644
--- a/web/src/components/layouts/layout.tsx
+++ b/web/src/components/layouts/layout.tsx
@@ -122,6 +122,14 @@ export default function Layout(props: PropsWithChildren) {
if (!routerOrganizationId && route.pathname.includes("[organizationId]"))
return null;
+ // UI customization – hide routes that belong to a disabled product module
+ if (
+ route.productModule &&
+ uiCustomization !== null &&
+ !uiCustomization.visibleModules.includes(route.productModule)
+ )
+ return null;
+
// Feature Flags
if (
route.featureFlag !== undefined &&
@@ -176,21 +184,14 @@ export default function Layout(props: PropsWithChildren) {
const items: (NavigationItem | null)[] =
route.items?.map((item) => mapNavigation(item)).filter(Boolean) ?? [];
- const url = (
- route.customizableHref
- ? (uiCustomization?.[route.customizableHref] ?? route.pathname)
- : route.pathname
- )
+ const url = route.pathname
+
?.replace("[projectId]", routerProjectId ?? "")
.replace("[organizationId]", routerOrganizationId ?? "");
return {
...route,
url: url,
- newTab:
- route.customizableHref && uiCustomization?.[route.customizableHref]
- ? true
- : route.newTab,
isActive: router.pathname === route.pathname,
items:
items.length > 0
diff --git a/web/src/components/layouts/routes.tsx b/web/src/components/layouts/routes.tsx
index 292554cfdd..c04bddd9cb 100644
--- a/web/src/components/layouts/routes.tsx
+++ b/web/src/components/layouts/routes.tsx
@@ -18,7 +18,6 @@ import {
} from "lucide-react";
import { type ReactNode } from "react";
import { type Entitlement } from "@/src/features/entitlements/constants/entitlements";
-import { type UiCustomizationOption } from "@/src/ee/features/ui-customization/useUiCustomization";
import { type User } from "next-auth";
import { type OrganizationScope } from "@/src/features/rbac/constants/organizationAccessRights";
import { SupportMenuDropdown } from "@/src/components/nav/support-menu-dropdown";
@@ -26,6 +25,7 @@ import { SidebarMenuButton } from "@/src/components/ui/sidebar";
import { useCommandMenu } from "@/src/features/command-k-menu/CommandMenuProvider";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { CloudStatusMenu } from "@/src/features/cloud-status-notification/components/CloudStatusMenu";
+import { type ProductModule } from "@/src/ee/features/ui-customization/productModuleSchema";
export type Route = {
title: string;
@@ -40,7 +40,7 @@ export type Route = {
bottom?: boolean; // bottom of the sidebar, only for first level routes
newTab?: boolean; // open in new tab
entitlements?: Entitlement[]; // entitlements required, array treated as OR
- customizableHref?: UiCustomizationOption; // key of useUiCustomization object to use to replace the href
+ productModule?: ProductModule; // Product module this route belongs to. Used to show/hide modules via ui customization.
show?: (p: {
organization: User["organizations"][number] | undefined;
}) => boolean;
@@ -75,11 +75,13 @@ export const ROUTES: Route[] = [
icon: LayoutDashboard,
label: "Beta",
entitlements: ["custom-dashboards"],
+ productModule: "dashboards",
},
{
title: "Tracing",
pathname: `/project/[projectId]/traces`,
icon: ListTree,
+ productModule: "tracing",
items: [
{
title: "Traces",
@@ -103,6 +105,7 @@ export const ROUTES: Route[] = [
title: "Evaluation",
icon: Lightbulb,
pathname: `/project/[projectId]/annotation-queues`,
+ productModule: "evaluation",
entitlements: ["annotation-queues", "model-based-evaluations"],
projectRbacScopes: ["annotationQueues:read", "evalJob:read"],
items: [
@@ -124,23 +127,27 @@ export const ROUTES: Route[] = [
title: "Users",
pathname: `/project/[projectId]/users`,
icon: UsersIcon,
+ productModule: "tracing",
},
{
title: "Prompts",
pathname: "/project/[projectId]/prompts",
icon: FileJson,
projectRbacScopes: ["prompts:read"],
+ productModule: "prompt-management",
},
{
title: "Playground",
pathname: "/project/[projectId]/playground",
icon: TerminalIcon,
+ productModule: "playground",
entitlements: ["playground"],
},
{
title: "Datasets",
pathname: `/project/[projectId]/datasets`,
icon: Database,
+ productModule: "datasets",
},
{
title: "Upgrade",
diff --git a/web/src/components/nav/support-menu-dropdown.tsx b/web/src/components/nav/support-menu-dropdown.tsx
index 01b8cdd3d4..e41ffeb946 100644
--- a/web/src/components/nav/support-menu-dropdown.tsx
+++ b/web/src/components/nav/support-menu-dropdown.tsx
@@ -19,10 +19,7 @@ import {
type LucideIcon,
} from "lucide-react";
import { useMemo, type ReactNode } from "react";
-import {
- type UiCustomizationOption,
- useUiCustomization,
-} from "@/src/ee/features/ui-customization/useUiCustomization";
+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";
import { SidebarMenuButton, useSidebar } from "@/src/components/ui/sidebar";
import { SiDiscord } from "react-icons/si";
import { env } from "@/src/env.mjs";
@@ -33,7 +30,6 @@ type SupportMenuItem = {
pathname: string;
icon: LucideIcon | React.ElementType;
menuNode?: ReactNode;
- customizableHref?: UiCustomizationOption;
};
export const SupportMenuDropdown = () => {
@@ -84,9 +80,9 @@ export const SupportMenuDropdown = () => {
items.push("separator");
items.push({
title: "Docs",
- pathname: "https://langfuse.com/docs",
+ pathname:
+ uiCustomization?.documentationHref ?? "https://langfuse.com/docs",
icon: LibraryBig,
- customizableHref: "documentationHref",
});
if (env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION) {
items.push({
@@ -142,21 +138,23 @@ export const SupportMenuDropdown = () => {
if (item === "separator") {
return <DropdownMenuSeparator key={`separator-${index}`} />;
}
- const url = item.customizableHref
- ? (uiCustomization?.[item.customizableHref] ?? item.pathname)
- : item.pathname;
+
return (
<DropdownMenuItem key={item.title} asChild>
{item.menuNode ?? (
<a
- href={url}
- target={url.startsWith("http") ? "_blank" : undefined}
- rel={url.startsWith("http") ? "noopener" : undefined}
+ href={item.pathname}
+ target={
+ item.pathname.startsWith("http") ? "_blank" : undefined
+ }
+ rel={
+ item.pathname.startsWith("http") ? "noopener" : undefined
+ }
className="flex cursor-pointer items-center"
>
<item.icon className="mr-2 h-4 w-4" />
{item.title}
- {url.startsWith("http") && (
+ {item.pathname.startsWith("http") && (
<ArrowUpRight className="ml-1 h-3 w-3" />
)}
</a>
diff --git a/web/src/ee/features/ui-customization/productModuleSchema.ts b/web/src/ee/features/ui-customization/productModuleSchema.ts
new file mode 100644
index 0000000000..f363b7e803
--- /dev/null
+++ b/web/src/ee/features/ui-customization/productModuleSchema.ts
@@ -0,0 +1,80 @@
+import { z } from "zod";
+
+/**
+ * All available product modules in Langfuse
+ */
+export const PRODUCT_MODULES = [
+ "dashboards",
+ "tracing",
+ "evaluation",
+ "prompt-management",
+ "playground",
+ "datasets",
+] as const;
+
+/**
+ * Schema for product modules that can be enabled/disabled in the UI
+ */
+export const ProductModule = z.enum(PRODUCT_MODULES);
+
+/**
+ * Type for product modules that can be enabled/disabled in the UI
+ */
+export type ProductModule = z.infer<typeof ProductModule>;
+
+/**
+ * Parse environment variables to determine which product modules should be visible.
+ *
+ * Two configuration modes:
+ * - When LANGFUSE_UI_VISIBLE_PRODUCT_MODULES is set: only listed modules are visible
+ * - When LANGFUSE_UI_HIDDEN_PRODUCT_MODULES is set: all modules except listed ones are visible
+ *
+ * If both are set, LANGFUSE_UI_VISIBLE_PRODUCT_MODULES takes precedence.
+ * If neither is set, all modules are visible.
+ */
+export function getVisibleProductModules(
+ visibleModulesEnv?: string,
+ hiddenModulesEnv?: string,
+): ProductModule[] {
+ // If both variables are set, visible list takes precedence with a warning
+ if (visibleModulesEnv && hiddenModulesEnv) {
+ console.warn(
+ "Both LANGFUSE_UI_VISIBLE_PRODUCT_MODULES and LANGFUSE_UI_HIDDEN_PRODUCT_MODULES are set. " +
+ "Using LANGFUSE_UI_VISIBLE_PRODUCT_MODULES as the allow list.",
+ );
+ return parseModulesList(visibleModulesEnv);
+ }
+
+ // Only hidden list set - return all modules except hidden ones
+ if (hiddenModulesEnv) {
+ const hiddenModules = parseModulesList(hiddenModulesEnv);
+ return PRODUCT_MODULES.filter(
+ (module) => !hiddenModules.includes(module as ProductModule),
+ ) as ProductModule[];
+ }
+
+ // Only visible list set - return only the visible modules
+ if (visibleModulesEnv) {
+ return parseModulesList(visibleModulesEnv);
+ }
+
+ // Neither is set - all modules are visible
+ return [...PRODUCT_MODULES] as ProductModule[];
+}
+
+/**
+ * Parse comma-separated values into product modules array.
+ * Invalid values are filtered out.
+ */
+function parseModulesList(input: string): ProductModule[] {
+ if (!input || !input.trim()) return [];
+
+ return input
+ .toLowerCase()
+ .split(",")
+ .map((module) => module.trim())
+ .filter(Boolean)
+ .filter((module) =>
+ PRODUCT_MODULES.includes(module as ProductModule),
+ ) as ProductModule[];
+}
diff --git a/web/src/ee/features/ui-customization/uiCustomizationRouter.ts b/web/src/ee/features/ui-customization/uiCustomizationRouter.ts
index 75ebd32af2..36f9467e23 100644
--- a/web/src/ee/features/ui-customization/uiCustomizationRouter.ts
+++ b/web/src/ee/features/ui-customization/uiCustomizationRouter.ts
@@ -1,6 +1,7 @@
import { env } from "@/src/env.mjs";
import { hasEntitlementBasedOnPlan } from "@/src/features/entitlements/server/hasEntitlement";
import { createTRPCRouter, protectedProcedure } from "@/src/server/api/trpc";
+import { getVisibleProductModules } from "@/src/ee/features/ui-customization/productModuleSchema";
export const uiCustomizationRouter = createTRPCRouter({
get: protectedProcedure.query(({ ctx }) => {
@@ -21,6 +22,10 @@ export const uiCustomizationRouter = createTRPCRouter({
defaultBaseUrlOpenAI: env.LANGFUSE_UI_DEFAULT_BASE_URL_OPENAI,
defaultBaseUrlAnthropic: env.LANGFUSE_UI_DEFAULT_BASE_URL_ANTHROPIC,
defaultBaseUrlAzure: env.LANGFUSE_UI_DEFAULT_BASE_URL_AZURE,
+ visibleModules: getVisibleProductModules(
+ env.LANGFUSE_UI_VISIBLE_PRODUCT_MODULES,
+ env.LANGFUSE_UI_HIDDEN_PRODUCT_MODULES,
+ ),
};
}),
});
diff --git a/web/src/env.mjs b/web/src/env.mjs
index d58eabc124..ce089c551c 100644
--- a/web/src/env.mjs
+++ b/web/src/env.mjs
@@ -289,6 +289,11 @@ export const env = createEnv({
.positive()
.default(50_000),
PLAIN_AUTHENTICATION_SECRET: z.string().optional(),
+
+ // UI customization - comma-separated list of visible product modules
+ LANGFUSE_UI_VISIBLE_PRODUCT_MODULES: z.string().optional(),
+ // UI customization - comma-separated list of hidden product modules
+ LANGFUSE_UI_HIDDEN_PRODUCT_MODULES: z.string().optional(),
},
/**
@@ -524,6 +529,8 @@ export const env = createEnv({
process.env.LANGFUSE_UI_DEFAULT_BASE_URL_ANTHROPIC,
LANGFUSE_UI_DEFAULT_BASE_URL_AZURE:
process.env.LANGFUSE_UI_DEFAULT_BASE_URL_AZURE,
+ LANGFUSE_UI_VISIBLE_PRODUCT_MODULES: process.env.LANGFUSE_UI_VISIBLE_PRODUCT_MODULES,
+ LANGFUSE_UI_HIDDEN_PRODUCT_MODULES: process.env.LANGFUSE_UI_HIDDEN_PRODUCT_MODULES,
// EE License
LANGFUSE_EE_LICENSE_KEY: process.env.LANGFUSE_EE_LICENSE_KEY,
ADMIN_API_KEY: process.env.ADMIN_API_KEY,