Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langfuse Langfuse DashboardService Types

From Leeroopedia
Revision as of 13:12, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Langfuse_Langfuse_DashboardService_Types.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Dashboard, Zod Schemas, Type Definitions
Last Updated 2026-02-14 00:00 GMT

Overview

Zod schema definitions and derived TypeScript types for the Langfuse dashboard system, covering dashboard definitions, widget configurations, chart types, dimensions, metrics, and layout positioning.

Description

This module defines the complete type system for the Langfuse dashboard feature using Zod v4 schemas. It provides validation schemas for both the dashboard structure and the widgets that compose it.

Chart configuration schemas:

  • Time series chart configs: LineChartTimeSeriesConfig, BarChartTimeSeriesConfig, AreaChartTimeSeriesConfig
  • Total value chart configs: HorizontalBarChartConfig (with optional value labels), VerticalBarChartConfig, PieChartConfig
  • Special chart configs: BigNumberChartConfig, HistogramChartConfig (with configurable bins 1-100, default 10), PivotTableChartConfig (with optional default sort)
  • All total-value configs support an optional row_limit (integer, positive, max 1000)

Core schemas:

  • ChartConfigSchema: Discriminated union of all chart config types, keyed by the type field
  • DimensionSchema: Defines a dimension with a field string
  • MetricSchema: Defines a metric with measure and agg (aggregation) strings
  • DashboardDefinitionSchema: Dashboard layout with a widgets array of positioned widget references (x, y, x_size, y_size)
  • DashboardDomainSchema: Full dashboard domain object with ID, timestamps, creator info, name, description, definition, filters, and owner scope
  • WidgetDomainSchema: Full widget domain object with view, dimensions, metrics, filters, chartType, chartConfig, and owner
  • CreateWidgetInputSchema: Input schema for widget creation
  • OwnerEnum: Either "PROJECT" or "LANGFUSE" (for system-provided dashboards)

Derived types: DashboardDomain, DashboardListResponse, WidgetDomain, CreateWidgetInput, WidgetListResponse

Usage

Use these schemas for validating dashboard and widget data in tRPC routes, API endpoints, and service methods. The derived types are used throughout the dashboard feature components and services.

Code Reference

Source Location

Signature

export const ChartConfigSchema: z.ZodDiscriminatedUnion<...>;
export const DimensionSchema: z.ZodObject<{ field: z.ZodString }>;
export const MetricSchema: z.ZodObject<{ measure: z.ZodString; agg: z.ZodString }>;
export const DashboardDefinitionSchema: z.ZodObject<...>;
export const DashboardDomainSchema: z.ZodObject<...>;
export const WidgetDomainSchema: z.ZodObject<...>;
export const CreateWidgetInputSchema: z.ZodObject<...>;
export const OwnerEnum: z.ZodEnum<["PROJECT", "LANGFUSE"]>;

export type DashboardDomain = z.infer<typeof DashboardDomainSchema>;
export type DashboardListResponse = z.infer<typeof DashboardListResponseSchema>;
export type WidgetDomain = z.infer<typeof WidgetDomainSchema>;
export type CreateWidgetInput = z.infer<typeof CreateWidgetInputSchema>;
export type WidgetListResponse = z.infer<typeof WidgetListResponseSchema>;

Import

import {
  DashboardDomainSchema,
  WidgetDomainSchema,
  CreateWidgetInputSchema,
  ChartConfigSchema,
  type DashboardDomain,
  type WidgetDomain,
  type CreateWidgetInput,
} from "@langfuse/shared/src/server/services/DashboardService/types";

I/O Contract

Inputs

The schemas serve as validators rather than functions. They accept raw data for parsing.

Schema Validates Key Fields
DashboardDomainSchema Dashboard domain objects id, name, description, definition (widgets layout), filters, owner
WidgetDomainSchema Widget domain objects id, name, view, dimensions, metrics, filters, chartType, chartConfig
CreateWidgetInputSchema Widget creation input name (min 1 char), description, view, dimensions, metrics, filters, chartType, chartConfig
ChartConfigSchema Chart configuration Discriminated by type: LINE_TIME_SERIES, BAR_TIME_SERIES, AREA_TIME_SERIES, HORIZONTAL_BAR, VERTICAL_BAR, PIE, NUMBER, HISTOGRAM, PIVOT_TABLE

Outputs

Name Type Description
DashboardDomain TypeScript type Inferred type from DashboardDomainSchema
WidgetDomain TypeScript type Inferred type from WidgetDomainSchema including all chart config variants
CreateWidgetInput TypeScript type Inferred type for widget creation payloads

Usage Examples

import {
  CreateWidgetInputSchema,
  ChartConfigSchema,
  type WidgetDomain,
} from "./types";

// Validate widget creation input
const input = CreateWidgetInputSchema.parse({
  name: "Cost Over Time",
  description: "Daily cost breakdown",
  view: "TRACES",
  dimensions: [{ field: "date" }],
  metrics: [{ measure: "totalCost", agg: "sum" }],
  filters: [],
  chartType: "LINE_TIME_SERIES",
  chartConfig: { type: "LINE_TIME_SERIES" },
});

// Validate chart config
const config = ChartConfigSchema.parse({
  type: "HISTOGRAM",
  bins: 20,
});

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment