🪢 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): Org-level analytics view (#18082)
Ben Bachem3532ba7a4c1b
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 017f12c7f6..fd20599928 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -722,6 +722,9 @@ importers:'@uiw/react-codemirror':specifier: ^4.25.8version: 4.25.8(@babel/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])([email protected])([email protected]([email protected]))([email protected])+ '@xyflow/react':+ specifier: ^12.12.0+ version: 12.12.0(@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])bcryptjs:specifier: ^2.4.3version: 2.4.3@@ -7273,6 +7276,22 @@ packages:'@xtuc/[email protected]':resolution: {integrity: sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==}+ '@xyflow/[email protected]':+ resolution: {integrity: sha512-74oXI0Rgm1Eu33cHQAd74J6oVgCH9mbFyTVQbsGgp2kmWwh0HdtBr2VP04z8mbPD+M/xO69nqG5dDEt7/EN2rQ==}+ peerDependencies:+ '@types/react': '>=17'+ '@types/react-dom': 19.2.3+ react: '>=17'+ react-dom: '>=17'+ peerDependenciesMeta:+ '@types/react':+ optional: true+ '@types/react-dom':+ optional: true++ '@xyflow/[email protected]':+ resolution: {integrity: sha512-a//eDjez3WZF47aaPTfVUDD0OINOq+WVwBZCRTqG+m0a5euX8EwlJ4jMY1Wxz0Ocj4xOeekJ70V22Pq0ll8RJw==}+resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}engines: {node: '>=6.5'}@@ -7735,6 +7754,9 @@ packages:resolution: {integrity: sha512-Ka+9Trutv7G8M6WT6SeiRWz792K5qEqIGEGzXKhAE6xOWAY6pPH8U+9IY3oCMv6kqTmLsv7Xh/2w2RigkePMsg==}+ resolution: {integrity: sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==}+resolution: {integrity: sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==}engines: {node: '>=18'}@@ -12677,6 +12699,21 @@ packages:resolution: {integrity: sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==}+ resolution: {integrity: sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==}+ engines: {node: '>=12.7.0'}+ peerDependencies:+ '@types/react': '>=16.8'+ immer: '>=9.0.6'+ react: '>=16.8'+ peerDependenciesMeta:+ '@types/react':+ optional: true+ immer:+ optional: true+ react:+ optional: true+resolution: {integrity: sha512-/8tAspM5LMPr28b3fwLYrtdj77ECpfZviaP75CMTnwO8ISyaE4GDIG/9rDDYq/cH9D2Xw2A2RXglLInmVBQB/g==}engines: {node: '>=12.20.0'}@@ -19127,6 +19164,31 @@ snapshots:'@xtuc/[email protected]': {}+ '@xyflow/[email protected](@types/[email protected](@types/[email protected]))(@types/[email protected])([email protected])([email protected]([email protected]))([email protected])':+ dependencies:+ '@xyflow/system': 0.0.83+ classcat: 5.0.5+ react: 19.2.4+ react-dom: 19.2.4([email protected])+ optionalDependencies:+ '@types/react': 19.2.14+ '@types/react-dom': 19.2.3(@types/[email protected])+ transitivePeerDependencies:+ - immer++ '@xyflow/[email protected]':+ dependencies:+ '@types/d3-drag': 3.0.7+ '@types/d3-interpolate': 3.0.4+ '@types/d3-selection': 3.0.11+ '@types/d3-transition': 3.0.9+ '@types/d3-zoom': 3.0.8+ d3-drag: 3.0.0+ d3-interpolate: 3.0.1+ d3-selection: 3.0.0+ d3-zoom: 3.0.0+dependencies:event-target-shim: 5.0.1@@ -19636,6 +19698,8 @@ snapshots:dependencies:clsx: 2.1.1+ [email protected]: {}+dependencies:restore-cursor: 5.1.0@@ -20527,17 +20591,6 @@ snapshots:transitivePeerDependencies:- supports-color- [email protected](@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected]([email protected])([email protected]))([email protected]):- dependencies:- debug: 3.2.7([email protected])- optionalDependencies:- '@typescript-eslint/parser': 8.67.0([email protected]([email protected])([email protected]))([email protected])([email protected])- eslint: 10.8.0([email protected])([email protected])- eslint-import-resolver-node: 0.3.10([email protected])- eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected])([email protected]))([email protected])- transitivePeerDependencies:- - supports-color-[email protected](@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected]([email protected])([email protected]))([email protected]):dependencies:debug: 3.2.7([email protected])@@ -20599,35 +20652,6 @@ snapshots:- eslint-import-resolver-webpack- supports-color- [email protected](@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected])([email protected]([email protected])([email protected]))([email protected]):- dependencies:- '@rtsao/scc': 1.1.0- array-includes: 3.1.9- array.prototype.findlastindex: 1.2.6- array.prototype.flat: 1.3.3- array.prototype.flatmap: 1.3.3- debug: 3.2.7([email protected])- doctrine: 2.1.0- eslint: 10.8.0([email protected])([email protected])- eslint-import-resolver-node: 0.3.10([email protected])- eslint-module-utils: 2.12.1(@typescript-eslint/[email protected]([email protected]([email protected])([email protected]))([email protected])([email protected]))([email protected]([email protected]))([email protected])([email protected]([email protected])([email protected]))([email protected])- hasown: 2.0.4- is-core-module: 2.16.2- is-glob: 4.0.3- minimatch: 3.1.5- object.fromentries: 2.0.8- object.groupby: 1.0.3- object.values: 1.2.1- semver: 6.3.1- string.prototype.trimend: 1.0.9- tsconfig-paths: 3.15.0- optionalDependencies:- '@typescript-eslint/parser': 8.67.0([email protected]([email protected])([email protected]))([email protected])([email protected])- transitivePeerDependencies:- - eslint-import-resolver-typescript- - eslint-import-resolver-webpack- - supports-color-dependencies:aria-query: 5.3.2@@ -25588,6 +25612,14 @@ snapshots:+ dependencies:+ use-sync-external-store: 1.6.0([email protected])+ optionalDependencies:+ '@types/react': 19.2.14+ immer: 11.1.4+ react: 19.2.4+[email protected](@types/[email protected])([email protected])([email protected])([email protected]([email protected])):optionalDependencies:'@types/react': 19.2.14diff --git a/web/package.json b/web/package.jsonindex 37ede1ea0b..08cda34895 100644--- a/web/package.json+++ b/web/package.json@@ -110,6 +110,7 @@"@typescript/typescript6": "^6.0.2","@uiw/codemirror-themes": "^4.23.7","@uiw/react-codemirror": "^4.25.8",+ "@xyflow/react": "^12.12.0","bcryptjs": "^2.4.3","bullmq": "^5.76.3","chroma-js": "^3.1.2",@@ -196,8 +197,8 @@"@types/bcryptjs": "^2.4.6","@types/chroma-js": "^3.1.2","@types/cors": "^2.8.19",- "@types/d3-selection": "^3.0.11","@types/d3-scale": "^4.0.9",+ "@types/d3-selection": "^3.0.11","@types/d3-shape": "^3.2.0","@types/d3-zoom": "^3.0.8","@types/lodash": "^4.17.24",diff --git a/web/src/features/organization-ingestion/server/organizationIngestionRouter.ts b/web/src/features/organization-ingestion/server/organizationIngestionRouter.tsindex 9d58a0d805..e7090200ff 100644--- a/web/src/features/organization-ingestion/server/organizationIngestionRouter.ts+++ b/web/src/features/organization-ingestion/server/organizationIngestionRouter.ts@@ -1,6 +1,7 @@import { z } from "zod/v4";import { TRPCError } from "@trpc/server";import { env } from "@/src/env.mjs";+import { hasInternalAccess } from "@/src/features/feature-flags/utils";import {createTRPCRouter,protectedOrganizationProcedure,@@ -13,8 +14,11 @@ export const organizationIngestionRouter = createTRPCRouter({.input(z.object({ orgId: z.string() })).query(async ({ input, ctx }) => {if (- ctx.session.user.admin !== true ||- env.LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES !== "true"+ !hasInternalAccess({+ isAdmin: ctx.session.user.admin === true,+ isExperimentalFeaturesEnabled:+ env.LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES === "true",+ }))throw new TRPCError({code: "FORBIDDEN",diff --git a/web/src/features/organization-ingestion/server/organizationIngestionService.ts b/web/src/features/organization-ingestion/server/organizationIngestionService.tsindex 6d053e9ff3..6407b385e4 100644--- a/web/src/features/organization-ingestion/server/organizationIngestionService.ts+++ b/web/src/features/organization-ingestion/server/organizationIngestionService.ts@@ -7,6 +7,7 @@ import {type IngestionSdkUpgradeStatus,} from "@langfuse/shared/src/server";import { type ScoreSourceType } from "@langfuse/shared";+import { MIGRATION_INGRESS_EVENT_SOURCES } from "@/src/features/v4/server/v4TransitionCache";const DAY_MS = 24 * 60 * 60 * 1_000;const MINUTE_MS = 60 * 1_000;@@ -149,7 +150,10 @@ export const getOrganizationIngestionOverview = async ({const [eventRows, scoreRows] = await Promise.all([queryClickhouse<ClickhouseClientRow & { ingestionPath: IngestionPath }>({query: EVENT_ROWS_QUERY,- params,+ params: {+ ...params,+ ingressSources: [...MIGRATION_INGRESS_EVENT_SOURCES],+ },tags: { route: "organization-ingestion-overview-events" },preferredClickhouseService: "EventsReadOnly",}),diff --git a/web/src/features/organizations/OrganizationSettingsPage.tsx b/web/src/features/organizations/OrganizationSettingsPage.tsxindex 2623e00169..02203ccb92 100644--- a/web/src/features/organizations/OrganizationSettingsPage.tsx+++ b/web/src/features/organizations/OrganizationSettingsPage.tsx@@ -24,7 +24,10 @@ import { env } from "@/src/env.mjs";import { OrgAuditLogsSettingsPage } from "@/src/ee/features/audit-log-viewer";import { useV4UpgradeUiFlag } from "@/src/features/v4-migration/useV4UpgradeUiEnabled";import { OrganizationFeaturePreviewsSettings } from "@/src/features/feature-flags/components/OrganizationFeaturePreviewsSettings";-import { useIsFeatureEnabled } from "@/src/features/feature-flags";+import {+ useIsFeatureEnabled,+ useInternalFeaturesEnabled,+} from "@/src/features/feature-flags";import {GatewayApiKeysPage,GatewayConfigurationPage,@@ -33,6 +36,7 @@ import {} from "@/src/features/ai-gateway";import useSessionStorage from "@/src/components/useSessionStorage";import { api } from "@/src/utils/api";+import { OrganizationAnalyticsPage } from "./components/OrganizationAnalyticsPage/OrganizationAnalyticsPage";type OrganizationSettingsPage = {title: string;@@ -43,6 +47,7 @@ type OrganizationSettingsPage = {} & ({ content: React.ReactNode } | { href: string });export function useOrganizationSettingsPages(): OrganizationSettingsPage[] {+ const internalFeaturesEnabled = useInternalFeaturesEnabled();const { organization } = useQueryProjectOrOrganization();const showBillingSettings = useHasEntitlement("cloud-billing");const hasAdminApiEntitlement = useHasEntitlement("admin-api");@@ -76,6 +81,7 @@ export function useOrganizationSettingsPages(): OrganizationSettingsPage[] {showBillingSettings: showBillingSettings && isCloudBillingAvailable,showOrgApiKeySettings,showAuditLogs,+ showAnalytics: internalFeaturesEnabled,isLangfuseCloud,showV4Migration,showAiGateway: canManageGateway && isAiGatewayEnabled,@@ -93,6 +99,7 @@ export const getOrganizationSettingsPages = ({showV4Migration,showAiGateway,showFeaturePreviews,+ showAnalytics,}: {organization: {id: string;@@ -111,6 +118,7 @@ export const getOrganizationSettingsPages = ({showV4Migration: boolean;showAiGateway: boolean;showFeaturePreviews: boolean;+ showAnalytics: boolean;}): OrganizationSettingsPage[] => [{title: "General",@@ -202,6 +210,14 @@ export const getOrganizationSettingsPages = ({content: <BillingSettings />,show: showBillingSettings,},+ {+ title: "Analytics",+ slug: "analytics",+ show: showAnalytics,+ section: "Organization",+ cmdKKeywords: ["ingestion", "observations", "scores", "usage"],+ content: <OrganizationAnalyticsPage organizationId={organization.id} />,+ },{title: "SSO",slug: "sso",diff --git a/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsx b/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsxnew file mode 100644index 0000000000..c3b952cbc1--- /dev/null+++ b/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsx@@ -0,0 +1,46 @@+import { OrgOverviewGraph } from "./OrgOverviewGraph";+import { useOrganizationIngestionOverview } from "../../hooks/useOrganizationIngestionOverview";+import { NoDataOrLoading } from "@/src/components/NoDataOrLoading";+import { ErrorPage } from "@/src/components/error-page";++export function ConnectedOrgOverviewGraph({+ organizationId,+ search,+ activityFilter,+ order,+}: {+ organizationId: string;+ search: string;+ activityFilter: "all" | "active" | "inactive";+ order: "billable" | "observations" | "scores" | "name";+}) {+ const { data, error, isLoading } =+ useOrganizationIngestionOverview(organizationId);++ if (error)+ return (+ <ErrorPage title="Unable to load analytics" message={error.message} />+ );+ if (!data) return <NoDataOrLoading isLoading={isLoading} />;++ return (+ <div className="flex h-[70vh] flex-col gap-2">+ {data.projects.length === 0 ? (+ <p className="text-muted-foreground text-sm">+ No projects in this organization.+ </p>+ ) : (+ <div className="border-border min-h-0 flex-1 overflow-hidden rounded-lg border">+ <OrgOverviewGraph+ data={data}+ search={search}+ activityFilter={+ activityFilter === "all" ? undefined : activityFilter+ }+ order={order}+ />+ </div>+ )}+ </div>+ );+}diff --git a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsx b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsxnew file mode 100644index 0000000000..c8994a5d5b--- /dev/null+++ b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsx@@ -0,0 +1,239 @@+import preview from "../../../../../.storybook/preview";+import {+ OrgOverviewGraph,+ type OrganizationIngestionOverview,+} from "./OrgOverviewGraph";++const meta = preview.meta({+ component: OrgOverviewGraph,+ parameters: { layout: "fullscreen" },+ decorators: [+ (Story) => (+ <div className="h-dvh w-full">+ <Story />+ </div>+ ),+ ],+});++const clientFields = {+ sdkName: "langfuse-js",+ sdkVersion: "4.0.0",+ canonicalSdkName: "javascript",+ sdkUpgradeStatus: "current",+ publicKey: "pk-js",+ isInternal: false,+ lastSeen: "2026-09-29T23:00:00Z",+} as const;++const exampleData: OrganizationIngestionOverview = {+ window: {+ previousFrom: "2026-09-16T00:00:00Z",+ currentFrom: "2026-09-23T00:00:00Z",+ to: "2026-09-30T00:00:00Z",+ },+ projects: [+ { id: "shiitake", name: "Shiitake" },+ { id: "porcini", name: "Porcini" },+ { id: "chanterelle", name: "Chanterelle" },+ ],+ eventRows: [+ {+ ...clientFields,+ projectId: "shiitake",+ ingestionPath: "otel",+ current: 8000,+ previous: 6000,+ },+ {+ ...clientFields,+ projectId: "shiitake",+ ingestionPath: "otel",+ sdkName: "langfuse-python",+ sdkVersion: "3.9.0",+ canonicalSdkName: "python",+ sdkUpgradeStatus: "outdated_major",+ publicKey: "pk-python",+ current: 4000,+ previous: 4000,+ },+ {+ ...clientFields,+ projectId: "porcini",+ ingestionPath: "otel",+ publicKey: "pk-staging",+ current: 0,+ previous: 200,+ lastSeen: "2026-09-20T12:00:00Z",+ },+ {+ ...clientFields,+ projectId: "chanterelle",+ ingestionPath: "otel",+ sdkName: "custom-js",+ sdkVersion: "1.0.0",+ canonicalSdkName: null,+ sdkUpgradeStatus: "unsupported_sdk",+ publicKey: null,+ current: 2883,+ previous: 0,+ },+ ],+ scoreRows: [+ {+ ...clientFields,+ projectId: "shiitake",+ source: "API",+ current: 20,+ previous: 20,+ },+ {+ ...clientFields,+ projectId: "shiitake",+ source: "EVAL",+ isInternal: true,+ current: 10,+ previous: 5,+ },+ {+ ...clientFields,+ projectId: "shiitake",+ source: "ANNOTATION",+ isInternal: true,+ current: 10,+ previous: 5,+ },+ {+ ...clientFields,+ projectId: "chanterelle",+ source: "API",+ sdkName: "custom-js",+ sdkVersion: "1.0.0",+ canonicalSdkName: null,+ sdkUpgradeStatus: "unsupported_sdk",+ publicKey: null,+ current: 3,+ previous: 0,+ },+ ],+};++export const Default = meta.story({ args: { data: exampleData } });++export const SingleProjectThreeClients = meta.story({+ args: {+ data: {+ ...exampleData,+ projects: [exampleData.projects[0]!],+ eventRows: exampleData.eventRows+ .filter((row) => row.projectId !== "porcini")+ .map((row) => ({ ...row, projectId: "shiitake" })),+ scoreRows: exampleData.scoreRows.map((row) => ({+ ...row,+ projectId: "shiitake",+ })),+ },+ },+});++const mushroomNames = [+ "Shiitake",+ "Porcini",+ "Chanterelle",+ "Morel",+ "Oyster",+ "Enoki",+ "Truffle",+ "Maitake",+ "Reishi",+ "Portobello",+ "Cremini",+ "Button",+ "King Oyster",+ "Black Trumpet",+ "Hedgehog",+ "Lobster",+ "Saffron Milk Cap",+ "Cauliflower",+ "Wood Ear",+ "Shimeji",+ "Nameko",+ "Puffball",+ "Blewit",+ "Matsutake",+];+const largeData: OrganizationIngestionOverview = {+ ...exampleData,+ projects: [],+ eventRows: [],+ scoreRows: [],+};+for (const [index, name] of mushroomNames.entries()) {+ const projectId = `mushroom-${index}`;+ const templateId = exampleData.projects[index % 3]!.id;+ const factor = 0.4 + ((index * 37 + 13) % 100) / 40;+ largeData.projects.push({ id: projectId, name: `Team ${name}` });+ for (const row of exampleData.eventRows.filter(+ (entry) => entry.projectId === templateId,+ )) {+ largeData.eventRows.push({+ ...row,+ projectId,+ current: Math.round(row.current * factor),+ previous: Math.round(row.previous * (0.5 + ((index * 19) % 80) / 40)),+ });+ }+ for (const row of exampleData.scoreRows.filter(+ (entry) => entry.projectId === templateId,+ )) {+ largeData.scoreRows.push({+ ...row,+ projectId,+ current: Math.round(row.current * factor),+ previous: Math.round(row.previous * factor),+ });+ }+}+let shuffleSeed = 42;+for (let index = largeData.projects.length - 1; index > 0; index--) {+ shuffleSeed = (shuffleSeed * 1664525 + 1013904223) % 4294967296;+ const swapIndex = shuffleSeed % (index + 1);+ [largeData.projects[index], largeData.projects[swapIndex]] = [+ largeData.projects[swapIndex]!,+ largeData.projects[index]!,+ ];+}++export const LargeOrganization = meta.story({+ args: { initialZoom: 0.35, data: largeData },+});++export const IdleProject = meta.story({+ args: {+ data: {+ ...exampleData,+ projects: [{ id: "morel", name: "Morel" }],+ eventRows: [],+ scoreRows: [],+ },+ },+});++export const UnknownSdk = meta.story({+ args: {+ data: {+ ...exampleData,+ projects: [exampleData.projects[0]!],+ eventRows: [+ {+ ...exampleData.eventRows[0]!,+ sdkName: null,+ sdkVersion: null,+ canonicalSdkName: null,+ sdkUpgradeStatus: "unknown",+ },+ ],+ scoreRows: [],+ },+ },+});diff --git a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsxnew file mode 100644index 0000000000..a5e1d9d05c--- /dev/null+++ b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx@@ -0,0 +1,423 @@+import { useMemo } from "react";+import {+ BaseEdge,+ EdgeLabelRenderer,+ Handle,+ MarkerType,+ Position,+ ReactFlow,+ getBezierPath,+ type Edge,+ type EdgeProps,+ type Node,+ type NodeProps,+} from "@xyflow/react";+import {+ ArrowDownRight,+ ArrowUpRight,+ Code2,+ FolderClosed,+} from "lucide-react";+import "@xyflow/react/dist/style.css";+import { type RouterOutputs } from "@/src/utils/api";++type WeekOverWeekCount = {+ current: number;+ previous: number;+ changePct: number | null;+};++type IngestionActivityStatus = "new" | "stopped" | "active" | "idle";++export type OrganizationIngestionOverview =+ RouterOutputs["organizationIngestion"]["overview"];++function weekOverWeek(current: number, previous: number): WeekOverWeekCount {+ if (previous === 0) {+ return { current, previous, changePct: current === 0 ? 0 : null };+ }+ return {+ current,+ previous,+ changePct: ((current - previous) / previous) * 100,+ };+}++type ClientNode = Node<+ {+ name: string;+ version: string;+ status: IngestionActivityStatus;+ lastSeen: string | null;+ },+ "client"+>;+type ProjectNode = Node<+ {+ name: string;+ events: WeekOverWeekCount;+ scores: WeekOverWeekCount;+ },+ "project"+>;+type FlowEdge = Edge<{ events: WeekOverWeekCount }, "flow">;++function ChangeIndicator({ change }: { change: number | null }) {+ if (change === null) {+ return <span className="text-blue-600 dark:text-blue-400">New</span>;+ }++ return (+ <span+ className={`inline-flex items-center tabular-nums ${change > 0 ? "text-green-600 dark:text-green-400" : ""} ${change < 0 ? "text-red-600 dark:text-red-400" : ""} ${change === 0 ? "text-muted-foreground" : ""}`}+ >+ {Math.abs(change).toFixed(2)}%+ {change > 0 && <ArrowUpRight className="size-3.5" />}+ {change < 0 && <ArrowDownRight className="size-3.5" />}+ </span>+ );+}++function FlowConnection({+ id,+ data,+ sourceX,+ sourceY,+ targetX,+ targetY,+ sourcePosition,+ targetPosition,+ markerEnd,+}: EdgeProps<FlowEdge>) {+ const [path, labelX, labelY] = getBezierPath({+ sourceX,+ sourceY,+ targetX,+ targetY,+ sourcePosition,+ targetPosition,+ });++ return (+ <>+ <BaseEdge id={id} path={path} markerEnd={markerEnd} />+ {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"+ style={{+ transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px)`,+ }}+ >+ <span className="font-bold tabular-nums">+ {data.events.current.toLocaleString()}+ </span>+ <ChangeIndicator change={data.events.changePct} />+ </div>+ </EdgeLabelRenderer>+ )}+ </>+ );+}++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">+ <span className="flex shrink-0 items-center gap-1.5">+ <Code2 className="size-3" />+ Client+ </span>+ <span+ className="text-foreground min-w-0 truncate text-right text-sm font-bold"+ title={data.name}+ >+ {data.name}+ </span>+ </div>+ <div className="text-muted-foreground mt-2 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">+ <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">+ <span>Last seen</span>+ <span className="text-foreground">+ {data.lastSeen+ ? new Date(data.lastSeen).toLocaleDateString()+ : "Never"}+ </span>+ </div>+ <Handle+ type="source"+ position={Position.Right}+ className="border-0! opacity-0!"+ />+ </div>+ );+}++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">+ <span className="flex shrink-0 items-center gap-1.5">+ <FolderClosed className="size-3" />+ Project+ </span>+ <span+ className="text-foreground min-w-0 truncate text-right text-sm font-bold"+ title={data.name}+ >+ {data.name}+ </span>+ </div>+ <div className="text-muted-foreground mt-2 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">+ {data.events.current.toLocaleString()}+ </span>+ <ChangeIndicator change={data.events.changePct} />+ </span>+ </div>+ <div className="text-muted-foreground mt-1.5 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">+ {data.scores.current.toLocaleString()}+ </span>+ <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">+ <span>Billable units (7d)</span>+ <span className="text-foreground font-bold tabular-nums">+ {(data.events.current + data.scores.current).toLocaleString()}+ </span>+ </div>+ <Handle+ type="target"+ position={Position.Left}+ className="border-0! opacity-0!"+ />+ </div>+ );+}++const nodeTypes = { client: ClientCard, project: ProjectCard };+const edgeTypes = { flow: FlowConnection };++export function OrgOverviewGraph({+ data,+ initialZoom,+ search,+ activityFilter,+ order,+}: {+ data: OrganizationIngestionOverview;+ initialZoom?: number;+ search?: string;+ activityFilter?: "active" | "inactive";+ order?: "billable" | "observations" | "scores" | "name";+}) {+ const { nodes, edges } = useMemo(() => {+ const nodes: Node[] = [];+ const edges: Edge[] = [];+ let row = 0;+ const query = search?.trim().toLowerCase() ?? "";+ const volumes = new Map<string, { observations: number; scores: number }>();+ for (const entry of data.eventRows) {+ const volume = volumes.get(entry.projectId) ?? {+ observations: 0,+ scores: 0,+ };+ volume.observations += entry.current;+ volumes.set(entry.projectId, volume);+ }+ for (const entry of data.scoreRows) {+ const volume = volumes.get(entry.projectId) ?? {+ observations: 0,+ scores: 0,+ };+ volume.scores += entry.current;+ volumes.set(entry.projectId, volume);+ }+ const projects = [...data.projects];+ if (order) {+ projects.sort((a, b) => {+ if (order === "name") return 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")+ return right.observations - left.observations;+ if (order === "scores") return right.scores - left.scores;+ return (+ right.observations + right.scores - left.observations - left.scores+ );+ });+ }++ for (const project of projects) {+ const projectNodeId = `project-${project.id}`;+ const firstRow = row;+ const clients = new Map<+ string,+ {+ sdkName: string | null;+ sdkVersion: string | null;+ current: number;+ previous: number;+ scoreCurrent: number;+ scorePrevious: number;+ lastSeen: string | null;+ }+ >();+ let eventCurrent = 0;+ let eventPrevious = 0;+ let scoreCurrent = 0;+ let scorePrevious = 0;+ for (const entry of [...data.eventRows, ...data.scoreRows]) {+ if (entry.projectId !== project.id) continue;+ const isEvent = "ingestionPath" in entry;+ if (isEvent) {+ eventCurrent += entry.current;+ eventPrevious += entry.previous;+ } else {+ scoreCurrent += entry.current;+ scorePrevious += entry.previous;+ // Evaluator and annotation scores contribute to project totals, not API client traffic.+ if (entry.source !== "API") continue;+ }+ const key = JSON.stringify([+ entry.sdkName,+ entry.sdkVersion,+ entry.publicKey,+ entry.isInternal,+ ]);+ const client = clients.get(key) ?? {+ sdkName: entry.sdkName,+ sdkVersion: entry.sdkVersion,+ current: 0,+ previous: 0,+ scoreCurrent: 0,+ scorePrevious: 0,+ lastSeen: null,+ };+ if (isEvent) {+ client.current += entry.current;+ client.previous += entry.previous;+ } else {+ client.scoreCurrent += entry.current;+ client.scorePrevious += entry.previous;+ }+ if (+ !client.lastSeen ||+ Date.parse(entry.lastSeen) > Date.parse(client.lastSeen)+ )+ client.lastSeen = entry.lastSeen;+ clients.set(key, client);+ }++ const projectMatches = project.name.toLowerCase().includes(query);+ const visibleClients = [...clients].filter(([, client]) => {+ if (+ !projectMatches &&+ !(client.sdkName ?? "Unknown client").toLowerCase().includes(query)+ )+ return false;+ const current = client.current + client.scoreCurrent;+ if (activityFilter === "active" && current === 0) return false;+ if (activityFilter === "inactive" && current > 0) return false;+ return true;+ });+ if (activityFilter === "active" && eventCurrent + scoreCurrent === 0)+ continue;+ if (activityFilter === "inactive" && eventCurrent + scoreCurrent > 0)+ continue;+ if (!projectMatches && visibleClients.length === 0) continue;++ for (const [key, client] of visibleClients) {+ const clientNodeId = `client-${project.id}-${key}`;+ const current = client.current + client.scoreCurrent;+ const previous = client.previous + client.scorePrevious;+ let status: IngestionActivityStatus = "idle";+ if (current > 0 && previous > 0) status = "active";+ else if (current > 0) status = "new";+ else if (previous > 0) status = "stopped";+ nodes.push({+ id: clientNodeId,+ type: "client",+ data: {+ name: client.sdkName ?? "Unknown client",+ version: client.sdkVersion ?? "Unknown",+ status,+ lastSeen: client.lastSeen,+ },+ position: { x: 0, y: row * 200 },+ });++ edges.push({+ id: `${clientNodeId}-${projectNodeId}`,+ source: clientNodeId,+ target: projectNodeId,+ type: "flow",+ data: { events: weekOverWeek(client.current, client.previous) },+ markerEnd: { type: MarkerType.ArrowClosed },+ });+ row++;+ }++ nodes.push({+ id: projectNodeId,+ type: "project",+ data: {+ name: project.name,+ events: weekOverWeek(eventCurrent, eventPrevious),+ scores: weekOverWeek(scoreCurrent, scorePrevious),+ },+ position: {+ x: 600,+ y:+ visibleClients.length > 0+ ? ((firstRow + row - 1) / 2) * 200+ : row * 200,+ },+ });+ if (visibleClients.length === 0) row++;+ }++ return { nodes, edges };+ }, [data, search, activityFilter, order]);++ return (+ <div className="h-full w-full">+ {nodes.length === 0 ? (+ <div className="text-muted-foreground flex h-full items-center justify-center text-sm">+ No matching projects or clients.+ </div>+ ) : (+ <ReactFlow+ key={JSON.stringify([search, activityFilter])}+ nodes={nodes}+ edges={edges}+ nodeTypes={nodeTypes}+ edgeTypes={edgeTypes}+ fitView+ fitViewOptions={{+ minZoom:+ search?.trim() || activityFilter ? 0.05 : (initialZoom ?? 1),+ maxZoom: initialZoom ?? 1,+ }}+ nodesDraggable={false}+ nodesConnectable={false}+ elementsSelectable={false}+ proOptions={{ hideAttribution: true }}+ />+ )}+ </div>+ );+}diff --git a/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsx b/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsxnew file mode 100644index 0000000000..9dc72da4db--- /dev/null+++ b/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsx@@ -0,0 +1,86 @@+import { ConnectedOrgOverviewGraph } from "../OrgOverviewGraph/ConnectedOrgOverviewGraph";+import 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 { SearchInput } from "@/src/components/design-system/SearchInput/SearchInput";+import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";++export function OrganizationAnalyticsPage({+ organizationId,+}: {+ organizationId: string;+}) {+ const internalFeaturesEnabled = useInternalFeaturesEnabled();+ const [search, setSearch] = useState("");+ const [activityFilter, setActivityFilter] = useState<+ "all" | "active" | "inactive"+ >("all");+ const [order, setOrder] = useState<+ "billable" | "observations" | "scores" | "name"+ >("billable");++ if (!internalFeaturesEnabled) {+ return (+ <ErrorPage title="Page not found" message="This page is not available." />+ );+ }++ return (+ <div className="flex flex-col gap-4">+ <div>+ <Header title="Organization Analytics" />+ <p className="text-muted-foreground text-sm">+ Explore ingestion activity across this organization’s projects and+ clients. Compare observations, scores, and billable units over the+ last seven days with the previous week.+ </p>+ </div>+ <div className="flex flex-wrap items-center gap-2">+ <div className="w-72">+ <SearchInput+ placeholder="Search projects and clients"+ value={search}+ onChange={setSearch}+ onSubmit={setSearch}+ />+ </div>+ <div className="ml-auto flex flex-wrap items-center gap-2">+ <div className="w-40">+ <SelectInput<"all" | "active" | "inactive">+ value={activityFilter}+ onValueChange={setActivityFilter}+ aria-label="Filter by activity"+ placeholder="Filter by activity"+ options={[+ { value: "all", label: "All activity" },+ { value: "active", label: "Active only" },+ { value: "inactive", label: "Inactive only" },+ ]}+ />+ </div>+ <div className="w-52">+ <SelectInput<"billable" | "observations" | "scores" | "name">+ value={order}+ onValueChange={setOrder}+ aria-label="Order projects"+ placeholder="Order projects"+ options={[+ { value: "billable", label: "Most billable units" },+ { value: "observations", label: "Most observations" },+ { value: "scores", label: "Most scores" },+ { value: "name", label: "Project name A–Z" },+ ]}+ />+ </div>+ </div>+ </div>+ <ConnectedOrgOverviewGraph+ organizationId={organizationId}+ search={search}+ activityFilter={activityFilter}+ order={order}+ />+ </div>+ );+}diff --git a/web/src/features/organizations/components/ProjectOverview.tsx b/web/src/features/organizations/components/ProjectOverview.tsxindex 7dfda6ea13..e8c2d21ba6 100644--- a/web/src/features/organizations/components/ProjectOverview.tsx+++ b/web/src/features/organizations/components/ProjectOverview.tsx@@ -5,6 +5,7 @@ import {Settings,Users,PlusIcon,+ ChartNoAxesCombined,} from "lucide-react";import {Card,@@ -45,6 +46,7 @@ import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeUimport { useAccountV4MigrationData } from "@/src/features/v4-migration/hooks/useV4MigrationData";import { getProjectMigrationReadiness } from "@/src/features/v4-migration/migrationData";import { ErrorPage } from "@/src/components/error-page";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";const OrganizationProjectTiles = ({org,@@ -201,6 +203,7 @@ const OrganizationActionButtons = ({orgId: string;primaryButtonVariant?: "default" | "secondary";}) => {+ const internalFeaturesEnabled = useInternalFeaturesEnabled();const membersViewAccess = useHasOrganizationAccess({organizationId: orgId,scope: "organizationMembers:read",@@ -211,19 +214,31 @@ const OrganizationActionButtons = ({});return (- <>- <Button asChild variant="ghost">- <Link href={`/organization/${orgId}/settings`}>- <Settings size={14} />- </Link>- </Button>- {membersViewAccess && (- <Button asChild variant="ghost">- <Link href={`/organization/${orgId}/settings/members`}>- <Users size={14} />+ <div className="flex items-center gap-4">+ <div className="flex items-center gap-0">+ {internalFeaturesEnabled && (+ <Button asChild variant="ghost" size="icon">+ <Link+ href={`/organization/${orgId}/settings/analytics`}+ aria-label="Organization analytics"+ >+ <ChartNoAxesCombined size={14} />+ </Link>+ </Button>+ )}+ <Button asChild variant="ghost" size="icon">+ <Link href={`/organization/${orgId}/settings`}>+ <Settings size={14} /></Link></Button>- )}+ {membersViewAccess && (+ <Button asChild variant="ghost" size="icon">+ <Link href={`/organization/${orgId}/settings/members`}>+ <Users size={14} />+ </Link>+ </Button>+ )}+ </div>{createProjectAccess ? (<Button asChild variant={primaryButtonVariant}><Link href={createProjectRoute(orgId)}>@@ -237,7 +252,7 @@ const OrganizationActionButtons = ({New project</Button>)}- </>+ </div>);};diff --git a/web/src/features/organizations/hooks/useOrganizationIngestionOverview.ts b/web/src/features/organizations/hooks/useOrganizationIngestionOverview.tsnew file mode 100644index 0000000000..b3fd2bbde9--- /dev/null+++ b/web/src/features/organizations/hooks/useOrganizationIngestionOverview.ts@@ -0,0 +1,10 @@+import { api } from "@/src/utils/api";+import { useInternalFeaturesEnabled } from "@/src/features/feature-flags";++export function useOrganizationIngestionOverview(organizationId: string) {+ const enabled = useInternalFeaturesEnabled();+ return api.organizationIngestion.overview.useQuery(+ { orgId: organizationId },+ { enabled: enabled && Boolean(organizationId) },+ );+}