Skip to content

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

feat: add dismissable docs nudges trace peek view (#10880)

Lotte Verheydenbc29cabe8713
diff --git a/web/src/components/ActionButton.tsx b/web/src/components/ActionButton.tsx
index 1b7178f406..d1786335e1 100644
--- a/web/src/components/ActionButton.tsx
+++ b/web/src/components/ActionButton.tsx
@@ -8,6 +8,7 @@ import {
} from "@/src/components/ui/hover-card";
import { HoverCardPortal } from "@radix-ui/react-hover-card";
import Link from "next/link";
+import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
const BUTTON_STATE_MESSAGES = {
limitReached: (current: number, max: number) =>
@@ -27,6 +28,8 @@ interface ActionButtonProps extends ButtonProps {
children: React.ReactNode;
className?: string;
href?: string;
+ trackingEventName?: Parameters<ReturnType<typeof usePostHogClientCapture>>[0];
+ trackingProps?: Record<string, unknown>;
}
export const ActionButton = React.forwardRef<
@@ -44,10 +47,13 @@ export const ActionButton = React.forwardRef<
icon,
className,
href,
+ trackingEventName,
+ trackingProps,
...buttonProps
},
ref,
) {
+ const capture = usePostHogClientCapture();
const hasReachedLimit =
typeof limit === "number" &&
limitValue !== undefined &&
@@ -70,6 +76,13 @@ export const ActionButton = React.forwardRef<
const message = getMessage();
+ // Handle click tracking for external links
+ const handleLinkClick = () => {
+ if (trackingEventName && href && isExternalUrl(href)) {
+ capture(trackingEventName, trackingProps ?? null);
+ }
+ };
+
const btnContent = (
<ButtonContent
ref={ref}
@@ -82,6 +95,7 @@ export const ActionButton = React.forwardRef<
className={className}
buttonProps={buttonProps}
href={href}
+ onLinkClick={handleLinkClick}
>
{children}
</ButtonContent>
@@ -126,6 +140,7 @@ const ButtonContent = React.forwardRef<
buttonProps: Omit<ButtonProps, "disabled" | "loading" | "className">;
children: React.ReactNode;
href?: string;
+ onLinkClick?: () => void;
}
>(function ButtonContent(
{
@@ -139,6 +154,7 @@ const ButtonContent = React.forwardRef<
buttonProps,
children,
href,
+ onLinkClick,
},
ref,
) {
@@ -174,6 +190,7 @@ const ButtonContent = React.forwardRef<
href={href}
target={isExternal ? "_blank" : undefined}
rel={isExternal ? "noopener noreferrer" : undefined}
+ onClick={onLinkClick}
>
{content}
</Link>
diff --git a/web/src/components/trace/IOPreview.tsx b/web/src/components/trace/IOPreview.tsx
index 38565c7bd8..2b44744229 100644
--- a/web/src/components/trace/IOPreview.tsx
+++ b/web/src/components/trace/IOPreview.tsx
@@ -3,6 +3,7 @@ import { type Prisma, deepParseJson } from "@langfuse/shared";
import { cn } from "@/src/utils/tailwind";
import { useEffect, useMemo, useState } from "react";
import { Button } from "@/src/components/ui/button";
+import { ActionButton } from "@/src/components/ActionButton";
import { Fragment } from "react";
import type { z } from "zod/v4";
import type {
@@ -30,9 +31,17 @@ import {
} from "@/src/utils/chatml";
import { ToolCallDefinitionCard } from "@/src/components/trace/ToolCallDefinitionCard";
import { ToolCallInvocationsView } from "@/src/components/trace/ToolCallInvocationsView";
-import { ListChevronsDownUp, ListChevronsUpDown } from "lucide-react";
+import {
+ ListChevronsDownUp,
+ ListChevronsUpDown,
+ BookOpen,
+ X,
+} from "lucide-react";
import { copyTextToClipboard } from "@/src/utils/clipboard";
+const EMPTY_IO_ALERT_ID = "empty-io";
+const STORAGE_KEY = "dismissed-trace-view-notifications";
+
export const IOPreview: React.FC<{
input?: Prisma.JsonValue;
output?: Prisma.JsonValue;
@@ -72,6 +81,8 @@ export const IOPreview: React.FC<{
>("jsonViewPreference", "pretty");
const selectedView = currentView ?? localCurrentView;
const capture = usePostHogClientCapture();
+ const [dismissedTraceViewNotifications, setDismissedTraceViewNotifications] =
+ useLocalStorage<string[]>(STORAGE_KEY, []);
const input = deepParseJson(props.input);
const output = deepParseJson(props.output);
const metadata = deepParseJson(props.metadata);
@@ -202,6 +213,13 @@ export const IOPreview: React.FC<{
const shouldRenderMarkdownSafely =
totalContentSize <= MARKDOWN_RENDER_CHARACTER_LIMIT;
+ const showEmptyState =
+ (input === null || input === undefined) &&
+ (output === null || output === undefined) &&
+ !isLoading &&
+ !hideIfNull &&
+ !dismissedTraceViewNotifications.includes(EMPTY_IO_ALERT_ID);
+
// default I/O
return (
<>
@@ -349,6 +367,48 @@ export const IOPreview: React.FC<{
) : null}
</div>
)}
+ {showEmptyState && (
+ <div className="relative mx-2 flex flex-col items-start gap-2 rounded-lg border border-dashed p-4">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="absolute right-1.5 top-1.5 h-5 w-5 p-0"
+ onClick={() => {
+ capture("notification:dismiss_notification", {
+ notification_id: EMPTY_IO_ALERT_ID,
+ });
+ setDismissedTraceViewNotifications((prev) =>
+ prev.includes(EMPTY_IO_ALERT_ID)
+ ? prev
+ : [...prev, EMPTY_IO_ALERT_ID],
+ );
+ }}
+ title="Dismiss"
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ <div className="flex w-full flex-row items-center gap-2 pr-6">
+ <div className="flex h-8 w-8 items-center justify-center rounded-full bg-accent">
+ <BookOpen className="h-4 w-4 text-muted-foreground" />
+ </div>
+ <h3 className="text-sm font-semibold">
+ Looks like this trace didn&apos;t receive an input or output.
+ </h3>
+ </div>
+ <p className="max-w-sm text-sm text-muted-foreground">
+ Add it in your code to make debugging a lot easier.
+ </p>
+ <ActionButton
+ variant="outline"
+ size="sm"
+ href="https://langfuse.com/faq/all/empty-trace-input-and-output"
+ trackingEventName="notification:click_link"
+ trackingProps={{ notification_id: EMPTY_IO_ALERT_ID }}
+ >
+ View Documentation
+ </ActionButton>
+ </div>
+ )}
</>
);
};
diff --git a/web/src/components/trace/index.tsx b/web/src/components/trace/index.tsx
index a206e1cb9e..2288f12e50 100644
--- a/web/src/components/trace/index.tsx
+++ b/web/src/components/trace/index.tsx
@@ -18,6 +18,8 @@ import {
UnfoldVertical,
PanelLeftClose,
PanelLeftOpen,
+ Info,
+ X,
} from "lucide-react";
import { useCallback, useState, useMemo, useRef, useEffect } from "react";
import { usePanelState } from "./hooks/usePanelState";
@@ -31,6 +33,7 @@ import { Command, CommandInput } from "@/src/components/ui/command";
import { TraceSearchList } from "@/src/components/trace/TraceSearchList";
import { useDebounce } from "@/src/hooks/useDebounce";
import { Button } from "@/src/components/ui/button";
+import { ActionButton } from "@/src/components/ActionButton";
import { cn } from "@/src/utils/tailwind";
import useSessionStorage from "@/src/components/useSessionStorage";
import { JsonExpansionProvider } from "@/src/components/trace/JsonExpansionContext";
@@ -59,6 +62,9 @@ const getNestedObservationKeys = (
return keys;
};
+const OBSERVATION_TYPE_ALERT_ID = "observation-types";
+const STORAGE_KEY = "dismissed-trace-view-notifications";
+
export function Trace(props: {
observations: Array<ObservationReturnTypeWithMetadata>;
trace: Omit<WithStringifiedMetadata<TraceDomain>, "input" | "output"> & {
@@ -101,6 +107,8 @@ export function Trace(props: {
] = useLocalStorage("colorCodeMetricsOnObservationTree", true);
const [showComments, setShowComments] = useLocalStorage("showComments", true);
const [showGraph, setShowGraph] = useLocalStorage("showGraph", true);
+ const [dismissedTraceViewNotifications, setDismissedTraceViewNotifications] =
+ useLocalStorage<string[]>(STORAGE_KEY, []);
const [collapsedNodes, setCollapsedNodes] = useState<string[]>([]);
// Use imperative panel API for collapse/expand
@@ -430,6 +438,67 @@ export function Trace(props: {
/>
) : null;
+ const observationTypeAlert = useMemo(() => {
+ if (
+ context === "peek" &&
+ props.observations.length > 0 &&
+ props.observations.every((o) => o.type === "SPAN") &&
+ !dismissedTraceViewNotifications.includes(OBSERVATION_TYPE_ALERT_ID)
+ ) {
+ return (
+ <div className="relative mx-2 mb-2 flex flex-col items-start justify-center gap-2 rounded-lg border border-dashed p-4">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="absolute right-1.5 top-1.5 h-5 w-5 p-0"
+ onClick={() => {
+ capture("notification:dismiss_notification", {
+ notification_id: OBSERVATION_TYPE_ALERT_ID,
+ });
+ setDismissedTraceViewNotifications((prev) =>
+ prev.includes(OBSERVATION_TYPE_ALERT_ID)
+ ? prev
+ : [...prev, OBSERVATION_TYPE_ALERT_ID],
+ );
+ }}
+ title="Dismiss"
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ <div className="flex w-full flex-row items-center gap-2 pr-6">
+ <div className="flex h-8 w-8 items-center justify-center rounded-full bg-accent">
+ <Info className="h-4 w-4 text-muted-foreground" />
+ </div>
+ <h3 className="text-sm font-semibold">
+ You&apos;re only using spans here.
+ </h3>
+ </div>
+ <p className="text-sm text-muted-foreground">
+ You&apos;ll get much richer insights by using specific observation
+ types.
+ </p>
+ <ActionButton
+ variant="outline"
+ size="sm"
+ className="h-auto whitespace-normal py-0.5 text-left"
+ href="https://langfuse.com/docs/observability/features/observation-types"
+ trackingEventName="notification:click_link"
+ trackingProps={{ notification_id: OBSERVATION_TYPE_ALERT_ID }}
+ >
+ Learn how to use observation types
+ </ActionButton>
+ </div>
+ );
+ }
+ return null;
+ }, [
+ context,
+ props.observations,
+ dismissedTraceViewNotifications,
+ setDismissedTraceViewNotifications,
+ capture,
+ ]);
+
return (
<JsonExpansionProvider>
<div
@@ -438,7 +507,7 @@ export function Trace(props: {
>
{/* Mobile: Vertical stack without resizing */}
{isMobile && (
- <div className="flex h-full w-full flex-col overflow-y-auto md:hidden">
+ <div className="flex w-full flex-1 flex-col overflow-y-auto md:hidden">
{/* Tree Panel - Mobile */}
<div className="flex-shrink-0 border-b pb-2">
<Command className="mt-1 flex flex-col gap-1 overflow-hidden rounded-none border-0">
@@ -621,7 +690,10 @@ export function Trace(props: {
/>
</div>
) : (
- <div className="w-full">{treeOrSearchContent}</div>
+ <div className="w-full">
+ {treeOrSearchContent}
+ {observationTypeAlert}
+ </div>
)}
</div>
</Command>
@@ -636,7 +708,7 @@ export function Trace(props: {
{/* Desktop: Horizontal resizable panels */}
{!isMobile && (
- <div className="hidden md:block md:h-full">
+ <div className="hidden md:flex md:h-full md:min-h-0 md:flex-1 md:flex-col">
<ResizablePanelGroup
id={panelGroupId}
direction="horizontal"
@@ -982,9 +1054,12 @@ export function Trace(props: {
maxSize={95}
className="flex flex-col overflow-hidden pl-0 pr-2"
>
- <div className="min-h-0 flex-1 overflow-y-auto pb-2">
+ <div className="min-h-0 overflow-y-auto pb-2">
{treeOrSearchContent}
</div>
+ <div className="shrink-0">
+ {observationTypeAlert}
+ </div>
</ResizablePanel>
<ResizableHandle className="relative h-px bg-border transition-colors duration-200 after:absolute after:inset-x-0 after:top-0 after:h-1 after:-translate-y-px after:bg-blue-200 after:opacity-0 after:transition-opacity after:duration-200 hover:after:opacity-100 data-[resize-handle-state='drag']:after:opacity-100" />
@@ -1003,9 +1078,12 @@ export function Trace(props: {
</ResizablePanelGroup>
) : (
<div className="flex h-full w-full flex-col overflow-hidden pl-0 pr-2">
- <div className="min-h-0 flex-1 overflow-y-auto pb-2">
+ <div className="min-h-0 overflow-y-auto pb-2">
{treeOrSearchContent}
</div>
+ <div className="shrink-0">
+ {observationTypeAlert}
+ </div>
</div>
)}
</div>
diff --git a/web/src/components/trace2/components/IOPreview/IOPreview.tsx b/web/src/components/trace2/components/IOPreview/IOPreview.tsx
index eb24da27f5..8cda8a5ecc 100644
--- a/web/src/components/trace2/components/IOPreview/IOPreview.tsx
+++ b/web/src/components/trace2/components/IOPreview/IOPreview.tsx
@@ -11,9 +11,15 @@ import { useChatMLParser } from "./hooks/useChatMLParser";
import { ChatMessageList } from "./components/ChatMessageList";
import { SectionToolDefinitions } from "./components/SectionToolDefinitions";
import { ViewModeToggle, type ViewMode } from "./components/ViewModeToggle";
+import { Button } from "@/src/components/ui/button";
+import { ActionButton } from "@/src/components/ActionButton";
+import { BookOpen, X } from "lucide-react";
export type { ViewMode };
+const EMPTY_IO_ALERT_ID = "empty-io";
+const STORAGE_KEY = "dismissed-trace-view-notifications";
+
export interface ExpansionStateProps {
inputExpansionState?: Record<string, boolean> | boolean;
outputExpansionState?: Record<string, boolean> | boolean;
@@ -131,6 +137,8 @@ export function IOPreview({
setIsPrettyViewAvailable,
}: IOPreviewProps) {
const capture = usePostHogClientCapture();
+ const [dismissedTraceViewNotifications, setDismissedTraceViewNotifications] =
+ useLocalStorage<string[]>(STORAGE_KEY, []);
// View state management
const [localCurrentView, setLocalCurrentView] = useLocalStorage<ViewMode>(
@@ -205,6 +213,13 @@ export function IOPreview({
onOutputExpansionChange,
};
+ const showEmptyState =
+ (parsedInput === null || parsedInput === undefined) &&
+ (parsedOutput === null || parsedOutput === undefined) &&
+ !isLoading &&
+ !hideIfNull &&
+ !dismissedTraceViewNotifications.includes(EMPTY_IO_ALERT_ID);
+
return (
<>
<SectionToolDefinitions
@@ -246,6 +261,48 @@ export function IOPreview({
<div style={{ display: selectedView === "json" ? "block" : "none" }}>
<JsonInputOutputView {...jsonViewProps} />
</div>
+ {showEmptyState && (
+ <div className="relative mx-2 flex flex-col items-start gap-2 rounded-lg border border-dashed p-4">
+ <Button
+ variant="ghost"
+ size="sm"
+ className="absolute right-1.5 top-1.5 h-5 w-5 p-0"
+ onClick={() => {
+ capture("notification:dismiss_notification", {
+ notification_id: EMPTY_IO_ALERT_ID,
+ });
+ setDismissedTraceViewNotifications((prev) =>
+ prev.includes(EMPTY_IO_ALERT_ID)
+ ? prev
+ : [...prev, EMPTY_IO_ALERT_ID],
+ );
+ }}
+ title="Dismiss"
+ >
+ <X className="h-3.5 w-3.5" />
+ </Button>
+ <div className="flex w-full flex-row items-center gap-2 pr-6">
+ <div className="flex h-8 w-8 items-center justify-center rounded-full bg-accent">
+ <BookOpen className="h-4 w-4 text-muted-foreground" />
+ </div>
+ <h3 className="text-sm font-semibold">
+ Looks like this trace didn&apos;t receive an input or output.
+ </h3>
+ </div>
+ <p className="max-w-sm text-sm text-muted-foreground">
+ Add it in your code to make debugging a lot easier.
+ </p>
+ <ActionButton
+ variant="outline"
+ size="sm"
+ href="https://langfuse.com/faq/all/empty-trace-input-and-output"
+ trackingEventName="notification:click_link"
+ trackingProps={{ notification_id: EMPTY_IO_ALERT_ID }}
+ >
+ View Documentation
+ </ActionButton>
+ </div>
+ )}
</>
);
}