Skip to content

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

feat(ui): add onboarding screens for core features (#5706)

Marc Klingenc7e7d62f47f5
diff --git a/packages/shared/src/server/repositories/scores.ts b/packages/shared/src/server/repositories/scores.ts
index 6381221875..1d23346645 100644
--- a/packages/shared/src/server/repositories/scores.ts
+++ b/packages/shared/src/server/repositories/scores.ts
@@ -878,3 +878,27 @@ export const getScoresForPostHog = async function* (
};
}
};
+
+export const hasAnyScore = async (projectId: string) => {
+ const query = `
+ SELECT 1
+ FROM scores
+ WHERE project_id = {projectId: String}
+ LIMIT 1
+ `;
+
+ const rows = await queryClickhouse<{ 1: number }>({
+ query,
+ params: {
+ projectId,
+ },
+ tags: {
+ feature: "tracing",
+ type: "score",
+ kind: "hasAny",
+ projectId,
+ },
+ });
+
+ return rows.length > 0;
+};
diff --git a/packages/shared/src/server/repositories/trace-sessions.ts b/packages/shared/src/server/repositories/trace-sessions.ts
index 0da36f3057..bec8c5ea97 100644
--- a/packages/shared/src/server/repositories/trace-sessions.ts
+++ b/packages/shared/src/server/repositories/trace-sessions.ts
@@ -59,3 +59,14 @@ export const getPublicSessionsFilter = async (
? [...filter.filter((f) => f.column !== "⭐️"), ...additionalBookmarkFilter]
: [...additionalBookmarkFilter];
};
+
+export const hasAnySession = async (projectId: string) => {
+ const count = await prisma.traceSession.count({
+ where: {
+ projectId,
+ },
+ take: 1,
+ });
+
+ return count > 0;
+};
diff --git a/packages/shared/src/server/repositories/traces.ts b/packages/shared/src/server/repositories/traces.ts
index 34bd325f69..81eaf6661c 100644
--- a/packages/shared/src/server/repositories/traces.ts
+++ b/packages/shared/src/server/repositories/traces.ts
@@ -196,13 +196,13 @@ export const getTracesBySessionId = async (
export const hasAnyTrace = async (projectId: string) => {
const query = `
- SELECT count(*) as count
+ SELECT 1
FROM traces
WHERE project_id = {projectId: String}
LIMIT 1
`;
- const rows = await queryClickhouse<{ count: string }>({
+ const rows = await queryClickhouse<{ 1: number }>({
query,
params: {
projectId,
@@ -210,12 +210,12 @@ export const hasAnyTrace = async (projectId: string) => {
tags: {
feature: "tracing",
type: "trace",
- kind: "exists",
+ kind: "hasAny",
projectId,
},
});
- return rows.length > 0 && Number(rows[0].count) > 0;
+ return rows.length > 0;
};
export const getTraceCountsByProjectInCreationInterval = async ({
@@ -562,6 +562,32 @@ export const deleteTracesByProjectId = async (projectId: string) => {
});
};
+export const hasAnyUser = async (projectId: string) => {
+ const query = `
+ SELECT 1
+ FROM traces
+ WHERE project_id = {projectId: String}
+ AND user_id IS NOT NULL
+ AND user_id != ''
+ LIMIT 1
+ `;
+
+ const rows = await queryClickhouse<{ 1: number }>({
+ query,
+ params: {
+ projectId,
+ },
+ tags: {
+ feature: "tracing",
+ type: "user",
+ kind: "hasAny",
+ projectId,
+ },
+ });
+
+ return rows.length > 0;
+};
+
export const getTotalUserCount = async (
projectId: string,
filter: FilterState,
diff --git a/web/src/components/onboarding/AnnotationQueuesOnboarding.tsx b/web/src/components/onboarding/AnnotationQueuesOnboarding.tsx
new file mode 100644
index 0000000000..cb84b9ca15
--- /dev/null
+++ b/web/src/components/onboarding/AnnotationQueuesOnboarding.tsx
@@ -0,0 +1,63 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { ClipboardCheck, Users, BarChart4, GitMerge } from "lucide-react";
+import { CreateOrEditAnnotationQueueButton } from "@/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton";
+
+export function AnnotationQueuesOnboarding({
+ projectId,
+}: {
+ projectId: string;
+}) {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Manage scoring workflows",
+ description:
+ "Create and manage annotation queues to streamline your scoring workflows",
+ icon: <ClipboardCheck className="h-4 w-4" />,
+ },
+ {
+ title: "Collaborate with annotators",
+ description:
+ "Invite team members to annotate and evaluate your LLM outputs",
+ icon: <Users className="h-4 w-4" />,
+ },
+ {
+ title: "Track annotation metrics",
+ description:
+ "Monitor annotation progress and quality metrics across your team",
+ icon: <BarChart4 className="h-4 w-4" />,
+ },
+ {
+ title: "Improve model performance",
+ description:
+ "Use annotation data to identify patterns and improve your models",
+ icon: <GitMerge className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with Annotation Queues"
+ description="Annotation queues help you manage scoring workflows for your LLM projects. Create queues, assign annotators, and track progress to improve your model's performance."
+ valuePropositions={valuePropositions}
+ primaryAction={{
+ label: "Create Annotation Queue",
+ component: (
+ <CreateOrEditAnnotationQueueButton
+ variant="secondary"
+ projectId={projectId}
+ size="lg"
+ />
+ ),
+ }}
+ secondaryAction={{
+ label: "Learn More",
+ href: "https://langfuse.com/docs/scores/annotation",
+ }}
+ videoSrc="https://static.langfuse.com/prod-assets/onboarding/annotation-queue-overview-v1.mp4"
+ />
+ );
+}
diff --git a/web/src/components/onboarding/DatasetsOnboarding.tsx b/web/src/components/onboarding/DatasetsOnboarding.tsx
new file mode 100644
index 0000000000..5c2f5bd3b7
--- /dev/null
+++ b/web/src/components/onboarding/DatasetsOnboarding.tsx
@@ -0,0 +1,58 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { Database, Beaker, Zap, Code } from "lucide-react";
+import { DatasetActionButton } from "@/src/features/datasets/components/DatasetActionButton";
+
+export function DatasetsOnboarding({ projectId }: { projectId: string }) {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Continuous improvement",
+ description:
+ "Create datasets from production edge cases to improve your application",
+ icon: <Zap className="h-4 w-4" />,
+ },
+ {
+ title: "Pre-deployment testing",
+ description: "Benchmark new releases before deploying to production",
+ icon: <Beaker className="h-4 w-4" />,
+ },
+ {
+ title: "Structured testing",
+ description:
+ "Run experiments on collections of inputs and expected outputs",
+ icon: <Database className="h-4 w-4" />,
+ },
+ {
+ title: "Custom workflows",
+ description:
+ "Build custom workflows around your datasets via the API and SDKs, e.g. for fine-tuning, few-shotting",
+ icon: <Code className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with Datasets"
+ description="Datasets in Langfuse are collections of inputs (and expected outputs) for your LLM application. You can for example use them to benchmark new releases before deployment to production."
+ valuePropositions={valuePropositions}
+ primaryAction={{
+ label: "Create Dataset",
+ component: (
+ <DatasetActionButton
+ variant="default"
+ mode="create"
+ projectId={projectId}
+ size="lg"
+ />
+ ),
+ }}
+ secondaryAction={{
+ label: "Learn More",
+ href: "https://langfuse.com/docs/datasets",
+ }}
+ />
+ );
+}
diff --git a/web/src/components/onboarding/EvaluatorsOnboarding.tsx b/web/src/components/onboarding/EvaluatorsOnboarding.tsx
new file mode 100644
index 0000000000..1b67849813
--- /dev/null
+++ b/web/src/components/onboarding/EvaluatorsOnboarding.tsx
@@ -0,0 +1,56 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { Bot, Gauge, Zap, BarChart4 } from "lucide-react";
+
+interface EvaluatorsOnboardingProps {
+ projectId: string;
+}
+
+export function EvaluatorsOnboarding({ projectId }: EvaluatorsOnboardingProps) {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Automate evaluations",
+ description:
+ "Use LLM-as-a-judge to automatically evaluate your traces without manual review",
+ icon: <Bot className="h-4 w-4" />,
+ },
+ {
+ title: "Measure quality",
+ description:
+ "Create custom evaluation criteria to measure the quality of your LLM outputs",
+ icon: <Gauge className="h-4 w-4" />,
+ },
+ {
+ title: "Scale efficiently",
+ description:
+ "Evaluate thousands of traces automatically with customizable sampling rates",
+ icon: <Zap className="h-4 w-4" />,
+ },
+ {
+ title: "Track performance",
+ description:
+ "Monitor evaluation metrics over time to identify trends and improvements",
+ icon: <BarChart4 className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with LLM-as-a-Judge Evaluations"
+ description="Create evaluation templates and evaluators to automatically score your traces with LLM-as-a-judge. Set up custom evaluation criteria and let AI help you measure the quality of your outputs."
+ valuePropositions={valuePropositions}
+ primaryAction={{
+ label: "Create Evaluator",
+ href: `/project/${projectId}/evals/new`,
+ }}
+ secondaryAction={{
+ label: "Learn More",
+ href: "https://langfuse.com/docs/scores/model-based-evals",
+ }}
+ videoSrc="https://static.langfuse.com/prod-assets/onboarding/scores-llm-as-a-judge-overview-v1.mp4"
+ />
+ );
+}
diff --git a/web/src/components/onboarding/PromptsOnboarding.tsx b/web/src/components/onboarding/PromptsOnboarding.tsx
new file mode 100644
index 0000000000..5f25ef206c
--- /dev/null
+++ b/web/src/components/onboarding/PromptsOnboarding.tsx
@@ -0,0 +1,51 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { FileText, GitBranch, Zap, BarChart4 } from "lucide-react";
+
+export function PromptsOnboarding({ projectId }: { projectId: string }) {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Decoupled from code",
+ description:
+ "Deploy new prompts without application redeployment, making updates faster and easier",
+ icon: <FileText className="h-4 w-4" />,
+ },
+ {
+ title: "Edit in UI or programmatically",
+ description:
+ "Non-technical users can easily edit prompts in the UI. Developers can optionally update prompts programmatically via the API and SDKs",
+ icon: <GitBranch className="h-4 w-4" />,
+ },
+ {
+ title: "Performance optimized",
+ description:
+ "Client-side caching prevents latency or availability issues for your applications",
+ icon: <Zap className="h-4 w-4" />,
+ },
+ {
+ title: "Compare metrics",
+ description:
+ "Track latency, cost, and evaluation metrics across different prompt versions",
+ icon: <BarChart4 className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with Prompt Management"
+ description="Langfuse Prompt Management helps you centrally manage, version control, and collaboratively iterate on your prompts. Start using prompt management to improve your LLM application's performance and maintainability."
+ valuePropositions={valuePropositions}
+ primaryAction={{
+ label: "Create Prompt",
+ href: `/project/${projectId}/prompts/new`,
+ }}
+ secondaryAction={{
+ label: "Learn More",
+ href: "https://langfuse.com/docs/prompts",
+ }}
+ />
+ );
+}
diff --git a/web/src/components/onboarding/ScoresOnboarding.tsx b/web/src/components/onboarding/ScoresOnboarding.tsx
new file mode 100644
index 0000000000..512dd945bf
--- /dev/null
+++ b/web/src/components/onboarding/ScoresOnboarding.tsx
@@ -0,0 +1,48 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { ThumbsUp, Star, LineChart, Code } from "lucide-react";
+
+export function ScoresOnboarding() {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Collect user feedback",
+ description:
+ "Gather thumbs up/down feedback from users to identify high and low quality outputs",
+ icon: <ThumbsUp className="h-4 w-4" />,
+ },
+ {
+ title: "Run model-based evaluations",
+ description:
+ "Use LLMs to automatically evaluate your application's outputs",
+ icon: <Star className="h-4 w-4" />,
+ },
+ {
+ title: "Track quality metrics",
+ description:
+ "Monitor quality metrics over time to identify trends and issues",
+ icon: <LineChart className="h-4 w-4" />,
+ },
+ {
+ title: "Use custom metrics",
+ description:
+ "Langfuse's scores are flexible and can be used to track any metric that's associated with an LLM application",
+ icon: <Code className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with Scores"
+ description="Scores allow you to evaluate the quality/safety of your LLM application through user feedback, model-based evaluations, or manual review. Scores can be used programmatically via the API and SDKs to track custom metrics."
+ valuePropositions={valuePropositions}
+ secondaryAction={{
+ label: "Learn More",
+ href: "https://langfuse.com/docs/scores",
+ }}
+ videoSrc="https://static.langfuse.com/prod-assets/onboarding/scores-overview-v1.mp4"
+ />
+ );
+}
diff --git a/web/src/components/onboarding/SessionsOnboarding.tsx b/web/src/components/onboarding/SessionsOnboarding.tsx
new file mode 100644
index 0000000000..db4b446256
--- /dev/null
+++ b/web/src/components/onboarding/SessionsOnboarding.tsx
@@ -0,0 +1,56 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { BarChart4, GitMerge, MessageSquare, Users } from "lucide-react";
+import Link from "next/link";
+
+export function SessionsOnboarding() {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Group related traces",
+ description:
+ "Sessions allow you to group related traces, such as a conversation or thread, for better organization and analysis",
+ icon: <MessageSquare className="h-4 w-4" />,
+ },
+ {
+ title: "Track user interactions",
+ description: "Monitor how users interact with your application over time",
+ icon: <Users className="h-4 w-4" />,
+ },
+ {
+ title: "Analyze conversation flows",
+ description: "Understand the complete flow of multi-turn conversations",
+ icon: <GitMerge className="h-4 w-4" />,
+ },
+ {
+ title: "Session-level metrics",
+ description:
+ "Get aggregated metrics for entire sessions, including costs and token usage",
+ icon: <BarChart4 className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with Sessions"
+ description="Sessions allow you to group related traces together, such as a conversation or thread. Use sessions to track interactions over time and analyze conversation/thread flows."
+ valuePropositions={valuePropositions}
+ gettingStarted={
+ <span>
+ To start using sessions, you need to add a `sessionId` to your traces.
+ See{" "}
+ <Link
+ href="https://langfuse.com/docs/tracing-features/sessions"
+ className="underline"
+ >
+ documentation
+ </Link>{" "}
+ for more details.
+ </span>
+ }
+ videoSrc="https://static.langfuse.com/prod-assets/onboarding/sessions-overview-v1.mp4"
+ />
+ );
+}
diff --git a/web/src/components/onboarding/TracesOnboarding.tsx b/web/src/components/onboarding/TracesOnboarding.tsx
new file mode 100644
index 0000000000..dd03927b47
--- /dev/null
+++ b/web/src/components/onboarding/TracesOnboarding.tsx
@@ -0,0 +1,57 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { setupTracingRoute } from "@/src/features/setup/setupRoutes";
+import { BarChart4, GitMerge, Search, Zap } from "lucide-react";
+
+interface TracesOnboardingProps {
+ projectId: string;
+}
+
+export function TracesOnboarding({ projectId }: TracesOnboardingProps) {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Full context capture",
+ description:
+ "Track the complete execution flow including API calls, context, prompts, parallelism and more",
+ icon: <GitMerge className="h-4 w-4" />,
+ },
+ {
+ title: "Cost monitoring",
+ description: "Track model usage and costs across your application",
+ icon: <BarChart4 className="h-4 w-4" />,
+ },
+ {
+ title: "Basis for evaluation",
+ description:
+ "Add evaluation scores to identify issues and track metrics over time",
+ icon: <Search className="h-4 w-4" />,
+ },
+ {
+ title: "Open and Multi-modal",
+ description:
+ "Langfuse traces can include images, audio, and other modalities. You can fully customize them to fit your needs",
+ icon: <Zap className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with LLM Tracing"
+ description="Traces allow you to track every LLM call and other relevant logic in your app/agent. Nested traces in Langfuse help to understand what is happening and identify the root cause of problems."
+ valuePropositions={valuePropositions}
+ primaryAction={{
+ label: "Configure Tracing",
+ href: setupTracingRoute(projectId),
+ }}
+ secondaryAction={{
+ label: "View Documentation",
+ href: "https://langfuse.com/docs/tracing",
+ }}
+ videoSrc="https://static.langfuse.com/prod-assets/onboarding/tracing-overview-v1.mp4"
+ className="bg-background dark:bg-background dark:text-white"
+ />
+ );
+}
diff --git a/web/src/components/onboarding/UsersOnboarding.tsx b/web/src/components/onboarding/UsersOnboarding.tsx
new file mode 100644
index 0000000000..3c93218de8
--- /dev/null
+++ b/web/src/components/onboarding/UsersOnboarding.tsx
@@ -0,0 +1,58 @@
+import React from "react";
+import {
+ SplashScreen,
+ type ValueProposition,
+} from "@/src/components/ui/splash-screen";
+import { Users, LineChart, Filter, BarChart4 } from "lucide-react";
+import Link from "next/link";
+export function UsersOnboarding() {
+ const valuePropositions: ValueProposition[] = [
+ {
+ title: "Track user interactions",
+ description:
+ "Attribute data in Langfuse to specific users by adding a userId to your traces",
+ icon: <Users className="h-4 w-4" />,
+ },
+ {
+ title: "Analyze user behavior",
+ description:
+ "Understand how different users interact with your LLM applications",
+ icon: <LineChart className="h-4 w-4" />,
+ },
+ {
+ title: "Filter by user segments",
+ description:
+ "Compare performance across different user segments to identify patterns",
+ icon: <Filter className="h-4 w-4" />,
+ },
+ {
+ title: "Monitor usage metrics",
+ description:
+ "Track token usage, costs, and other metrics on a per-user basis",
+ icon: <BarChart4 className="h-4 w-4" />,
+ },
+ ];
+
+ return (
+ <SplashScreen
+ title="Get Started with User Tracking"
+ description="Correlate costs, evaluations and other LLM Application metrics to specific users. Start tracking users to better understand how they interact with your LLM applications."
+ valuePropositions={valuePropositions}
+ gettingStarted={
+ <span>
+ To start tracking users, you need to add a `userId` to your traces.
+ See{" "}
+ <Link
+ href="https://langfuse.com/docs/tracing-features/users"
+ className="underline"
+ >
+ documentation
+ </Link>{" "}
+ for more details.
+ </span>
+ }
+ videoSrc="https://static.langfuse.com/prod-assets/onboarding/users-overview-v1.mp4"
+ className="bg-background dark:bg-background dark:text-white"
+ />
+ );
+}
diff --git a/web/src/components/ui/alert.tsx b/web/src/components/ui/alert.tsx
index 70a1adfdce..74eb145ff6 100644
--- a/web/src/components/ui/alert.tsx
+++ b/web/src/components/ui/alert.tsx
@@ -4,7 +4,7 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/src/utils/tailwind";
const alertVariants = cva(
- "relative w-full rounded-lg border p-3 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
+ "relative w-full rounded-lg border p-3 [&>svg~*]:pl-6 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-3 [&>svg]:top-3 [&>svg]:text-foreground",
{
variants: {
variant: {
diff --git a/web/src/components/ui/splash-screen.tsx b/web/src/components/ui/splash-screen.tsx
new file mode 100644
index 0000000000..4500f60a70
--- /dev/null
+++ b/web/src/components/ui/splash-screen.tsx
@@ -0,0 +1,153 @@
+import React, { useState } from "react";
+import { cn } from "@/src/utils/tailwind";
+import Image from "next/image";
+import { InfoIcon } from "lucide-react";
+import { ActionButton } from "@/src/components/ActionButton";
+import { Alert, AlertTitle, AlertDescription } from "@/src/components/ui/alert";
+
+export interface ValueProposition {
+ title: string;
+ description: string;
+ icon?: React.ReactNode;
+}
+
+export interface ActionConfig {
+ label: string;
+ href?: string;
+ onClick?: () => void;
+ component?: React.ReactNode;
+}
+
+export interface SplashScreenProps {
+ title: string;
+ description: string;
+ image?: {
+ src: string;
+ alt: string;
+ width: number;
+ height: number;
+ };
+ videoSrc?: string;
+ valuePropositions?: ValueProposition[];
+ primaryAction?: ActionConfig;
+ secondaryAction?: ActionConfig;
+ gettingStarted?: string | React.ReactNode;
+ className?: string;
+}
+
+interface VideoPlayerProps {
+ videoSrc: string;
+}
+
+function VideoPlayer({ videoSrc }: VideoPlayerProps) {
+ const [hasError, setHasError] = useState(false);
+ const [isLoaded, setIsLoaded] = useState(false);
+
+ return (
+ <div
+ className={cn(
+ "my-6 w-full max-w-3xl overflow-hidden rounded-lg border border-border",
+ {
+ hidden: !isLoaded || hasError,
+ },
+ )}
+ >
+ <video
+ src={videoSrc}
+ controls
+ autoPlay
+ muted
+ loop
+ controlsList="nodownload"
+ className="w-full"
+ onError={() => setHasError(true)}
+ onLoadedData={() => setIsLoaded(true)}
+ />
+ </div>
+ );
+}
+
+export function SplashScreen({
+ title,
+ description,
+ image,
+ videoSrc,
+ valuePropositions = [],
+ primaryAction,
+ secondaryAction,
+ gettingStarted,
+ className,
+}: SplashScreenProps) {
+ return (
+ <div
+ className={cn(
+ "mx-auto flex max-w-4xl flex-col items-center p-8",
+ className,
+ )}
+ >
+ <div className="mb-6 text-center">
+ <h2 className="mb-2 text-2xl font-bold">{title}</h2>
+ <p className="text-muted-foreground">{description}</p>
+ </div>
+
+ <div className="mb-8 flex w-full flex-wrap justify-center gap-4">
+ {primaryAction &&
+ (primaryAction.component || (
+ <ActionButton
+ size="lg"
+ onClick={primaryAction.onClick}
+ href={primaryAction.href}
+ >
+ {primaryAction.label}
+ </ActionButton>
+ ))}
+
+ {secondaryAction &&
+ (secondaryAction.component || (
+ <ActionButton
+ variant="outline"
+ size="lg"
+ onClick={secondaryAction.onClick}
+ href={secondaryAction.href}
+ >
+ {secondaryAction.label}
+ </ActionButton>
+ ))}
+ </div>
+
+ {gettingStarted && (
+ <Alert className="w-full max-w-3xl">
+ <InfoIcon className="mr-2 h-4 w-4" />
+ <AlertTitle>Getting Started</AlertTitle>
+ <AlertDescription>{gettingStarted}</AlertDescription>
+ </Alert>
+ )}
+
+ {videoSrc && <VideoPlayer videoSrc={videoSrc} />}
+
+ {!videoSrc && image && (
+ <div className="my-6 w-full max-w-3xl">
+ <Image
+ src={image.src}
+ alt={image.alt}
+ width={image.width}
+ height={image.height}
+ className="rounded-md"
+ />
+ </div>
+ )}
+
+ {valuePropositions.length > 0 && (
+ <div className="my-6 grid w-full max-w-3xl grid-cols-1 gap-4 md:grid-cols-2">
+ {valuePropositions.map((prop, index) => (
+ <Alert key={index}>
+ {prop.icon}
+ <AlertTitle>{prop.title}</AlertTitle>
+ <AlertDescription>{prop.description}</AlertDescription>
+ </Alert>
+ ))}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/web/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx b/web/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx
index ecc87e18f1..9d02cd965b 100644
--- a/web/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx
+++ b/web/src/ee/features/annotation-queues/components/CreateOrEditAnnotationQueueButton.tsx
@@ -1,4 +1,4 @@
-import { Button } from "@/src/components/ui/button";
+import { Button, type ButtonProps } from "@/src/components/ui/button";
import React, { useEffect, useState } from "react";
import {
Dialog,
@@ -44,10 +44,12 @@ export const CreateOrEditAnnotationQueueButton = ({
projectId,
queueId,
variant = "secondary",
+ size,
}: {
projectId: string;
queueId?: string;
variant?: "secondary" | "ghost";
+ size?: ButtonProps["size"];
}) => {
const [isOpen, setIsOpen] = useState(false);
const hasAccess = useHasProjectAccess({
@@ -168,6 +170,7 @@ export const CreateOrEditAnnotationQueueButton = ({
hasEntitlement={hasEntitlement}
limitValue={queueCountData.data}
limit={queueLimit}
+ size={size}
>
<span className="ml-1 text-sm font-normal">
{queueId ? "Edit" : "New queue"}
diff --git a/web/src/ee/features/annotation-queues/pages/AnnotationQueues.tsx b/web/src/ee/features/annotation-queues/pages/AnnotationQueues.tsx
index 6f9f3767ac..fdb1438a0c 100644
--- a/web/src/ee/features/annotation-queues/pages/AnnotationQueues.tsx
+++ b/web/src/ee/features/annotation-queues/pages/AnnotationQueues.tsx
@@ -4,6 +4,8 @@ import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAcces
import { useHasEntitlement } from "@/src/features/entitlements/hooks";
import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";
import Page from "@/src/components/layouts/page";
+import { AnnotationQueuesOnboarding } from "@/src/components/onboarding/AnnotationQueuesOnboarding";
+import { api } from "@/src/utils/api";
export default function AnnotationQueues() {
const router = useRouter();
@@ -13,6 +15,23 @@ export default function AnnotationQueues() {
scope: "annotationQueues:read",
});
const hasEntitlement = useHasEntitlement("annotation-queues");
+
+ // Check if the user has any annotation queues
+ const { data: hasAnyQueue, isLoading } = api.annotationQueues.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ refetchInterval: 10_000,
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnyQueue;
+
if (!hasAccess || !hasEntitlement) return <SupportOrUpgradePage />;
return (
@@ -25,8 +44,14 @@ export default function AnnotationQueues() {
href: "https://langfuse.com/docs/scores/annotation",
},
}}
+ scrollable={showOnboarding}
>
- <AnnotationQueuesTable projectId={projectId} />
+ {/* Show onboarding screen if user has no annotation queues */}
+ {showOnboarding ? (
+ <AnnotationQueuesOnboarding projectId={projectId} />
+ ) : (
+ <AnnotationQueuesTable projectId={projectId} />
+ )}
</Page>
);
}
diff --git a/web/src/ee/features/annotation-queues/server/annotationQueues.ts b/web/src/ee/features/annotation-queues/server/annotationQueues.ts
index 81abd1f0a3..cdfc4f9914 100644
--- a/web/src/ee/features/annotation-queues/server/annotationQueues.ts
+++ b/web/src/ee/features/annotation-queues/server/annotationQueues.ts
@@ -19,6 +19,35 @@ import { TRPCError } from "@trpc/server";
import { z } from "zod";
export const queueRouter = createTRPCRouter({
+ hasAny: protectedProjectProcedure
+ .input(
+ z.object({
+ projectId: z.string(),
+ }),
+ )
+ .query(async ({ input, ctx }) => {
+ throwIfNoEntitlement({
+ entitlement: "annotation-queues",
+ projectId: input.projectId,
+ sessionUser: ctx.session.user,
+ });
+
+ throwIfNoProjectAccess({
+ session: ctx.session,
+ projectId: input.projectId,
+ scope: "annotationQueues:read",
+ });
+
+ const queue = await ctx.prisma.annotationQueue.findFirst({
+ where: {
+ projectId: input.projectId,
+ },
+ select: { id: true },
+ take: 1,
+ });
+
+ return queue !== null;
+ }),
all: protectedProjectProcedure
.input(
z.object({
diff --git a/web/src/ee/features/billing/components/SupportOrUpgradePage.tsx b/web/src/ee/features/billing/components/SupportOrUpgradePage.tsx
index 901d332731..edb5a7660b 100644
--- a/web/src/ee/features/billing/components/SupportOrUpgradePage.tsx
+++ b/web/src/ee/features/billing/components/SupportOrUpgradePage.tsx
@@ -1,9 +1,22 @@
-// TODO: replace placeholder div with actual component
+import { AlertCircle } from "lucide-react";
+import { Alert, AlertTitle, AlertDescription } from "@/src/components/ui/alert";
+
export const SupportOrUpgradePage = () => {
return (
- <div>
- You have no access to this feature. Check with your system administrator
- to get elevated access or upgrade your plan.
+ <div className="flex h-full w-full items-center justify-center p-6">
+ <div className="w-full max-w-md">
+ <Alert>
+ <AlertCircle className="h-4 w-4" />
+ <AlertTitle>Access Restricted</AlertTitle>
+ <AlertDescription>
+ <p className="mb-2">This feature requires additional permissions</p>
+ <p>
+ Contact your system/project administrator for access or upgrade
+ your plan. Need help? Reach out to support.
+ </p>
+ </AlertDescription>
+ </Alert>
+ </div>
</div>
);
};
diff --git a/web/src/ee/features/evals/pages/evaluators.tsx b/web/src/ee/features/evals/pages/evaluators.tsx
index 1fadda5378..59823a96e3 100644
--- a/web/src/ee/features/evals/pages/evaluators.tsx
+++ b/web/src/ee/features/evals/pages/evaluators.tsx
@@ -12,27 +12,22 @@ import {
} from "@/src/components/ui/tabs-bar";
import { ActionButton } from "@/src/components/ActionButton";
import { api } from "@/src/utils/api";
-import { useEntitlementLimit } from "@/src/features/entitlements/hooks";
+import {
+ useEntitlementLimit,
+ useHasEntitlement,
+} from "@/src/features/entitlements/hooks";
+import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/SupportOrUpgradePage";
+import { EvaluatorsOnboarding } from "@/src/components/onboarding/EvaluatorsOnboarding";
export default function EvaluatorsPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
const capture = usePostHogClientCapture();
- // only fetched first page to get count of active evaluators
- // ok as this includes the first 50 active evaluators
- const evaluatorsFirstPage = api.evals.allConfigs.useQuery({
- projectId,
- page: 0,
- limit: 50,
- });
- const evaluatorCountFirstPage = evaluatorsFirstPage.data?.configs.filter(
- (e) => e.status === "ACTIVE",
- ).length;
-
const evaluatorLimit = useEntitlementLimit(
"model-based-evaluations-count-evaluators",
);
+ const hasEntitlement = useHasEntitlement("model-based-evaluations");
const hasWriteAccess = useHasProjectAccess({
projectId,
scope: "evalJob:CUD",
@@ -43,8 +38,45 @@ export default function EvaluatorsPage() {
scope: "evalJob:read",
});
- if (!hasReadAccess) {
- return null;
+ // Fetch counts of evaluator configs and templates
+ const countsQuery = api.evals.counts.useQuery(
+ {
+ projectId,
+ },
+ {
+ enabled: !!projectId && hasEntitlement,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
+
+ const showOnboarding =
+ countsQuery.data?.configCount === 0 &&
+ countsQuery.data?.templateCount === 0;
+
+ if (!hasReadAccess || !hasEntitlement) {
+ return <SupportOrUpgradePage />;
+ }
+
+ if (showOnboarding) {
+ return (
+ <Page
+ headerProps={{
+ title: "Evaluators",
+ help: {
+ description:
+ "Use LLM-as-a-judge evaluators as practical addition to human annotation. Configure an evaluation prompt and a model as judge to evaluate incoming traces.",
+ href: "https://langfuse.com/docs/scores/model-based-evals",
+ },
+ }}
+ scrollable
+ >
+ <EvaluatorsOnboarding projectId={projectId} />
+ </Page>
+ );
}
return (
@@ -78,7 +110,7 @@ export default function EvaluatorsPage() {
variant="outline"
onClick={() => capture("eval_config:new_form_open")}
href={`/project/${projectId}/evals/new`}
- limitValue={evaluatorCountFirstPage ?? 0}
+ limitValue={countsQuery.data?.configCount ?? 0}
limit={evaluatorLimit}
>
New evaluator
diff --git a/web/src/ee/features/evals/server/router.ts b/web/src/ee/features/evals/server/router.ts
index 358221c419..fc33c0344d 100644
--- a/web/src/ee/features/evals/server/router.ts
+++ b/web/src/ee/features/evals/server/router.ts
@@ -134,6 +134,40 @@ export const evalRouter = createTRPCRouter({
});
return env.LANGFUSE_MAX_HISTORIC_EVAL_CREATION_LIMIT;
}),
+ counts: protectedProjectProcedure
+ .input(z.object({ projectId: z.string() }))
+ .query(async ({ input, ctx }) => {
+ throwIfNoEntitlement({
+ entitlement: "model-based-evaluations",
+ projectId: input.projectId,
+ sessionUser: ctx.session.user,
+ });
+
+ throwIfNoProjectAccess({
+ session: ctx.session,
+ projectId: input.projectId,
+ scope: "evalJob:read",
+ });
+
+ const [configCount, templateCount] = await Promise.all([
+ ctx.prisma.jobConfiguration.count({
+ where: {
+ projectId: input.projectId,
+ jobType: "EVAL",
+ },
+ }),
+ ctx.prisma.evalTemplate.count({
+ where: {
+ projectId: input.projectId,
+ },
+ }),
+ ]);
+
+ return {
+ configCount,
+ templateCount,
+ };
+ }),
allConfigs: protectedProjectProcedure
.input(
z.object({
diff --git a/web/src/features/datasets/components/DatasetActionButton.tsx b/web/src/features/datasets/components/DatasetActionButton.tsx
index a37c4ef66a..f8fa66588c 100644
--- a/web/src/features/datasets/components/DatasetActionButton.tsx
+++ b/web/src/features/datasets/components/DatasetActionButton.tsx
@@ -1,4 +1,4 @@
-import { Button } from "@/src/components/ui/button";
+import { Button, type ButtonProps } from "@/src/components/ui/button";
import { Edit, LockIcon, PlusIcon, Trash } from "lucide-react";
import {
Dialog,
@@ -18,7 +18,8 @@ interface BaseDatasetButtonProps {
mode: "create" | "update" | "delete";
projectId: string;
className?: string;
- onFormSuccess?: () => void;
+ size?: ButtonProps["size"];
+ variant?: ButtonProps["variant"];
}
interface CreateDatasetButtonProps extends BaseDatasetButtonProps {
@@ -59,8 +60,8 @@ export const DatasetActionButton = (props: DatasetActionButtonProps) => {
{props.mode === "update" ? (
props.icon ? (
<Button
- variant="outline"
- size={"icon"}
+ variant={props.variant || "outline"}
+ size={props.size || "icon"}
className={props.className}
disabled={!hasAccess}
onClick={() =>
@@ -73,7 +74,9 @@ export const DatasetActionButton = (props: DatasetActionButtonProps) => {
</Button>
) : (
<Button
- variant="ghost"
+ variant={props.variant || "ghost"}
+ size={props.size || "icon"}
+ className={props.className}
onClick={() => {
setOpen(true);
capture("datasets:update_form_open", {
@@ -91,7 +94,9 @@ export const DatasetActionButton = (props: DatasetActionButtonProps) => {
)
) : props.mode === "delete" ? (
<Button
- variant="ghost"
+ variant={props.variant || "ghost"}
+ size={props.size}
+ className={props.className}
onClick={() => {
setOpen(true);
capture("datasets:delete_form_open", {
@@ -104,10 +109,11 @@ export const DatasetActionButton = (props: DatasetActionButtonProps) => {
</Button>
) : (
<Button
+ size={props.size}
className={props.className}
disabled={!hasAccess}
onClick={() => capture("datasets:new_form_open")}
- variant="secondary"
+ variant={props.variant || "secondary"}
>
{hasAccess ? (
<PlusIcon className="-ml-0.5 mr-1.5 h-4 w-4" aria-hidden="true" />
diff --git a/web/src/features/datasets/server/dataset-router.ts b/web/src/features/datasets/server/dataset-router.ts
index 4448bc114c..dfac4cae52 100644
--- a/web/src/features/datasets/server/dataset-router.ts
+++ b/web/src/features/datasets/server/dataset-router.ts
@@ -31,6 +31,23 @@ const formatDatasetItemData = (data: string | null | undefined) => {
};
export const datasetRouter = createTRPCRouter({
+ hasAny: protectedProjectProcedure
+ .input(
+ z.object({
+ projectId: z.string(),
+ }),
+ )
+ .query(async ({ input, ctx }) => {
+ const dataset = await ctx.prisma.dataset.findFirst({
+ where: {
+ projectId: input.projectId,
+ },
+ select: { id: true },
+ take: 1,
+ });
+
+ return dataset !== null;
+ }),
allDatasetMeta: protectedProjectProcedure
.input(z.object({ projectId: z.string() }))
.query(async ({ input, ctx }) => {
diff --git a/web/src/features/prompts/server/routers/promptRouter.ts b/web/src/features/prompts/server/routers/promptRouter.ts
index e59e6d303f..4dea7e6b2b 100644
--- a/web/src/features/prompts/server/routers/promptRouter.ts
+++ b/web/src/features/prompts/server/routers/promptRouter.ts
@@ -36,6 +36,29 @@ const PromptFilterOptions = z.object({
});
export const promptRouter = createTRPCRouter({
+ hasAny: protectedProjectProcedure
+ .input(
+ z.object({
+ projectId: z.string(),
+ }),
+ )
+ .query(async ({ input, ctx }) => {
+ throwIfNoProjectAccess({
+ session: ctx.session,
+ projectId: input.projectId,
+ scope: "prompts:read",
+ });
+
+ const prompt = await ctx.prisma.prompt.findFirst({
+ where: {
+ projectId: input.projectId,
+ },
+ select: { id: true },
+ take: 1,
+ });
+
+ return prompt !== null;
+ }),
all: protectedProjectProcedure
.input(PromptFilterOptions)
.query(async ({ input, ctx }) => {
diff --git a/web/src/pages/project/[projectId]/datasets.tsx b/web/src/pages/project/[projectId]/datasets.tsx
index da40bf688f..c742b4c87c 100644
--- a/web/src/pages/project/[projectId]/datasets.tsx
+++ b/web/src/pages/project/[projectId]/datasets.tsx
@@ -1,11 +1,28 @@
import { useRouter } from "next/router";
import { DatasetsTable } from "@/src/features/datasets/components/DatasetsTable";
import Page from "@/src/components/layouts/page";
+import { api } from "@/src/utils/api";
+import { DatasetsOnboarding } from "@/src/components/onboarding/DatasetsOnboarding";
-export default function Traces() {
+export default function Datasets() {
const router = useRouter();
const projectId = router.query.projectId as string;
+ // Check if the project has any datasets
+ const { data: hasAnyDataset, isLoading } = api.datasets.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnyDataset;
+
return (
<Page
headerProps={{
@@ -16,8 +33,14 @@ export default function Traces() {
href: "https://langfuse.com/docs/datasets",
},
}}
+ scrollable={showOnboarding}
>
- <DatasetsTable projectId={projectId} />
+ {/* Show onboarding screen if project has no datasets */}
+ {showOnboarding ? (
+ <DatasetsOnboarding projectId={projectId} />
+ ) : (
+ <DatasetsTable projectId={projectId} />
+ )}
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/observations.tsx b/web/src/pages/project/[projectId]/observations.tsx
index 8efb0f3fb8..d4fb7c0e56 100644
--- a/web/src/pages/project/[projectId]/observations.tsx
+++ b/web/src/pages/project/[projectId]/observations.tsx
@@ -1,11 +1,29 @@
import { useRouter } from "next/router";
import ObservationsTable from "@/src/components/table/use-cases/observations";
import Page from "@/src/components/layouts/page";
+import { api } from "@/src/utils/api";
+import { TracesOnboarding } from "@/src/components/onboarding/TracesOnboarding";
export default function Generations() {
const router = useRouter();
const projectId = router.query.projectId as string;
+ // Check if the user has any traces
+ const { data: hasAnyTrace, isLoading } = api.traces.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ refetchInterval: 10_000,
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnyTrace;
+
return (
<Page
headerProps={{
@@ -16,8 +34,14 @@ export default function Generations() {
href: "https://langfuse.com/docs/tracing",
},
}}
+ scrollable={showOnboarding}
>
- <ObservationsTable projectId={projectId} />
+ {/* Show onboarding screen if user has no traces */}
+ {showOnboarding ? (
+ <TracesOnboarding projectId={projectId} />
+ ) : (
+ <ObservationsTable projectId={projectId} />
+ )}
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/prompts/index.tsx b/web/src/pages/project/[projectId]/prompts/index.tsx
index a1aa1959b3..6a3d750e7a 100644
--- a/web/src/pages/project/[projectId]/prompts/index.tsx
+++ b/web/src/pages/project/[projectId]/prompts/index.tsx
@@ -1,7 +1,28 @@
+import { useRouter } from "next/router";
import Page from "@/src/components/layouts/page";
import { PromptTable } from "@/src/features/prompts/components/prompts-table";
+import { api } from "@/src/utils/api";
+import { PromptsOnboarding } from "@/src/components/onboarding/PromptsOnboarding";
export default function Prompts() {
+ const router = useRouter();
+ const projectId = router.query.projectId as string;
+
+ // Check if the project has any prompts
+ const { data: hasAnyPrompt, isLoading } = api.prompts.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnyPrompt;
+
return (
<Page
headerProps={{
@@ -12,8 +33,14 @@ export default function Prompts() {
href: "https://langfuse.com/docs/prompts",
},
}}
+ scrollable={showOnboarding}
>
- <PromptTable />
+ {/* Show onboarding screen if project has no prompts */}
+ {showOnboarding ? (
+ <PromptsOnboarding projectId={projectId} />
+ ) : (
+ <PromptTable />
+ )}
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/scores.tsx b/web/src/pages/project/[projectId]/scores.tsx
index f30456f949..e046d37e42 100644
--- a/web/src/pages/project/[projectId]/scores.tsx
+++ b/web/src/pages/project/[projectId]/scores.tsx
@@ -1,11 +1,29 @@
import { useRouter } from "next/router";
import ScoresTable from "@/src/components/table/use-cases/scores";
import Page from "@/src/components/layouts/page";
+import { api } from "@/src/utils/api";
+import { ScoresOnboarding } from "@/src/components/onboarding/ScoresOnboarding";
export default function ScoresPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
+ // Check if the user has any scores
+ const { data: hasAnyScore, isLoading } = api.scores.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ refetchInterval: 10_000,
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnyScore;
+
return (
<Page
headerProps={{
@@ -16,8 +34,14 @@ export default function ScoresPage() {
href: "https://langfuse.com/docs/scores",
},
}}
+ scrollable={showOnboarding}
>
- <ScoresTable projectId={projectId} />
+ {/* Show onboarding screen if user has no scores */}
+ {showOnboarding ? (
+ <ScoresOnboarding />
+ ) : (
+ <ScoresTable projectId={projectId} />
+ )}
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/sessions.tsx b/web/src/pages/project/[projectId]/sessions.tsx
index 65ebacf987..9e1c2ee3c5 100644
--- a/web/src/pages/project/[projectId]/sessions.tsx
+++ b/web/src/pages/project/[projectId]/sessions.tsx
@@ -1,11 +1,28 @@
import { useRouter } from "next/router";
import SessionsTable from "@/src/components/table/use-cases/sessions";
import Page from "@/src/components/layouts/page";
+import { SessionsOnboarding } from "@/src/components/onboarding/SessionsOnboarding";
+import { api } from "@/src/utils/api";
export default function Sessions() {
const router = useRouter();
const projectId = router.query.projectId as string;
+ const { data: hasAnySession, isLoading } = api.sessions.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ refetchInterval: 10_000,
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnySession;
+
return (
<Page
headerProps={{
@@ -16,8 +33,14 @@ export default function Sessions() {
href: "https://langfuse.com/docs/sessions",
},
}}
+ scrollable={showOnboarding}
>
- <SessionsTable projectId={projectId} />
+ {/* Show onboarding screen if user has no sessions */}
+ {showOnboarding ? (
+ <SessionsOnboarding />
+ ) : (
+ <SessionsTable projectId={projectId} />
+ )}
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/traces.tsx b/web/src/pages/project/[projectId]/traces.tsx
index 3816d8695c..476d21f3da 100644
--- a/web/src/pages/project/[projectId]/traces.tsx
+++ b/web/src/pages/project/[projectId]/traces.tsx
@@ -1,12 +1,29 @@
import { useRouter } from "next/router";
import TracesTable from "@/src/components/table/use-cases/traces";
-import SetupTracingButton from "@/src/features/setup/components/SetupTracingButton";
import Page from "@/src/components/layouts/page";
+import { api } from "@/src/utils/api";
+import { TracesOnboarding } from "@/src/components/onboarding/TracesOnboarding";
export default function Traces() {
const router = useRouter();
const projectId = router.query.projectId as string;
+ // Check if the user has any traces
+ const { data: hasAnyTrace, isLoading } = api.traces.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ refetchInterval: 10_000,
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnyTrace;
+
return (
<Page
headerProps={{
@@ -16,10 +33,15 @@ export default function Traces() {
"A trace represents a single function/api invocation. Traces contain observations. See docs to learn more.",
href: "https://langfuse.com/docs/tracing",
},
- actionButtonsRight: <SetupTracingButton />,
}}
+ scrollable={showOnboarding}
>
- <TracesTable projectId={projectId} />
+ {/* Show onboarding screen if user has no traces */}
+ {showOnboarding ? (
+ <TracesOnboarding projectId={projectId} />
+ ) : (
+ <TracesTable projectId={projectId} />
+ )}
</Page>
);
}
diff --git a/web/src/pages/project/[projectId]/users.tsx b/web/src/pages/project/[projectId]/users.tsx
index e55d0d117a..ab658d4cdc 100644
--- a/web/src/pages/project/[projectId]/users.tsx
+++ b/web/src/pages/project/[projectId]/users.tsx
@@ -23,6 +23,7 @@ import { joinTableCoreAndMetrics } from "@/src/components/table/utils/joinTableC
import { useTableDateRange } from "@/src/hooks/useTableDateRange";
import { useDebounce } from "@/src/hooks/useDebounce";
import Page from "@/src/components/layouts/page";
+import { UsersOnboarding } from "@/src/components/onboarding/UsersOnboarding";
type RowData = {
userId: string;
@@ -37,6 +38,44 @@ export default function UsersPage() {
const router = useRouter();
const projectId = router.query.projectId as string;
+ // Check if the user has any users
+ const { data: hasAnyUser, isLoading } = api.users.hasAny.useQuery(
+ { projectId },
+ {
+ enabled: !!projectId,
+ trpc: {
+ context: {
+ skipBatch: true,
+ },
+ },
+ refetchInterval: 10_000,
+ },
+ );
+
+ const showOnboarding = !isLoading && !hasAnyUser;
+
+ return (
+ <Page
+ headerProps={{
+ title: "Users",
+ help: {
+ description:
+ "Attribute data in Langfuse to a user by adding a userId to your traces. See docs to learn more.",
+ href: "https://langfuse.com/docs/user-explorer",
+ },
+ }}
+ scrollable={showOnboarding}
+ >
+ {/* Show onboarding screen if user has no users */}
+ {showOnboarding ? <UsersOnboarding /> : <UsersTable />}
+ </Page>
+ );
+}
+
+const UsersTable = () => {
+ const router = useRouter();
+ const projectId = router.query.projectId as string;
+
const [userFilterState, setUserFilterState] = useQueryFilterState(
[],
"users",
@@ -244,16 +283,7 @@ export default function UsersPage() {
];
return (
- <Page
- headerProps={{
- title: "Users",
- help: {
- description:
- "Attribute data in Langfuse to a user by adding a userId to your traces. See docs to learn more.",
- href: "https://langfuse.com/docs/user-explorer",
- },
- }}
- >
+ <>
<DataTableToolbar
filterColumnDefinition={usersTableCols}
filterState={userFilterState}
@@ -308,6 +338,6 @@ export default function UsersPage() {
state: paginationState,
}}
/>
- </Page>
+ </>
);
-}
+};
diff --git a/web/src/server/api/routers/scores.ts b/web/src/server/api/routers/scores.ts
index 9832cd3ff4..0627b137ab 100644
--- a/web/src/server/api/routers/scores.ts
+++ b/web/src/server/api/routers/scores.ts
@@ -38,6 +38,7 @@ import {
getScoreById,
convertDateToClickhouseDateTime,
searchExistingAnnotationScore,
+ hasAnyScore,
} from "@langfuse/shared/src/server";
import { v4 } from "uuid";
@@ -376,4 +377,13 @@ export const scoresRouter = createTRPCRouter({
dataType: dataType,
}));
}),
+ hasAny: protectedProjectProcedure
+ .input(
+ z.object({
+ projectId: z.string(),
+ }),
+ )
+ .query(async ({ input }) => {
+ return await hasAnyScore(input.projectId);
+ }),
});
diff --git a/web/src/server/api/routers/sessions.ts b/web/src/server/api/routers/sessions.ts
index 2125824772..73800011b3 100644
--- a/web/src/server/api/routers/sessions.ts
+++ b/web/src/server/api/routers/sessions.ts
@@ -30,6 +30,7 @@ import {
getPublicSessionsFilter,
logger,
getSessionsWithMetrics,
+ hasAnySession,
} from "@langfuse/shared/src/server";
import { chunk } from "lodash";
@@ -41,6 +42,15 @@ const SessionFilterOptions = z.object({
});
export const sessionRouter = createTRPCRouter({
+ hasAny: protectedProjectProcedure
+ .input(
+ z.object({
+ projectId: z.string(),
+ }),
+ )
+ .query(async ({ input }) => {
+ return await hasAnySession(input.projectId);
+ }),
all: protectedProjectProcedure
.input(SessionFilterOptions)
.query(async ({ input, ctx }) => {
diff --git a/web/src/server/api/routers/users.ts b/web/src/server/api/routers/users.ts
index b5cffc3383..b3b0fb7ff9 100644
--- a/web/src/server/api/routers/users.ts
+++ b/web/src/server/api/routers/users.ts
@@ -9,6 +9,7 @@ import {
getTotalUserCount,
getTracesGroupedByUsers,
getUserMetrics,
+ hasAnyUser,
} from "@langfuse/shared/src/server";
const UserFilterOptions = z.object({
@@ -25,6 +26,16 @@ const UserAllOptions = UserFilterOptions.extend({
});
export const userRouter = createTRPCRouter({
+ hasAny: protectedProjectProcedure
+ .input(
+ z.object({
+ projectId: z.string(),
+ }),
+ )
+ .query(async ({ input }) => {
+ return await hasAnyUser(input.projectId);
+ }),
+
all: protectedProjectProcedure
.input(UserAllOptions)
.query(async ({ input, ctx }) => {