🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(tracing): tracing setup page with prompt (#13045)
annabellscha3e61ecc84f2f
diff --git a/web/src/components/onboarding/TracesOnboarding.tsx b/web/src/components/onboarding/TracesOnboarding.tsxindex 94ac18e315..bb586008c7 100644--- a/web/src/components/onboarding/TracesOnboarding.tsx+++ b/web/src/components/onboarding/TracesOnboarding.tsx@@ -1,6 +1,5 @@import React from "react";-import { SplashScreen } from "@/src/components/ui/splash-screen";-import { TracingSetup } from "@/src/pages/project/[projectId]/traces/setup";+import { TracesSetupOnboardingCard } from "@/src/features/setup/components/TracesSetupOnboardingCard";interface TracesOnboardingProps {projectId: string;@@ -8,15 +7,8 @@ interface TracesOnboardingProps {export function TracesOnboarding({ projectId }: TracesOnboardingProps) {return (- <SplashScreen- title="You don't have any traces yet"- description="Traces show you how your LLM calls behave in your application: what they cost, how they perform, and where things go wrong. It's the first step towards improving the behavior of your app."- videoSrc="https://static.langfuse.com/prod-assets/onboarding/tracing-overview-v1.mp4"- >- <div className="mt-8">- <h3 className="mb-8 text-2xl font-semibold">Get started</h3>- <TracingSetup projectId={projectId} hasTracingConfigured={false} />- </div>- </SplashScreen>+ <div className="space-y-10">+ <TracesSetupOnboardingCard projectId={projectId} />+ </div>);}diff --git a/web/src/components/ui/splash-screen.tsx b/web/src/components/ui/splash-screen.tsxindex 6e6eb28606..e51e6673e8 100644--- a/web/src/components/ui/splash-screen.tsx+++ b/web/src/components/ui/splash-screen.tsx@@ -4,6 +4,7 @@ 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";+import { StatusBadge } from "@/src/components/layouts/status-badge";export interface ValueProposition {title: string;@@ -18,9 +19,17 @@ export interface ActionConfig {component?: React.ReactNode;}+export interface Step {+ title: string;+ description?: string;+ badge?: React.ReactNode;+ content?: React.ReactNode;+}+export interface SplashScreenProps {title: string;description: string;+ waitingFor?: string;image?: {src: string;alt: string;@@ -28,19 +37,17 @@ export interface SplashScreenProps {height: number;};videoSrc?: string;+ steps?: Step[];valuePropositions?: ValueProposition[];primaryAction?: ActionConfig;secondaryAction?: ActionConfig;gettingStarted?: string | React.ReactNode;children?: React.ReactNode;- className?: string;-}--interface VideoPlayerProps {- videoSrc: string;+ /** Where to render the video. Defaults to "top" (after header, before content) */+ videoPosition?: "top" | "bottom";}-function VideoPlayer({ videoSrc }: VideoPlayerProps) {+function VideoPlayer({ videoSrc }: { videoSrc: string }) {const [hasError, setHasError] = useState(false);const [isLoaded, setIsLoaded] = useState(false);@@ -48,9 +55,7 @@ function VideoPlayer({ videoSrc }: VideoPlayerProps) {<divclassName={cn("border-border my-6 w-full max-w-3xl overflow-hidden rounded-lg border",- {- hidden: !isLoaded || hasError,- },+ { hidden: !isLoaded || hasError },)}><video@@ -72,17 +77,46 @@ function VideoPlayer({ videoSrc }: VideoPlayerProps) {export function SplashScreen({title,description,+ waitingFor,image,videoSrc,+ steps,valuePropositions = [],primaryAction,secondaryAction,gettingStarted,children,+ videoPosition = "top",}: SplashScreenProps) {+ const mediaBlock = (+ <>+ {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>+ )}+ </>+ );+return (- <div className={cn("mx-auto flex max-w-4xl flex-col items-center p-8")}>+ <div className="mx-auto flex max-w-4xl flex-col items-center p-8"><div className="mb-6 text-center">+ {waitingFor && (+ <StatusBadge+ type="waiting"+ showText={false}+ className="mb-3 px-3 py-1 text-sm"+ >+ {waitingFor}+ </StatusBadge>+ )}<h2 className="mb-2 text-2xl font-bold">{title}</h2><p className="text-muted-foreground">{description}</p></div>@@ -98,7 +132,6 @@ export function SplashScreen({{primaryAction.label}</ActionButton>))}-{secondaryAction &&(secondaryAction.component || (<ActionButton@@ -120,17 +153,42 @@ export function SplashScreen({</Alert>)}- {videoSrc && <VideoPlayer videoSrc={videoSrc} />}+ {videoPosition === "top" && mediaBlock}- {!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"- />+ {/* Numbered steps */}+ {steps && steps.length > 0 && (+ <div className="w-full max-w-4xl">+ {steps.map((step, index) => (+ <div key={index} className="flex gap-4">+ {/* Left: circle + connecting line */}+ <div className="flex flex-col items-center">+ <div className="bg-foreground text-background flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-sm font-semibold">+ {index + 1}+ </div>+ {index < steps.length - 1 && (+ <div className="bg-border mt-1 w-px flex-1" />+ )}+ </div>+ {/* Right: title + content */}+ <div+ className={cn(+ "min-w-0 flex-1 pt-1",+ index < steps.length - 1 ? "pb-8" : "pb-0",+ )}+ >+ <div className="mb-2 flex items-center gap-3">+ <h3 className="text-xl font-semibold">{step.title}</h3>+ {step.badge}+ </div>+ {step.description && (+ <p className="text-muted-foreground text-sm leading-6">+ {step.description}+ </p>+ )}+ {step.content && <div className="mt-3">{step.content}</div>}+ </div>+ </div>+ ))}</div>)}@@ -147,6 +205,8 @@ export function SplashScreen({))}</div>)}++ {videoPosition === "bottom" && mediaBlock}</div>);}diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.tsindex c79afaf6d2..9eac9387c9 100644--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts@@ -169,7 +169,12 @@ export const events = {"modal_open","create_new_button_click",],- onboarding: ["code_example_tab_switch", "tracing_check_active"],+ onboarding: [+ "code_example_tab_switch",+ "tracing_check_active",+ "tracing_agent_prompt_copy_clicked",+ "tracing_manual_docs_link_clicked",+ ],user_settings: ["theme_changed"],project_settings: ["project_delete",diff --git a/web/src/features/setup/components/TracesSetupOnboardingCard.tsx b/web/src/features/setup/components/TracesSetupOnboardingCard.tsxnew file mode 100644index 0000000000..d1c6f7ebe5--- /dev/null+++ b/web/src/features/setup/components/TracesSetupOnboardingCard.tsx@@ -0,0 +1,182 @@+import { ActionButton } from "@/src/components/ActionButton";+import { Badge } from "@/src/components/ui/badge";+import { Button } from "@/src/components/ui/button";+import { SplashScreen } from "@/src/components/ui/splash-screen";+import { copyTextToClipboard } from "@/src/utils/clipboard";+import { ApiKeyRender } from "@/src/features/public-api/components/CreateApiKeyButton";+import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";+import { api } from "@/src/utils/api";+import { type RouterOutput } from "@/src/utils/types";+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";+import { Check, Copy, LockIcon, Sparkles } from "lucide-react";+import Link from "next/link";+import { useState } from "react";+import { toast } from "sonner";++const SKILLS_INSTALL_COMMAND =+ "Install the Langfuse AI skill from github.com/langfuse/skills and use it to add tracing to this application with Langfuse following best practices.";+const MANUAL_TRACING_DOCS_URL =+ "https://langfuse.com/docs/observability/get-started";++function CopyableSnippet({+ value,+ onCopy,+}: {+ value: string;+ onCopy?: () => void;+}) {+ const [copied, setCopied] = useState(false);++ const handleCopy = async () => {+ try {+ await copyTextToClipboard(value);+ onCopy?.();+ setCopied(true);+ setTimeout(() => setCopied(false), 1000);+ } catch {+ toast.error("Failed to copy to clipboard");+ }+ };++ return (+ <div className="bg-muted/50 flex items-center gap-4 rounded-2xl border p-5 shadow-xs">+ <code className="min-w-0 flex-1 font-mono text-xs leading-6 break-words whitespace-pre-wrap sm:text-sm">+ {value}+ </code>+ <Button+ variant="outline"+ size="sm"+ className="shrink-0 gap-2"+ onClick={() => void handleCopy()}+ >+ {copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}+ {copied ? "Copied" : "Copy prompt"}+ </Button>+ </div>+ );+}++export function TracesSetupOnboardingCard({+ projectId,+}: {+ projectId: string;+}) {+ const capture = usePostHogClientCapture();+ const hasApiKeyCreateAccess = useHasProjectAccess({+ projectId,+ scope: "apiKeys:CUD",+ });+ const [apiKeys, setApiKeys] = useState<+ RouterOutput["projectApiKeys"]["create"] | null+ >(null);+ const utils = api.useUtils();+ const mutCreateApiKey = api.projectApiKeys.create.useMutation({+ onSuccess: (data) => {+ utils.projectApiKeys.invalidate();+ setApiKeys(data);+ },+ });++ const createApiKey = async () => {+ try {+ await mutCreateApiKey.mutateAsync({ projectId });+ } catch (error) {+ console.error("Error creating API key:", error);+ toast.error("Failed to create API key");+ }+ };++ return (+ <SplashScreen+ waitingFor="Waiting for first trace"+ title="Time to log your first trace, it only takes a minute"+ description="Get your API keys first, then ask your coding agent to add observability with Langfuse to your application."+ videoSrc="https://static.langfuse.com/prod-assets/onboarding/traces-overview-v1.mp4"+ videoPosition="bottom"+ steps={[+ {+ title: "Create API keys",+ description:+ "Your application needs API keys to send traces to Langfuse.",+ content: apiKeys ? (+ <ApiKeyRender+ generatedKeys={apiKeys}+ scope="project"+ className="mt-1"+ />+ ) : (+ <div className="flex flex-wrap gap-2">+ {hasApiKeyCreateAccess ? (+ <Button+ onClick={createApiKey}+ loading={mutCreateApiKey.isPending}+ className="self-start"+ >+ Create new API key+ </Button>+ ) : (+ <Button disabled className="self-start">+ <LockIcon+ className="mr-2 -ml-0.5 h-4 w-4"+ aria-hidden="true"+ />+ Create new API key+ </Button>+ )}+ <ActionButton+ href={`/project/${projectId}/settings/api-keys`}+ variant="secondary"+ >+ Manage API keys+ </ActionButton>+ </div>+ ),+ },+ {+ title: "Add tracing with your coding agent",+ badge: (+ <Badge variant="tertiary" className="gap-1">+ <Sparkles className="h-3 w-3" />+ Recommended+ </Badge>+ ),+ description:+ "Paste this prompt into Claude, Cursor, Copilot, or another coding agent.",+ content: (+ <>+ <CopyableSnippet+ value={SKILLS_INSTALL_COMMAND}+ onCopy={() =>+ capture("onboarding:tracing_agent_prompt_copy_clicked", {+ projectId,+ })+ }+ />+ <div className="mt-3">+ <Link+ href={MANUAL_TRACING_DOCS_URL}+ target="_blank"+ rel="noopener noreferrer"+ className="text-primary inline-flex text-sm underline underline-offset-4 hover:no-underline"+ onClick={() =>+ capture("onboarding:tracing_manual_docs_link_clicked", {+ href: MANUAL_TRACING_DOCS_URL,+ projectId,+ })+ }+ >+ or follow our docs to set up tracing manually+ </Link>+ </div>+ </>+ ),+ },+ {+ title: "Run your app — traces will appear here",+ description:+ "Once your app makes an LLM call, traces show up within seconds.",+ },+ ]}+ />+ );+}