🪢 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(web): Improve org-level analytics view (#18090)
Ben Bachemcfc59468b96a
diff --git a/web/src/__tests__/server/unit/organizationIngestionService.servertest.ts b/web/src/__tests__/server/unit/organizationIngestionService.servertest.tsnew file mode 100644index 0000000000..e9ba09af19--- /dev/null+++ b/web/src/__tests__/server/unit/organizationIngestionService.servertest.ts@@ -0,0 +1,80 @@+import { getOrganizationIngestionOverview } from "@/src/features/organization-ingestion/server/organizationIngestionService";+import { prisma } from "@langfuse/shared/src/db";++const mocks = vi.hoisted(() => ({+ queryClickhouse: vi.fn(),+ getSdkUsageSeriesByProject: vi.fn(),+}));++vi.mock("@langfuse/shared/src/server", () => ({+ queryClickhouse: mocks.queryClickhouse,+ UNKNOWN_INGESTION_SDK_VALUE: "unknown",+ convertDateToClickhouseDateTime: (date: Date) => date.toISOString(),+ classifyIngestionSdkVersion: () => ({+ canonicalSdkName: null,+ status: "unsupported_sdk",+ }),+}));+vi.mock("@/src/features/v4/server/v4TransitionCache", () => ({+ MIGRATION_INGRESS_EVENT_SOURCES: ["otel", "otel-delayed"],+}));+vi.mock("@/src/features/v4/server/v4TransitionSdkUsage", () => ({+ getSdkUsageSeriesByProject: mocks.getSdkUsageSeriesByProject,+}));++const client = {+ projectId: "project",+ sdkName: "custom-client",+ sdkVersion: "1.0.0",+ publicKey: "pk-client",+ isInternal: false,+ currentCount: 10,+ previousCount: 0,+ lastSeen: "2026-09-30T00:00:00Z",+};++describe("organization ingestion migration attributes", () => {+ beforeEach(() => {+ vi.resetAllMocks();+ vi.spyOn(prisma.evaluationRule, "groupBy").mockResolvedValue([]);+ vi.spyOn(prisma.dataset, "groupBy").mockResolvedValue([]);+ vi.spyOn(prisma.datasetItem, "groupBy").mockResolvedValue([]);+ vi.spyOn(prisma.monitor, "groupBy").mockResolvedValue([]);+ vi.spyOn(prisma, "$queryRaw").mockResolvedValue([]);+ mocks.queryClickhouse+ .mockResolvedValueOnce([{ ...client, ingestionPath: "otel" }])+ .mockResolvedValueOnce([{ ...client, source: "API" }]);+ });++ it.each([+ { actions: ["none"], expected: "not_required" },+ { actions: ["none", "required"], expected: "required" },+ { actions: ["required", "none"], expected: "required" },+ { actions: [], expected: "unknown" },+ ])(+ "maps $actions to $expected for events and scores",+ async ({ actions, expected }) => {+ mocks.getSdkUsageSeriesByProject.mockResolvedValue(+ new Map([+ [+ "project",+ actions.map((actionLevel) => ({ ...client, actionLevel })),+ ],+ ]),+ );+ const result = await getOrganizationIngestionOverview({+ prisma,+ projects: [{ id: "project", name: "Project" }],+ nowMs: Date.parse("2026-09-30T12:00:00Z"),+ });+ expect(result.eventRows[0]?.v4Migration).toBe(expected);+ expect(result.scoreRows[0]?.v4Migration).toBe(expected);+ },+ );++ it("does not query migration evidence for an empty organization", async () => {+ await getOrganizationIngestionOverview({ prisma, projects: [] });+ expect(mocks.getSdkUsageSeriesByProject).not.toHaveBeenCalled();+ expect(mocks.queryClickhouse).not.toHaveBeenCalled();+ });+});diff --git a/web/src/features/organization-ingestion/server/organizationIngestionService.ts b/web/src/features/organization-ingestion/server/organizationIngestionService.tsindex 0efaac90db..a4f7a21760 100644--- a/web/src/features/organization-ingestion/server/organizationIngestionService.ts+++ b/web/src/features/organization-ingestion/server/organizationIngestionService.ts@@ -8,6 +8,7 @@ import {} from "@langfuse/shared/src/server";import { type ScoreSourceType } from "@langfuse/shared";import { Prisma, type PrismaClient } from "@langfuse/shared/src/db";+import { getSdkUsageSeriesByProject } from "@/src/features/v4/server/v4TransitionSdkUsage";const DAY_MS = 24 * 60 * 60 * 1_000;const MINUTE_MS = 60 * 1_000;@@ -21,6 +22,7 @@ type IngestionClientFields = {sdkVersion: string | null;canonicalSdkName: IngestionSdkCanonicalName | null;sdkUpgradeStatus: IngestionSdkUpgradeStatus;+ v4Migration: "required" | "not_required" | "unknown";publicKey: string | null;/** Written by Langfuse itself (`langfuse-*` environment or internal SDK). */isInternal: boolean;@@ -110,19 +112,32 @@ GROUP BY projectId, source, sdkName, sdkVersion, publicKey, isInternalconst toNullableSdkValue = (value: string): string | null =>value === "" || value === UNKNOWN_INGESTION_SDK_VALUE ? null : value;-const toClientFields = (row: ClickhouseClientRow): IngestionClientFields => {+const toClientFields = (+ row: ClickhouseClientRow,+ migrationByClient: Map<string, "required" | "not_required">,+): IngestionClientFields => {const sdkName = toNullableSdkValue(row.sdkName);const sdkVersion = toNullableSdkValue(row.sdkVersion);const classification = classifyIngestionSdkVersion({ sdkName, sdkVersion });+ const isInternal =+ row.isInternal === true || row.isInternal === 1 || row.isInternal === "1";+ let v4Migration: IngestionClientFields["v4Migration"] = "unknown";+ // Migration detection excludes internal traffic and uses its own detection window.+ if (!isInternal) {+ v4Migration =+ migrationByClient.get(+ JSON.stringify([row.projectId, sdkName, sdkVersion, row.publicKey]),+ ) ?? "unknown";+ }return {sdkName,sdkVersion,canonicalSdkName: classification.canonicalSdkName,sdkUpgradeStatus: classification.status,+ v4Migration,publicKey: row.publicKey === "" ? null : row.publicKey,- isInternal:- row.isInternal === true || row.isInternal === 1 || row.isInternal === "1",+ isInternal,current: Number(row.currentCount),previous: Number(row.previousCount),lastSeen: row.lastSeen,@@ -226,21 +241,40 @@ export const getOrganizationIngestionOverview = async ({to: convertDateToClickhouseDateTime(to),};- const [featureCounts, eventRows, scoreRows] = await Promise.all([- getProjectFeatureCounts({ prisma, projectIds: params.projectIds }),- queryClickhouse<ClickhouseClientRow & { ingestionPath: IngestionPath }>({- query: EVENT_ROWS_QUERY,- params,- tags: { route: "organization-ingestion-overview-events" },- preferredClickhouseService: "EventsReadOnly",- }),- queryClickhouse<ClickhouseClientRow & { source: string }>({- query: SCORE_ROWS_QUERY,- params,- tags: { route: "organization-ingestion-overview-scores" },- preferredClickhouseService: "ReadOnly",- }),- ]);+ const [featureCounts, eventRows, scoreRows, migrationSeriesByProject] =+ await Promise.all([+ getProjectFeatureCounts({ prisma, projectIds: params.projectIds }),+ queryClickhouse<ClickhouseClientRow & { ingestionPath: IngestionPath }>({+ query: EVENT_ROWS_QUERY,+ params,+ tags: { route: "organization-ingestion-overview-events" },+ preferredClickhouseService: "EventsReadOnly",+ }),+ queryClickhouse<ClickhouseClientRow & { source: string }>({+ query: SCORE_ROWS_QUERY,+ params,+ tags: { route: "organization-ingestion-overview-scores" },+ preferredClickhouseService: "ReadOnly",+ }),+ getSdkUsageSeriesByProject({ projectIds: params.projectIds, nowMs }),+ ]);++ const migrationByClient = new Map<string, "required" | "not_required">();+ for (const [projectId, series] of migrationSeriesByProject) {+ for (const client of series) {+ const key = JSON.stringify([+ projectId,+ toNullableSdkValue(client.sdkName),+ toNullableSdkValue(client.sdkVersion),+ client.publicKey,+ ]);+ if (client.actionLevel === "required") {+ migrationByClient.set(key, "required");+ } else if (!migrationByClient.has(key)) {+ migrationByClient.set(key, "not_required");+ }+ }+ }return {window,@@ -251,13 +285,13 @@ export const getOrganizationIngestionOverview = async ({eventRows: eventRows.map((row) => ({projectId: row.projectId,ingestionPath: row.ingestionPath,- ...toClientFields(row),+ ...toClientFields(row, migrationByClient),})),scoreRows: scoreRows.flatMap((row) => [{projectId: row.projectId,source: row.source as ScoreSourceType,- ...toClientFields(row),+ ...toClientFields(row, migrationByClient),},]),};diff --git a/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsx b/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsxindex c3b952cbc1..aa7d736aa7 100644--- a/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsx+++ b/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsx@@ -1,4 +1,5 @@import { OrgOverviewGraph } from "./OrgOverviewGraph";+import { type ComponentProps } from "react";import { useOrganizationIngestionOverview } from "../../hooks/useOrganizationIngestionOverview";import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";import { ErrorPage } from "@/src/components/error-page";@@ -12,7 +13,7 @@ export function ConnectedOrgOverviewGraph({organizationId: string;search: string;activityFilter: "all" | "active" | "inactive";- order: "billable" | "observations" | "scores" | "name";+ order: NonNullable<ComponentProps<typeof OrgOverviewGraph>["order"]>;}) {const { data, error, isLoading } =useOrganizationIngestionOverview(organizationId);diff --git a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsx b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsxindex 60acdcee99..e3440dbfa8 100644--- a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsx+++ b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsx@@ -1,4 +1,5 @@import preview from "../../../../../.storybook/preview";+import { expect, userEvent, waitFor, within } from "storybook/test";import {OrgOverviewGraph,type OrganizationIngestionOverview,@@ -21,6 +22,7 @@ const clientFields = {sdkVersion: "4.0.0",canonicalSdkName: "javascript",sdkUpgradeStatus: "current",+ v4Migration: "not_required",publicKey: "pk-js",isInternal: false,lastSeen: "2026-09-29T23:00:00Z",@@ -81,6 +83,7 @@ const exampleData: OrganizationIngestionOverview = {sdkVersion: "3.9.0",canonicalSdkName: "python",sdkUpgradeStatus: "outdated_major",+ v4Migration: "required",publicKey: "pk-python",current: 4000,previous: 4000,@@ -148,6 +151,220 @@ const exampleData: OrganizationIngestionOverview = {export const Default = meta.story({ args: { data: exampleData } });+export const SortByDatasets = meta.story({+ name: "(Test) Sort by datasets with name tie-breaker",+ args: {+ order: "datasets",+ data: {+ ...exampleData,+ projects: exampleData.projects.map((project) => ({+ ...project,+ features: {+ ...project.features,+ datasets: project.id === "porcini" ? 1 : 3,+ },+ })),+ eventRows: [],+ scoreRows: [],+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await canvas.findByText("Chanterelle");+ await waitFor(() => {+ const centers = ["Chanterelle", "Shiitake", "Porcini"].map((name) => {+ const node = canvas.getByText(name).closest(".react-flow__node");+ expect(node).not.toBeNull();+ const bounds = node!.getBoundingClientRect();+ expect(bounds.height).toBeGreaterThan(0);+ return bounds.top + bounds.height / 2;+ });+ expect(centers[0]!).toBeLessThan(centers[1]!);+ expect(centers[1]!).toBeLessThan(centers[2]!);+ });+ },+});++export const SortByEvaluationRules = meta.story({+ args: { data: exampleData, order: "activeEvaluationRules" },+});++export const SortByDatasetItems = meta.story({+ args: { data: exampleData, order: "datasetItems" },+});++export const SortByActiveMonitors = meta.story({+ args: { data: exampleData, order: "activeMonitors" },+});++export const SortByPrompts = meta.story({+ args: { data: exampleData, order: "prompts" },+});++export const EmptyProjectBeforeClients = meta.story({+ args: {+ data: {+ ...exampleData,+ projects: [+ {+ id: "empty",+ name: "Empty project",+ features: {+ activeEvaluationRules: 0,+ datasets: 0,+ datasetItems: 0,+ activeMonitors: 0,+ prompts: 0,+ },+ },+ exampleData.projects[0]!,+ ],+ eventRows: exampleData.eventRows.map((row) => ({+ ...row,+ projectId: "shiitake",+ })),+ scoreRows: [],+ },+ },+});++export const SeparatedProjectCards = meta.story({+ name: "(Test) Separated project cards",+ args: { data: exampleData },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await canvas.findByText("Shiitake");+ await waitFor(() => {+ const cards = ["Shiitake", "Porcini", "Chanterelle"].map((name) => {+ const node = canvas.getByText(name).closest(".react-flow__node");+ expect(node).not.toBeNull();+ const bounds = node!.getBoundingClientRect();+ expect(bounds.height).toBeGreaterThan(0);+ return bounds;+ });+ expect(cards[1]!.top).toBeGreaterThan(cards[0]!.bottom);+ expect(cards[2]!.top).toBeGreaterThan(cards[1]!.bottom);+ });+ },+});++export const ProjectMetadata = meta.story({+ name: "(Test) Project metadata",+ args: {+ data: {+ ...exampleData,+ projects: [exampleData.projects[0]!],+ eventRows: [],+ scoreRows: [],+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expect(+ await canvas.findByText("Active evaluation rules"),+ ).toBeVisible();+ await expect(canvas.getByText("Datasets")).toBeVisible();+ await expect(canvas.getByText("Dataset items")).toBeVisible();+ await expect(canvas.getByText("1,250")).toBeVisible();+ await expect(canvas.getByText("Active monitors")).toBeVisible();+ await expect(canvas.getByText("Prompts")).toBeVisible();+ await expect(canvas.getByText("Observations (7d)")).toBeVisible();+ },+});++export const MixedInternalExternalTraffic = meta.story({+ name: "(Test) Mixed internal and external traffic",+ args: {+ data: {+ ...exampleData,+ projects: [exampleData.projects[0]!],+ eventRows: [+ {+ ...exampleData.eventRows[0]!,+ current: 8000,+ previous: 6000,+ v4Migration: "required",+ },+ {+ ...exampleData.eventRows[0]!,+ isInternal: true,+ current: 2000,+ previous: 1000,+ lastSeen: "2026-09-30T00:00:00Z",+ v4Migration: "unknown",+ },+ ],+ scoreRows: [],+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expect(await canvas.findAllByText("langfuse-js")).toHaveLength(1);+ await waitFor(() => {+ const client = canvas+ .getByText("langfuse-js")+ .closest(".react-flow__node");+ const project = canvas.getByText("Shiitake").closest(".react-flow__node");+ expect(client).not.toBeNull();+ expect(project).not.toBeNull();+ const clientBounds = client!.getBoundingClientRect();+ const projectBounds = project!.getBoundingClientRect();+ expect(clientBounds.height).toBeGreaterThan(0);+ expect(projectBounds.height).toBeGreaterThan(0);+ expect(+ Math.abs(+ clientBounds.top ++ clientBounds.height / 2 -+ (projectBounds.top + projectBounds.height / 2),+ ),+ ).toBeLessThan(1);+ });+ await expect(await canvas.findByText("External")).toBeVisible();+ await expect(await canvas.findByText("Internal")).toBeVisible();+ await expect(canvas.getByText("8,000")).toBeVisible();+ await expect(canvas.getByText("2,000")).toBeVisible();+ await expect(canvas.getByText("Required")).toBeVisible();+ await userEvent.hover(+ canvas.getByRole("button", {+ name: "Explain internal and external traffic",+ }),+ );+ const body = within(canvasElement.ownerDocument.body);+ await expect(await body.findByRole("tooltip")).toHaveTextContent(+ "Internal observations use an environment starting with langfuse-",+ );+ },+});++export const ExternalTrafficOnly = meta.story({+ name: "(Test) External traffic only",+ args: {+ data: {+ ...exampleData,+ projects: [exampleData.projects[0]!],+ eventRows: [exampleData.eventRows[0]!],+ scoreRows: [],+ },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ await expect(await canvas.findAllByText("8,000")).toHaveLength(3);+ await expect(canvas.queryByText("External")).not.toBeInTheDocument();+ await expect(canvas.queryByText("Internal")).not.toBeInTheDocument();+ },+});++export const CompactViewport = meta.story({+ args: { data: exampleData },+ decorators: [+ (Story) => (+ <div className="h-[480px] w-[720px]">+ <Story />+ </div>+ ),+ ],+});+export const SingleProjectThreeClients = meta.story({args: {data: {@@ -264,6 +481,7 @@ export const UnknownSdk = meta.story({sdkVersion: null,canonicalSdkName: null,sdkUpgradeStatus: "unknown",+ v4Migration: "unknown",},],scoreRows: [],diff --git a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsxindex a5e1d9d05c..84d2b761bb 100644--- a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx+++ b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx@@ -17,9 +17,11 @@ import {ArrowUpRight,Code2,FolderClosed,+ Info,} from "lucide-react";import "@xyflow/react/dist/style.css";import { type RouterOutputs } from "@/src/utils/api";+import { Tooltip } from "@/src/components/design-system/Tooltip/Tooltip";type WeekOverWeekCount = {current: number;@@ -49,18 +51,29 @@ type ClientNode = Node<version: string;status: IngestionActivityStatus;lastSeen: string | null;+ v4Migration: OrganizationIngestionOverview["eventRows"][number]["v4Migration"];},"client">;type ProjectNode = Node<{name: string;+ features: OrganizationIngestionOverview["projects"][number]["features"];events: WeekOverWeekCount;scores: WeekOverWeekCount;},"project">;-type FlowEdge = Edge<{ events: WeekOverWeekCount }, "flow">;+type FlowEdge = Edge<+ { externalEvents: WeekOverWeekCount; internalEvents: WeekOverWeekCount },+ "flow"+>;++const migrationLabels = {+ required: "Required",+ not_required: "Not required",+ unknown: "Unknown",+} satisfies Record<ClientNode["data"]["v4Migration"], string>;function ChangeIndicator({ change }: { change: number | null }) {if (change === null) {@@ -97,6 +110,9 @@ function FlowConnection({sourcePosition,targetPosition,});+ const hasInternalUsage =+ data &&+ (data.internalEvents.current > 0 || data.internalEvents.previous > 0);return (<>@@ -104,15 +120,43 @@ function FlowConnection({{data && (<EdgeLabelRenderer><div- className="border-border bg-card text-foreground absolute flex items-center gap-2 rounded-md border px-2 py-1 text-xs shadow-sm"+ className={`border-border bg-card text-foreground absolute grid items-center gap-x-2 gap-y-1 rounded-md border px-2 py-1 text-xs whitespace-nowrap shadow-sm ${hasInternalUsage ? "grid-cols-[auto_auto_auto]" : "grid-cols-[auto_auto]"}`}style={{transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px)`,}}>- <span className="font-bold tabular-nums">- {data.events.current.toLocaleString()}+ {hasInternalUsage && (+ <span className="text-muted-foreground">External</span>+ )}+ <span className="text-right font-bold tabular-nums">+ {data.externalEvents.current.toLocaleString()}</span>- <ChangeIndicator change={data.events.changePct} />+ <ChangeIndicator change={data.externalEvents.changePct} />+ {hasInternalUsage && (+ <>+ <span className="text-muted-foreground flex items-center gap-1">+ Internal+ <Tooltip label="Internal observations use an environment starting with langfuse- (typically Langfuse-generated traffic). External observations use any other environment. Counts compare the last 7 days with the preceding 7 days.">+ {({ getTriggerProps }) => (+ <button+ type="button"+ aria-label="Explain internal and external traffic"+ className="pointer-events-auto inline-flex"+ onMouseDown={(event) => event.stopPropagation()}+ onDoubleClick={(event) => event.stopPropagation()}+ {...getTriggerProps()}+ >+ <Info className="size-3" />+ </button>+ )}+ </Tooltip>+ </span>+ <span className="text-right font-bold tabular-nums">+ {data.internalEvents.current.toLocaleString()}+ </span>+ <ChangeIndicator change={data.internalEvents.changePct} />+ </>+ )}</div></EdgeLabelRenderer>)}@@ -122,8 +166,8 @@ function FlowConnection({function ClientCard({ data }: NodeProps<ClientNode>) {return (- <div className="border-border bg-card text-card-foreground dark:bg-muted w-64 rounded-lg border px-4 py-3 shadow-sm">- <div className="text-muted-foreground border-border dark:border-border-contrast flex items-center justify-between gap-3 border-b pb-3 text-xs">+ <div className="border-border bg-card text-card-foreground dark:bg-muted w-64 rounded-lg border px-3 py-2 shadow-sm">+ <div className="text-muted-foreground border-border dark:border-border-contrast flex items-center justify-between gap-2 border-b pb-2 text-xs"><span className="flex shrink-0 items-center gap-1.5"><Code2 className="size-3" />Client@@ -135,15 +179,15 @@ function ClientCard({ data }: NodeProps<ClientNode>) {{data.name}</span></div>- <div className="text-muted-foreground mt-2 flex items-center justify-between text-xs">+ <div className="text-muted-foreground mt-1.5 flex items-center justify-between text-xs"><span>SDK version</span><span className="text-foreground">{data.version}</span></div>- <div className="text-muted-foreground mt-1.5 flex items-center justify-between text-xs">+ <div className="text-muted-foreground mt-1 flex items-center justify-between text-xs"><span>Status</span><span className="text-foreground capitalize">{data.status}</span></div>- <div className="text-muted-foreground mt-1.5 flex items-center justify-between text-xs">+ <div className="text-muted-foreground mt-1 flex items-center justify-between text-xs"><span>Last seen</span><span className="text-foreground">{data.lastSeen@@ -151,6 +195,18 @@ function ClientCard({ data }: NodeProps<ClientNode>) {: "Never"}</span></div>+ <div className="text-muted-foreground mt-1 flex items-center justify-between text-xs">+ <span>V4 migration</span>+ <span+ className={+ data.v4Migration === "required"+ ? "text-amber-600 dark:text-amber-400"+ : "text-foreground"+ }+ >+ {migrationLabels[data.v4Migration]}+ </span>+ </div><Handletype="source"position={Position.Right}@@ -162,8 +218,8 @@ function ClientCard({ data }: NodeProps<ClientNode>) {function ProjectCard({ data }: NodeProps<ProjectNode>) {return (- <div className="border-border bg-card text-card-foreground dark:bg-muted w-64 rounded-lg border px-4 py-3 shadow-sm">- <div className="text-muted-foreground border-border dark:border-border-contrast flex items-center justify-between gap-3 border-b pb-3 text-xs">+ <div className="border-border bg-card text-card-foreground dark:bg-muted w-64 rounded-lg border px-3 py-2 shadow-sm">+ <div className="text-muted-foreground border-border dark:border-border-contrast flex items-center justify-between gap-2 border-b pb-2 text-xs"><span className="flex shrink-0 items-center gap-1.5"><FolderClosed className="size-3" />Project@@ -175,7 +231,39 @@ function ProjectCard({ data }: NodeProps<ProjectNode>) {{data.name}</span></div>- <div className="text-muted-foreground mt-2 flex items-center justify-between text-xs">+ <div className="text-muted-foreground border-border dark:border-border-contrast mt-1.5 flex flex-col gap-1 border-b pb-1.5 text-xs">+ <div className="flex items-center justify-between">+ <span>Active evaluation rules</span>+ <span className="text-foreground font-bold tabular-nums">+ {data.features.activeEvaluationRules.toLocaleString()}+ </span>+ </div>+ <div className="flex items-center justify-between">+ <span>Datasets</span>+ <span className="text-foreground font-bold tabular-nums">+ {data.features.datasets.toLocaleString()}+ </span>+ </div>+ <div className="flex items-center justify-between">+ <span>Dataset items</span>+ <span className="text-foreground font-bold tabular-nums">+ {data.features.datasetItems.toLocaleString()}+ </span>+ </div>+ <div className="flex items-center justify-between">+ <span>Active monitors</span>+ <span className="text-foreground font-bold tabular-nums">+ {data.features.activeMonitors.toLocaleString()}+ </span>+ </div>+ <div className="flex items-center justify-between">+ <span>Prompts</span>+ <span className="text-foreground font-bold tabular-nums">+ {data.features.prompts.toLocaleString()}+ </span>+ </div>+ </div>+ <div className="text-muted-foreground mt-1.5 flex items-center justify-between text-xs"><span>Observations (7d)</span><span className="flex items-center gap-2"><span className="text-foreground font-bold tabular-nums">@@ -184,7 +272,7 @@ function ProjectCard({ data }: NodeProps<ProjectNode>) {<ChangeIndicator change={data.events.changePct} /></span></div>- <div className="text-muted-foreground mt-1.5 flex items-center justify-between text-xs">+ <div className="text-muted-foreground mt-1 flex items-center justify-between text-xs"><span>Scores (7d)</span><span className="flex items-center gap-2"><span className="text-foreground font-bold tabular-nums">@@ -193,7 +281,7 @@ function ProjectCard({ data }: NodeProps<ProjectNode>) {<ChangeIndicator change={data.scores.changePct} /></span></div>- <div className="border-border dark:border-border-contrast text-muted-foreground mt-2 flex items-center justify-between border-t pt-2 text-xs">+ <div className="border-border dark:border-border-contrast text-muted-foreground mt-1.5 flex items-center justify-between border-t pt-1.5 text-xs"><span>Billable units (7d)</span><span className="text-foreground font-bold tabular-nums">{(data.events.current + data.scores.current).toLocaleString()}@@ -210,6 +298,8 @@ function ProjectCard({ data }: NodeProps<ProjectNode>) {const nodeTypes = { client: ClientCard, project: ProjectCard };const edgeTypes = { flow: FlowConnection };+const rowSpacing = 160;+const projectSpacing = 288;export function OrgOverviewGraph({data,@@ -222,12 +312,18 @@ export function OrgOverviewGraph({initialZoom?: number;search?: string;activityFilter?: "active" | "inactive";- order?: "billable" | "observations" | "scores" | "name";+ order?:+ | "billable"+ | "observations"+ | "scores"+ | "name"+ | keyof OrganizationIngestionOverview["projects"][number]["features"];}) {const { nodes, edges } = useMemo(() => {const nodes: Node[] = [];const edges: Edge[] = [];let row = 0;+ let previousProjectY: number | null = null;const query = search?.trim().toLowerCase() ?? "";const volumes = new Map<string, { observations: number; scores: number }>();for (const entry of data.eventRows) {@@ -250,6 +346,18 @@ export function OrgOverviewGraph({if (order) {projects.sort((a, b) => {if (order === "name") return a.name.localeCompare(b.name);+ if (+ order === "activeEvaluationRules" ||+ order === "datasets" ||+ order === "datasetItems" ||+ order === "activeMonitors" ||+ order === "prompts"+ ) {+ return (+ b.features[order] - a.features[order] ||+ a.name.localeCompare(b.name)+ );+ }const left = volumes.get(a.id) ?? { observations: 0, scores: 0 };const right = volumes.get(b.id) ?? { observations: 0, scores: 0 };if (order === "observations")@@ -263,7 +371,6 @@ export function OrgOverviewGraph({for (const project of projects) {const projectNodeId = `project-${project.id}`;- const firstRow = row;const clients = new Map<string,{@@ -271,9 +378,12 @@ export function OrgOverviewGraph({sdkVersion: string | null;current: number;previous: number;+ internalCurrent: number;+ internalPrevious: number;scoreCurrent: number;scorePrevious: number;lastSeen: string | null;+ v4Migration: ClientNode["data"]["v4Migration"];}>();let eventCurrent = 0;@@ -296,24 +406,38 @@ export function OrgOverviewGraph({entry.sdkName,entry.sdkVersion,entry.publicKey,- entry.isInternal,]);const client = clients.get(key) ?? {sdkName: entry.sdkName,sdkVersion: entry.sdkVersion,current: 0,previous: 0,+ internalCurrent: 0,+ internalPrevious: 0,scoreCurrent: 0,scorePrevious: 0,lastSeen: null,+ v4Migration: entry.v4Migration,};if (isEvent) {client.current += entry.current;client.previous += entry.previous;+ if (entry.isInternal) {+ client.internalCurrent += entry.current;+ client.internalPrevious += entry.previous;+ }} else {client.scoreCurrent += entry.current;client.scorePrevious += entry.previous;}+ if (entry.v4Migration === "required") {+ client.v4Migration = "required";+ } else if (+ entry.v4Migration === "not_required" &&+ client.v4Migration === "unknown"+ ) {+ client.v4Migration = "not_required";+ }if (!client.lastSeen ||Date.parse(entry.lastSeen) > Date.parse(client.lastSeen)@@ -340,6 +464,16 @@ export function OrgOverviewGraph({continue;if (!projectMatches && visibleClients.length === 0) continue;+ const projectRowOffset = Math.max(visibleClients.length - 1, 0) / 2;+ if (previousProjectY !== null) {+ row = Math.max(+ row,+ (previousProjectY + projectSpacing) / rowSpacing - projectRowOffset,+ );+ }+ const firstRow = row;+ const projectY = (firstRow + projectRowOffset) * rowSpacing;+for (const [key, client] of visibleClients) {const clientNodeId = `client-${project.id}-${key}`;const current = client.current + client.scoreCurrent;@@ -356,8 +490,9 @@ export function OrgOverviewGraph({version: client.sdkVersion ?? "Unknown",status,lastSeen: client.lastSeen,+ v4Migration: client.v4Migration,},- position: { x: 0, y: row * 200 },+ position: { x: 0, y: row * rowSpacing },});edges.push({@@ -365,7 +500,16 @@ export function OrgOverviewGraph({source: clientNodeId,target: projectNodeId,type: "flow",- data: { events: weekOverWeek(client.current, client.previous) },+ data: {+ externalEvents: weekOverWeek(+ client.current - client.internalCurrent,+ client.previous - client.internalPrevious,+ ),+ internalEvents: weekOverWeek(+ client.internalCurrent,+ client.internalPrevious,+ ),+ },markerEnd: { type: MarkerType.ArrowClosed },});row++;@@ -376,18 +520,16 @@ export function OrgOverviewGraph({type: "project",data: {name: project.name,+ features: project.features,events: weekOverWeek(eventCurrent, eventPrevious),scores: weekOverWeek(scoreCurrent, scorePrevious),},position: {- x: 600,- y:- visibleClients.length > 0- ? ((firstRow + row - 1) / 2) * 200- : row * 200,+ x: 536,+ y: projectY,},});- if (visibleClients.length === 0) row++;+ previousProjectY = projectY;}return { nodes, edges };@@ -403,13 +545,13 @@ export function OrgOverviewGraph({<ReactFlowkey={JSON.stringify([search, activityFilter])}nodes={nodes}+ nodeOrigin={[0, 0.5]}edges={edges}nodeTypes={nodeTypes}edgeTypes={edgeTypes}fitViewfitViewOptions={{- minZoom:- search?.trim() || activityFilter ? 0.05 : (initialZoom ?? 1),+ minZoom: 0.05,maxZoom: initialZoom ?? 1,}}nodesDraggable={false}diff --git a/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsx b/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsxindex 9dc72da4db..5923891379 100644--- a/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsx+++ b/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsx@@ -2,7 +2,7 @@ import { ConnectedOrgOverviewGraph } from "../OrgOverviewGraph/ConnectedOrgOvervimport Header from "@/src/components/layouts/header";import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";import { ErrorPage } from "@/src/components/error-page";-import { useState } from "react";+import { useState, type ComponentProps } from "react";import { SearchInput } from "@/src/components/design-system/SearchInput/SearchInput";import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";@@ -16,9 +16,10 @@ export function OrganizationAnalyticsPage({const [activityFilter, setActivityFilter] = useState<"all" | "active" | "inactive">("all");- const [order, setOrder] = useState<- "billable" | "observations" | "scores" | "name"- >("billable");+ const [order, setOrder] =+ useState<ComponentProps<typeof ConnectedOrgOverviewGraph>["order"]>(+ "billable",+ );if (!internalFeaturesEnabled) {return (@@ -60,7 +61,9 @@ export function OrganizationAnalyticsPage({/></div><div className="w-52">- <SelectInput<"billable" | "observations" | "scores" | "name">+ <SelectInput<+ ComponentProps<typeof ConnectedOrgOverviewGraph>["order"]+ >value={order}onValueChange={setOrder}aria-label="Order projects"@@ -69,6 +72,14 @@ export function OrganizationAnalyticsPage({{ value: "billable", label: "Most billable units" },{ value: "observations", label: "Most observations" },{ value: "scores", label: "Most scores" },+ {+ value: "activeEvaluationRules",+ label: "Most active evaluation rules",+ },+ { value: "datasets", label: "Most datasets" },+ { value: "datasetItems", label: "Most dataset items" },+ { value: "activeMonitors", label: "Most active monitors" },+ { value: "prompts", label: "Most prompts" },{ value: "name", label: "Project name A–Z" },]}/>