Skip to content

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

chore(web): remove org-level ingestion overview and analytics view (#18101)

Hassieb Pakzada48751c99841
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index fd20599928..017f12c7f6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -722,9 +722,6 @@ importers:
'@uiw/react-codemirror':
specifier: ^4.25.8
- '@xyflow/react':
- specifier: ^12.12.0
bcryptjs:
specifier: ^2.4.3
version: 2.4.3
@@ -7276,22 +7273,6 @@ packages:
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'}
@@ -7754,9 +7735,6 @@ 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'}
@@ -12699,21 +12677,6 @@ 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'}
@@ -19164,31 +19127,6 @@ snapshots:
'@xtuc/[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
@@ -19698,8 +19636,6 @@ snapshots:
dependencies:
clsx: 2.1.1
-
dependencies:
restore-cursor: 5.1.0
@@ -20591,6 +20527,17 @@ snapshots:
transitivePeerDependencies:
- supports-color
+ dependencies:
+ debug: 3.2.7([email protected])
+ optionalDependencies:
+ eslint-import-resolver-node: 0.3.10([email protected])
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
debug: 3.2.7([email protected])
@@ -20652,6 +20599,35 @@ snapshots:
- eslint-import-resolver-webpack
- supports-color
+ 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-import-resolver-node: 0.3.10([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:
+ transitivePeerDependencies:
+ - eslint-import-resolver-typescript
+ - eslint-import-resolver-webpack
+ - supports-color
+
dependencies:
aria-query: 5.3.2
@@ -25612,14 +25588,6 @@ 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
-
optionalDependencies:
'@types/react': 19.2.14
diff --git a/web/package.json b/web/package.json
index 08cda34895..37ede1ea0b 100644
--- a/web/package.json
+++ b/web/package.json
@@ -110,7 +110,6 @@
"@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",
@@ -197,8 +196,8 @@
"@types/bcryptjs": "^2.4.6",
"@types/chroma-js": "^3.1.2",
"@types/cors": "^2.8.19",
- "@types/d3-scale": "^4.0.9",
"@types/d3-selection": "^3.0.11",
+ "@types/d3-scale": "^4.0.9",
"@types/d3-shape": "^3.2.0",
"@types/d3-zoom": "^3.0.8",
"@types/lodash": "^4.17.24",
diff --git a/web/src/__tests__/server/unit/organizationIngestionService.servertest.ts b/web/src/__tests__/server/unit/organizationIngestionService.servertest.ts
deleted file mode 100644
index e9ba09af19..0000000000
--- a/web/src/__tests__/server/unit/organizationIngestionService.servertest.ts
+++ /dev/null
@@ -1,80 +0,0 @@
-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/organizationIngestionRouter.ts b/web/src/features/organization-ingestion/server/organizationIngestionRouter.ts
deleted file mode 100644
index 07926f9d35..0000000000
--- a/web/src/features/organization-ingestion/server/organizationIngestionRouter.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-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,
-} from "@/src/server/api/trpc";
-import { getAccessibleOrganizationProjects } from "@/src/features/v4/server/v4TransitionService";
-import { getOrganizationIngestionOverview } from "@/src/features/organization-ingestion/server/organizationIngestionService";
-
-export const organizationIngestionRouter = createTRPCRouter({
- overview: protectedOrganizationProcedure
- .input(z.object({ orgId: z.string() }))
- .query(async ({ input, ctx }) => {
- if (
- !hasInternalAccess({
- isAdmin: ctx.session.user.admin === true,
- isExperimentalFeaturesEnabled:
- env.LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES === "true",
- })
- )
- throw new TRPCError({
- code: "FORBIDDEN",
- message:
- "The organization ingestion overview is an internal preview.",
- });
-
- const projects = await getAccessibleOrganizationProjects({
- prisma: ctx.prisma,
- orgId: input.orgId,
- session: ctx.session,
- });
-
- return getOrganizationIngestionOverview({ prisma: ctx.prisma, projects });
- }),
-});
diff --git a/web/src/features/organization-ingestion/server/organizationIngestionService.ts b/web/src/features/organization-ingestion/server/organizationIngestionService.ts
deleted file mode 100644
index a4f7a21760..0000000000
--- a/web/src/features/organization-ingestion/server/organizationIngestionService.ts
+++ /dev/null
@@ -1,298 +0,0 @@
-import {
- classifyIngestionSdkVersion,
- convertDateToClickhouseDateTime,
- queryClickhouse,
- UNKNOWN_INGESTION_SDK_VALUE,
- type IngestionSdkCanonicalName,
- type IngestionSdkUpgradeStatus,
-} 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;
-const ORGANIZATION_INGESTION_WINDOW_MS = 7 * DAY_MS;
-
-type IngestionPath = "otel" | "ingestion_api";
-
-/** Ingesting client identity shared by event and score rows. */
-type IngestionClientFields = {
- sdkName: string | null;
- 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;
- /** Count in [`window.currentFrom`, `window.to`). */
- current: number;
- /** Count in [`window.previousFrom`, `window.currentFrom`). */
- previous: number;
- /** Latest timestamp across both windows (ISO, UTC). */
- lastSeen: string;
-};
-
-/** Current configuration counts, not scoped to the ingestion windows. */
-type ProjectFeatureCounts = {
- activeEvaluationRules: number;
- datasets: number;
- /** Latest, non-deleted dataset item versions. */
- datasetItems: number;
- activeMonitors: number;
- /** Distinct prompt names, not versions. */
- prompts: number;
-};
-
-type OrganizationIngestionOverview = {
- window: { previousFrom: string; currentFrom: string; to: string };
- projects: { id: string; name: string; features: ProjectFeatureCounts }[];
- eventRows: (IngestionClientFields & {
- projectId: string;
- ingestionPath: IngestionPath;
- })[];
- scoreRows: (IngestionClientFields & {
- projectId: string;
- source: ScoreSourceType;
- })[];
-};
-
-type ClickhouseClientRow = {
- projectId: string;
- sdkName: string;
- sdkVersion: string;
- publicKey: string;
- isInternal: boolean | string | number;
- currentCount: string | number;
- previousCount: string | number;
- lastSeen: string;
-};
-
-const EVENT_ROWS_QUERY = `
-SELECT
- project_id AS projectId,
- if(startsWith(source, 'otel'), 'otel', 'ingestion_api') AS ingestionPath,
- ingestion_sdk_name AS sdkName,
- ingestion_sdk_version AS sdkVersion,
- ingestion_api_key AS publicKey,
- startsWith(environment, 'langfuse-') AS isInternal,
- countIf(start_time >= {currentFrom: DateTime64(3)}) AS currentCount,
- countIf(start_time < {currentFrom: DateTime64(3)}) AS previousCount,
- formatDateTime(max(start_time), '%Y-%m-%dT%H:%i:%SZ', 'UTC') AS lastSeen
-FROM events_core
-WHERE
- project_id IN {projectIds: Array(String)}
- AND start_time >= {previousFrom: DateTime64(3)}
- AND start_time < {to: DateTime64(3)}
- AND is_deleted = 0
-GROUP BY projectId, ingestionPath, sdkName, sdkVersion, publicKey, isInternal
-`;
-
-const SCORE_ROWS_QUERY = `
-SELECT
- project_id AS projectId,
- source,
- ingestion_sdk_name AS sdkName,
- ingestion_sdk_version AS sdkVersion,
- ingestion_api_key AS publicKey,
- startsWith(environment, 'langfuse-') AS isInternal,
- countIf(timestamp >= {currentFrom: DateTime64(3)}) AS currentCount,
- countIf(timestamp < {currentFrom: DateTime64(3)}) AS previousCount,
- formatDateTime(max(timestamp), '%Y-%m-%dT%H:%i:%SZ', 'UTC') AS lastSeen
-FROM scores
-WHERE
- project_id IN {projectIds: Array(String)}
- AND timestamp >= {previousFrom: DateTime64(3)}
- AND timestamp < {to: DateTime64(3)}
- AND is_deleted = 0
-GROUP BY projectId, source, sdkName, sdkVersion, publicKey, isInternal
-`;
-
-const toNullableSdkValue = (value: string): string | null =>
- value === "" || value === UNKNOWN_INGESTION_SDK_VALUE ? null : value;
-
-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,
- current: Number(row.currentCount),
- previous: Number(row.previousCount),
- lastSeen: row.lastSeen,
- };
-};
-
-const getProjectFeatureCounts = async ({
- prisma,
- projectIds,
-}: {
- prisma: PrismaClient;
- projectIds: string[];
-}): Promise<Map<string, ProjectFeatureCounts>> => {
- const [evaluationRules, datasets, datasetItems, monitors, prompts] =
- await Promise.all([
- prisma.evaluationRule.groupBy({
- by: ["projectId"],
- where: { projectId: { in: projectIds }, status: "ACTIVE" },
- _count: { _all: true },
- }),
- prisma.dataset.groupBy({
- by: ["projectId"],
- where: { projectId: { in: projectIds } },
- _count: { _all: true },
- }),
- prisma.datasetItem.groupBy({
- by: ["projectId"],
- where: {
- projectId: { in: projectIds },
- isDeleted: false,
- validTo: null,
- },
- _count: { _all: true },
- }),
- prisma.monitor.groupBy({
- by: ["projectId"],
- where: { projectId: { in: projectIds }, status: "ACTIVE" },
- _count: { _all: true },
- }),
- prisma.$queryRaw<{ projectId: string; count: bigint }[]>(Prisma.sql`
- SELECT project_id AS "projectId", COUNT(DISTINCT name) AS count
- FROM prompts
- WHERE project_id IN (${Prisma.join(projectIds)})
- GROUP BY project_id
- `),
- ]);
-
- const toCountMap = (
- rows: { projectId: string; _count: { _all: number } }[],
- ) => new Map(rows.map((row) => [row.projectId, row._count._all]));
- const evaluationRuleCounts = toCountMap(evaluationRules);
- const datasetCounts = toCountMap(datasets);
- const datasetItemCounts = toCountMap(datasetItems);
- const monitorCounts = toCountMap(monitors);
- const promptCounts = new Map(
- prompts.map((row) => [row.projectId, Number(row.count)]),
- );
-
- return new Map(
- projectIds.map((projectId) => [
- projectId,
- {
- activeEvaluationRules: evaluationRuleCounts.get(projectId) ?? 0,
- datasets: datasetCounts.get(projectId) ?? 0,
- datasetItems: datasetItemCounts.get(projectId) ?? 0,
- activeMonitors: monitorCounts.get(projectId) ?? 0,
- prompts: promptCounts.get(projectId) ?? 0,
- },
- ]),
- );
-};
-
-export const getOrganizationIngestionOverview = async ({
- prisma,
- projects,
- nowMs = Date.now(),
-}: {
- prisma: PrismaClient;
- projects: { id: string; name: string }[];
- nowMs?: number;
-}): Promise<OrganizationIngestionOverview> => {
- const to = new Date(Math.floor(nowMs / MINUTE_MS) * MINUTE_MS);
- const currentFrom = new Date(to.getTime() - ORGANIZATION_INGESTION_WINDOW_MS);
- const previousFrom = new Date(
- currentFrom.getTime() - ORGANIZATION_INGESTION_WINDOW_MS,
- );
- const window = {
- previousFrom: previousFrom.toISOString(),
- currentFrom: currentFrom.toISOString(),
- to: to.toISOString(),
- };
-
- if (projects.length === 0) {
- return { window, projects: [], eventRows: [], scoreRows: [] };
- }
-
- const params = {
- projectIds: projects.map((project) => project.id),
- previousFrom: convertDateToClickhouseDateTime(previousFrom),
- currentFrom: convertDateToClickhouseDateTime(currentFrom),
- to: convertDateToClickhouseDateTime(to),
- };
-
- 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,
- projects: projects.map((project) => ({
- ...project,
- features: featureCounts.get(project.id)!,
- })),
- eventRows: eventRows.map((row) => ({
- projectId: row.projectId,
- ingestionPath: row.ingestionPath,
- ...toClientFields(row, migrationByClient),
- })),
- scoreRows: scoreRows.flatMap((row) => [
- {
- projectId: row.projectId,
- source: row.source as ScoreSourceType,
- ...toClientFields(row, migrationByClient),
- },
- ]),
- };
-};
diff --git a/web/src/features/organizations/OrganizationSettingsPage.tsx b/web/src/features/organizations/OrganizationSettingsPage.tsx
index 02203ccb92..2623e00169 100644
--- a/web/src/features/organizations/OrganizationSettingsPage.tsx
+++ b/web/src/features/organizations/OrganizationSettingsPage.tsx
@@ -24,10 +24,7 @@ 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,
- useInternalFeaturesEnabled,
-} from "@/src/features/feature-flags";
+import { useIsFeatureEnabled } from "@/src/features/feature-flags";
import {
GatewayApiKeysPage,
GatewayConfigurationPage,
@@ -36,7 +33,6 @@ 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;
@@ -47,7 +43,6 @@ 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");
@@ -81,7 +76,6 @@ export function useOrganizationSettingsPages(): OrganizationSettingsPage[] {
showBillingSettings: showBillingSettings && isCloudBillingAvailable,
showOrgApiKeySettings,
showAuditLogs,
- showAnalytics: internalFeaturesEnabled,
isLangfuseCloud,
showV4Migration,
showAiGateway: canManageGateway && isAiGatewayEnabled,
@@ -99,7 +93,6 @@ export const getOrganizationSettingsPages = ({
showV4Migration,
showAiGateway,
showFeaturePreviews,
- showAnalytics,
}: {
organization: {
id: string;
@@ -118,7 +111,6 @@ export const getOrganizationSettingsPages = ({
showV4Migration: boolean;
showAiGateway: boolean;
showFeaturePreviews: boolean;
- showAnalytics: boolean;
}): OrganizationSettingsPage[] => [
{
title: "General",
@@ -210,14 +202,6 @@ 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.tsx
deleted file mode 100644
index aa7d736aa7..0000000000
--- a/web/src/features/organizations/components/OrgOverviewGraph/ConnectedOrgOverviewGraph.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-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";
-
-export function ConnectedOrgOverviewGraph({
- organizationId,
- search,
- activityFilter,
- order,
-}: {
- organizationId: string;
- search: string;
- activityFilter: "all" | "active" | "inactive";
- order: NonNullable<ComponentProps<typeof OrgOverviewGraph>["order"]>;
-}) {
- 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.tsx
deleted file mode 100644
index e3440dbfa8..0000000000
--- a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.stories.tsx
+++ /dev/null
@@ -1,490 +0,0 @@
-import preview from "../../../../../.storybook/preview";
-import { expect, userEvent, waitFor, within } from "storybook/test";
-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",
- v4Migration: "not_required",
- publicKey: "pk-js",
- isInternal: false,
- lastSeen: "2026-09-29T23:00:00Z",
-} as const;
-
-const noFeatures = {
- activeEvaluationRules: 0,
- datasets: 0,
- datasetItems: 0,
- activeMonitors: 0,
- prompts: 0,
-};
-
-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",
- features: {
- activeEvaluationRules: 4,
- datasets: 3,
- datasetItems: 1250,
- activeMonitors: 2,
- prompts: 12,
- },
- },
- {
- id: "porcini",
- name: "Porcini",
- features: {
- activeEvaluationRules: 1,
- datasets: 1,
- datasetItems: 40,
- activeMonitors: 0,
- prompts: 3,
- },
- },
- { id: "chanterelle", name: "Chanterelle", features: noFeatures },
- ],
- 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",
- v4Migration: "required",
- 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 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: {
- ...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 template = exampleData.projects[index % 3]!;
- const templateId = template.id;
- const factor = 0.4 + ((index * 37 + 13) % 100) / 40;
- largeData.projects.push({
- id: projectId,
- name: `Team ${name}`,
- features: template.features,
- });
- 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", features: noFeatures }],
- 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",
- v4Migration: "unknown",
- },
- ],
- scoreRows: [],
- },
- },
-});
diff --git a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx b/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx
deleted file mode 100644
index 84d2b761bb..0000000000
--- a/web/src/features/organizations/components/OrgOverviewGraph/OrgOverviewGraph.tsx
+++ /dev/null
@@ -1,565 +0,0 @@
-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,
- 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;
- 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;
- v4Migration: OrganizationIngestionOverview["eventRows"][number]["v4Migration"];
- },
- "client"
->;
-type ProjectNode = Node<
- {
- name: string;
- features: OrganizationIngestionOverview["projects"][number]["features"];
- events: WeekOverWeekCount;
- scores: WeekOverWeekCount;
- },
- "project"
->;
-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) {
- 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,
- });
- const hasInternalUsage =
- data &&
- (data.internalEvents.current > 0 || data.internalEvents.previous > 0);
-
- return (
- <>
- <BaseEdge id={id} path={path} markerEnd={markerEnd} />
- {data && (
- <EdgeLabelRenderer>
- <div
- 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)`,
- }}
- >
- {hasInternalUsage && (
- <span className="text-muted-foreground">External</span>
- )}
- <span className="text-right font-bold tabular-nums">
- {data.externalEvents.current.toLocaleString()}
- </span>
- <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>
- )}
- </>
- );
-}
-
-function ClientCard({ data }: NodeProps<ClientNode>) {
- return (
- <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
- </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-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 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 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>
- <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>
- <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-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
- </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 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">
- {data.events.current.toLocaleString()}
- </span>
- <ChangeIndicator change={data.events.changePct} />
- </span>
- </div>
- <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">
- {data.scores.current.toLocaleString()}
- </span>
- <ChangeIndicator change={data.scores.changePct} />
- </span>
- </div>
- <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()}
- </span>
- </div>
- <Handle
- type="target"
- position={Position.Left}
- className="border-0! opacity-0!"
- />
- </div>
- );
-}
-
-const nodeTypes = { client: ClientCard, project: ProjectCard };
-const edgeTypes = { flow: FlowConnection };
-const rowSpacing = 160;
-const projectSpacing = 288;
-
-export function OrgOverviewGraph({
- data,
- initialZoom,
- search,
- activityFilter,
- order,
-}: {
- data: OrganizationIngestionOverview;
- initialZoom?: number;
- search?: string;
- activityFilter?: "active" | "inactive";
- 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) {
- 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);
- 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")
- 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 clients = new Map<
- string,
- {
- sdkName: string | null;
- 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;
- 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,
- ]);
- 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)
- )
- 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;
-
- 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;
- 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,
- v4Migration: client.v4Migration,
- },
- position: { x: 0, y: row * rowSpacing },
- });
-
- edges.push({
- id: `${clientNodeId}-${projectNodeId}`,
- source: clientNodeId,
- target: projectNodeId,
- type: "flow",
- data: {
- externalEvents: weekOverWeek(
- client.current - client.internalCurrent,
- client.previous - client.internalPrevious,
- ),
- internalEvents: weekOverWeek(
- client.internalCurrent,
- client.internalPrevious,
- ),
- },
- markerEnd: { type: MarkerType.ArrowClosed },
- });
- row++;
- }
-
- nodes.push({
- id: projectNodeId,
- type: "project",
- data: {
- name: project.name,
- features: project.features,
- events: weekOverWeek(eventCurrent, eventPrevious),
- scores: weekOverWeek(scoreCurrent, scorePrevious),
- },
- position: {
- x: 536,
- y: projectY,
- },
- });
- previousProjectY = projectY;
- }
-
- 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}
- nodeOrigin={[0, 0.5]}
- edges={edges}
- nodeTypes={nodeTypes}
- edgeTypes={edgeTypes}
- fitView
- fitViewOptions={{
- minZoom: 0.05,
- 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.tsx
deleted file mode 100644
index 5923891379..0000000000
--- a/web/src/features/organizations/components/OrganizationAnalyticsPage/OrganizationAnalyticsPage.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-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, type ComponentProps } 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<ComponentProps<typeof ConnectedOrgOverviewGraph>["order"]>(
- "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<
- ComponentProps<typeof ConnectedOrgOverviewGraph>["order"]
- >
- 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: "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" },
- ]}
- />
- </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.tsx
index e8c2d21ba6..7dfda6ea13 100644
--- a/web/src/features/organizations/components/ProjectOverview.tsx
+++ b/web/src/features/organizations/components/ProjectOverview.tsx
@@ -5,7 +5,6 @@ import {
Settings,
Users,
PlusIcon,
- ChartNoAxesCombined,
} from "lucide-react";
import {
Card,
@@ -46,7 +45,6 @@ import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeU
import { 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,
@@ -203,7 +201,6 @@ const OrganizationActionButtons = ({
orgId: string;
primaryButtonVariant?: "default" | "secondary";
}) => {
- const internalFeaturesEnabled = useInternalFeaturesEnabled();
const membersViewAccess = useHasOrganizationAccess({
organizationId: orgId,
scope: "organizationMembers:read",
@@ -214,31 +211,19 @@ const OrganizationActionButtons = ({
});
return (
- <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} />
+ <>
+ <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} />
</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)}>
@@ -252,7 +237,7 @@ const OrganizationActionButtons = ({
New project
</Button>
)}
- </div>
+ </>
);
};
diff --git a/web/src/features/organizations/hooks/useOrganizationIngestionOverview.ts b/web/src/features/organizations/hooks/useOrganizationIngestionOverview.ts
deleted file mode 100644
index b3fd2bbde9..0000000000
--- a/web/src/features/organizations/hooks/useOrganizationIngestionOverview.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-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) },
- );
-}
diff --git a/web/src/server/api/root.ts b/web/src/server/api/root.ts
index 8a1e5dcab5..a8722501a7 100644
--- a/web/src/server/api/root.ts
+++ b/web/src/server/api/root.ts
@@ -63,7 +63,6 @@ import { inAppAgentRouter } from "@/src/features/in-app-agent/server/router";
import { v4TransitionRouter } from "@/src/features/v4/server/v4TransitionRouter";
import { aiGatewayRouter } from "@/src/features/ai-gateway/server";
import { skillRouter } from "@/src/features/skills/server/skill-router";
-import { organizationIngestionRouter } from "@/src/features/organization-ingestion/server/organizationIngestionRouter";
/**
* This is the primary router for your server.
@@ -85,7 +84,6 @@ export const appRouter = createTRPCRouter({
dashboard: dashboardRouter,
organizations: organizationsRouter,
organizationApiKeys: organizationApiKeysRouter,
- organizationIngestion: organizationIngestionRouter,
verifiedDomain: verifiedDomainRouter,
ssoConfig: ssoConfigRouter,
projects: projectsRouter,