Skip to content

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

feat(web): warn ClickHouse staff viewing data (#19266)

Max Deichmann09f29e2bddf6
diff --git a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx
index ce9503b951..8e93c03b09 100644
--- a/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx
+++ b/web/src/components/layouts/app-layout/variants/AuthenticatedLayout.tsx
@@ -57,6 +57,10 @@ import useLocalStorage from "@/src/components/useLocalStorage";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics";
import { useSession } from "next-auth/react";
import { useQueryProjectOrOrganization } from "@/src/features/projects";
+import {
+ CustomerDataWarningBannerView,
+ getCustomerDataWarning,
+} from "@/src/features/customer-data-warning";
import { accountSettingsPath } from "@/src/features/settings/accountSettingsPath";
import { useHasOrganizationAccess } from "@/src/features/rbac";
import {
@@ -139,7 +143,24 @@ export function AuthenticatedLayout({
// Account-level entry: use the raw flag (same as account settings tabs), not
// project-scoped force-v3 suppression.
const showV4Migration = useV4UpgradeUiFlag();
- const { organization: currentOrganization } = useQueryProjectOrOrganization();
+ const { organization: currentOrganization, project: currentProject } =
+ useQueryProjectOrOrganization();
+ const customerDataWarning = getCustomerDataWarning({
+ email: user.email,
+ isAdmin: user.admin === true,
+ isLangfuseCloud,
+ projectId:
+ typeof router.query.projectId === "string"
+ ? router.query.projectId
+ : null,
+ organizationId:
+ typeof router.query.organizationId === "string"
+ ? router.query.organizationId
+ : null,
+ memberships: user.organizations,
+ organizationName: currentOrganization?.name ?? null,
+ projectName: currentProject?.name ?? null,
+ });
const regionMenuItems = getAvailableCloudRegionOptions(currentRegion).map(
(region) => ({
@@ -293,6 +314,9 @@ export function AuthenticatedLayout({
ref={topBannerRef}
className="fixed top-0 z-51 flex w-full flex-col"
>
+ {customerDataWarning && (
+ <CustomerDataWarningBannerView {...customerDataWarning} />
+ )}
{paymentBanner && (
<PaymentBannerView
organizationName={paymentBanner.organizationName}
diff --git a/web/src/features/customer-data-warning/CustomerDataWarningBannerView.stories.tsx b/web/src/features/customer-data-warning/CustomerDataWarningBannerView.stories.tsx
new file mode 100644
index 0000000000..5af37a6fba
--- /dev/null
+++ b/web/src/features/customer-data-warning/CustomerDataWarningBannerView.stories.tsx
@@ -0,0 +1,26 @@
+import preview from "../../../.storybook/preview";
+import { CustomerDataWarningBannerView } from "./CustomerDataWarningBannerView";
+
+const meta = preview.meta({
+ component: CustomerDataWarningBannerView,
+});
+
+/**
+ * ClickHouse or Langfuse staff viewing a customer project they are not a member of.
+ * The strip stays up for the page load; it has no dismiss control.
+ */
+export const Project = meta.story({
+ args: {
+ scope: "project",
+ organizationName: "Acme",
+ projectName: "Production",
+ },
+});
+
+/** Same strip on an organization page, where there is no project name. */
+export const Organization = meta.story({
+ args: {
+ scope: "organization",
+ organizationName: "Acme",
+ },
+});
diff --git a/web/src/features/customer-data-warning/CustomerDataWarningBannerView.tsx b/web/src/features/customer-data-warning/CustomerDataWarningBannerView.tsx
new file mode 100644
index 0000000000..40ce3700a9
--- /dev/null
+++ b/web/src/features/customer-data-warning/CustomerDataWarningBannerView.tsx
@@ -0,0 +1,23 @@
+import {
+ customerDataWarningText,
+ type CustomerDataWarning,
+} from "./getCustomerDataWarning";
+
+/**
+ * Top-of-page strip for ClickHouse and Langfuse staff viewing a customer
+ * project or organization through admin access. Same placement and shape as the preview
+ * deployment strip, in amber so the two cannot be confused. It is not
+ * dismissible.
+ */
+export function CustomerDataWarningBannerView(warning: CustomerDataWarning) {
+ return (
+ <div
+ className="ph-no-capture border-customer-data-banner-border bg-customer-data-banner text-customer-data-banner-foreground flex w-full items-center justify-center border-b px-4 py-1"
+ role="status"
+ >
+ <p className="text-center text-sm text-balance">
+ {customerDataWarningText(warning)}
+ </p>
+ </div>
+ );
+}
diff --git a/web/src/features/customer-data-warning/getCustomerDataWarning.clienttest.ts b/web/src/features/customer-data-warning/getCustomerDataWarning.clienttest.ts
new file mode 100644
index 0000000000..815d3dee55
--- /dev/null
+++ b/web/src/features/customer-data-warning/getCustomerDataWarning.clienttest.ts
@@ -0,0 +1,180 @@
+import { describe, expect, it } from "vitest";
+import {
+ customerDataWarningText,
+ getCustomerDataWarning,
+} from "./getCustomerDataWarning";
+
+const viewingCustomerProject = {
+ email: "[email protected]",
+ isAdmin: true,
+ isLangfuseCloud: true,
+ projectId: "proj_customer",
+ organizationId: null,
+ memberships: [{ id: "org_internal", projects: [{ id: "proj_internal" }] }],
+ organizationName: "Acme",
+ projectName: "Production",
+};
+
+describe("getCustomerDataWarning", () => {
+ it("shows a project warning for a ClickHouse admin on Cloud who is not a member", () => {
+ expect(getCustomerDataWarning(viewingCustomerProject)).toEqual({
+ scope: "project",
+ organizationName: "Acme",
+ projectName: "Production",
+ });
+ });
+
+ "matches staff email %s case-insensitively",
+ (email) => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ email,
+ }),
+ ).toMatchObject({ scope: "project" });
+ },
+ );
+
+ it.each([
+ null,
+ ])("hides for email %s", (email) => {
+ expect(
+ getCustomerDataWarning({ ...viewingCustomerProject, email }),
+ ).toBeNull();
+ });
+
+ it("hides when the staff user is not an admin", () => {
+ expect(
+ getCustomerDataWarning({ ...viewingCustomerProject, isAdmin: false }),
+ ).toBeNull();
+ });
+
+ it("hides on self-hosted deployments", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ isLangfuseCloud: false,
+ }),
+ ).toBeNull();
+ });
+
+ it("hides when the admin is a genuine member of the project", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ memberships: [
+ { id: "org_customer", projects: [{ id: "proj_customer" }] },
+ ],
+ }),
+ ).toBeNull();
+ });
+
+ it("shows when the admin belongs to the organization but not this project", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ memberships: [{ id: "org_customer", projects: [{ id: "proj_other" }] }],
+ }),
+ ).toMatchObject({ scope: "project" });
+ });
+
+ it("shows an organization warning when the admin is not a member of the org", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ projectId: null,
+ organizationId: "org_customer",
+ projectName: null,
+ }),
+ ).toEqual({
+ scope: "organization",
+ organizationName: "Acme",
+ });
+ });
+
+ it("hides an organization route when the admin is a member", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ projectId: null,
+ organizationId: "org_internal",
+ projectName: null,
+ organizationName: "Langfuse",
+ }),
+ ).toBeNull();
+ });
+
+ it("uses the project when the route has both a project and an organization", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ organizationId: "org_unrelated",
+ }),
+ ).toMatchObject({ scope: "project", projectName: "Production" });
+ });
+
+ it("hides when the route has no project or organization", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ projectId: null,
+ organizationId: null,
+ }),
+ ).toBeNull();
+ });
+
+ it("hides a project warning until both names have loaded", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ projectName: null,
+ }),
+ ).toBeNull();
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ organizationName: null,
+ }),
+ ).toBeNull();
+ });
+
+ it("hides an organization warning until the organization name has loaded", () => {
+ expect(
+ getCustomerDataWarning({
+ ...viewingCustomerProject,
+ projectId: null,
+ organizationId: "org_customer",
+ organizationName: null,
+ }),
+ ).toBeNull();
+ });
+});
+
+describe("customerDataWarningText", () => {
+ it("names the organization and project", () => {
+ expect(
+ customerDataWarningText({
+ scope: "project",
+ organizationName: "Acme",
+ projectName: "Production",
+ }),
+ ).toBe(
+ "You are viewing a customer project (Acme / Production). Treat all data as confidential.",
+ );
+ });
+
+ it("names the organization on an organization route", () => {
+ expect(
+ customerDataWarningText({
+ scope: "organization",
+ organizationName: "Acme",
+ }),
+ ).toBe(
+ "You are viewing a customer organization (Acme). Treat all data as confidential.",
+ );
+ });
+});
diff --git a/web/src/features/customer-data-warning/getCustomerDataWarning.ts b/web/src/features/customer-data-warning/getCustomerDataWarning.ts
new file mode 100644
index 0000000000..bc53417e23
--- /dev/null
+++ b/web/src/features/customer-data-warning/getCustomerDataWarning.ts
@@ -0,0 +1,93 @@
+const STAFF_EMAIL_DOMAINS = ["@clickhouse.com", "@langfuse.com"] as const;
+
+/**
+ * Real org and project memberships from the session. Admins who are not
+ * members have no entry here; staff access to those resources is granted in
+ * the tRPC project and organization middleware.
+ */
+type CustomerDataWarningMembership = {
+ id: string;
+ projects: { id: string }[];
+};
+
+export type CustomerDataWarning =
+ | {
+ scope: "project";
+ organizationName: string;
+ projectName: string;
+ }
+ | {
+ scope: "organization";
+ organizationName: string;
+ };
+
+type CustomerDataWarningInput = {
+ email: string | null | undefined;
+ isAdmin: boolean;
+ isLangfuseCloud: boolean;
+ projectId: string | null;
+ organizationId: string | null;
+ memberships: CustomerDataWarningMembership[];
+ organizationName: string | null;
+ projectName: string | null;
+};
+
+function isStaffEmail(email: string | null | undefined): boolean {
+ const normalized = email?.toLowerCase();
+ if (!normalized) return false;
+ return STAFF_EMAIL_DOMAINS.some((domain) => normalized.endsWith(domain));
+}
+
+function isProjectMember(
+ memberships: CustomerDataWarningMembership[],
+ projectId: string,
+): boolean {
+ return memberships.some((organization) =>
+ organization.projects.some((project) => project.id === projectId),
+ );
+}
+
+function isOrganizationMember(
+ memberships: CustomerDataWarningMembership[],
+ organizationId: string,
+): boolean {
+ return memberships.some((organization) => organization.id === organizationId);
+}
+
+export function getCustomerDataWarning(
+ input: CustomerDataWarningInput,
+): CustomerDataWarning | null {
+ if (!input.isLangfuseCloud || !input.isAdmin) return null;
+ if (!isStaffEmail(input.email)) return null;
+
+ if (input.projectId) {
+ if (isProjectMember(input.memberships, input.projectId)) return null;
+ if (!input.organizationName || !input.projectName) return null;
+ return {
+ scope: "project",
+ organizationName: input.organizationName,
+ projectName: input.projectName,
+ };
+ }
+
+ if (input.organizationId) {
+ if (isOrganizationMember(input.memberships, input.organizationId))
+ return null;
+ if (!input.organizationName) return null;
+ return {
+ scope: "organization",
+ organizationName: input.organizationName,
+ };
+ }
+
+ return null;
+}
+
+export function customerDataWarningText(warning: CustomerDataWarning): string {
+ const target =
+ warning.scope === "project"
+ ? `customer project (${warning.organizationName} / ${warning.projectName})`
+ : `customer organization (${warning.organizationName})`;
+
+ return `You are viewing a ${target}. Treat all data as confidential.`;
+}
diff --git a/web/src/features/customer-data-warning/index.ts b/web/src/features/customer-data-warning/index.ts
new file mode 100644
index 0000000000..8b416e3120
--- /dev/null
+++ b/web/src/features/customer-data-warning/index.ts
@@ -0,0 +1,2 @@
+export { CustomerDataWarningBannerView } from "./CustomerDataWarningBannerView";
+export { getCustomerDataWarning } from "./getCustomerDataWarning";
diff --git a/web/src/styles/globals.css b/web/src/styles/globals.css
index 93e3f6794b..587f8d6acb 100644
--- a/web/src/styles/globals.css
+++ b/web/src/styles/globals.css
@@ -68,6 +68,11 @@
--color-preview-banner-border: hsl(var(--preview-banner-border));
--color-preview-banner-link: hsl(var(--preview-banner-link));
--color-preview-banner-link-hover: hsl(var(--preview-banner-link-hover));
+ --color-customer-data-banner: hsl(var(--customer-data-banner));
+ --color-customer-data-banner-foreground: hsl(
+ var(--customer-data-banner-foreground)
+ );
+ --color-customer-data-banner-border: hsl(var(--customer-data-banner-border));
--color-control-fill: hsl(var(--control-fill));
--color-control-track: hsl(var(--control-track));
--color-control-border: hsl(var(--control-border));
@@ -420,6 +425,11 @@
--preview-banner-border: 213 97% 87%;
--preview-banner-link: 224 76% 48%;
--preview-banner-link-hover: 226 71% 40%;
+ /* Staff customer-data strip (Cloud only): amber-100 / amber-950 / amber-200,
+ so it cannot be read as the blue preview-deployment strip. */
+ --customer-data-banner: 48 96% 89%;
+ --customer-data-banner-foreground: 21 92% 14%;
+ --customer-data-banner-border: 48 97% 77%;
/* Checked selection controls (checkbox/switch): monochrome in BOTH
modes — dark fill + light glyph in light, muted-white fill + dark
glyph in dark. Deliberately dimmer than --primary in dark so checked
@@ -659,6 +669,11 @@
--preview-banner-border: 215 37% 31%;
--preview-banner-link: 213 94% 68%;
--preview-banner-link-hover: 212 96% 78%;
+ /* Staff customer-data strip: amber fill over the dark canvas, warm light
+ text, a step-lighter border. Distinct from the blue preview strip. */
+ --customer-data-banner: 32 40% 16%;
+ --customer-data-banner-foreground: 48 96% 89%;
+ --customer-data-banner-border: 36 35% 28%;
--control-fill: 0 0% 78%;
--control-track: 0 0% 24%;
/* Matches --border-contrast: unchecked checkboxes/radios read by their