🪢 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(web): mask customer IO content in PostHog session recordings (#16244)
Trang Nguyenc32710d9757b
diff --git a/web/eslint.config.mjs b/web/eslint.config.mjsindex 5d692c7aa8..c5b604100f 100644--- a/web/eslint.config.mjs+++ b/web/eslint.config.mjs@@ -79,6 +79,8 @@ export default ["io-message-header",// Used by parent arbitrary selectors to tune IO preview body spacing and borders."io-message-content",+ // posthog-js block class: elements carrying it are excluded from session recordings.+ "ph-no-capture",// Component-level selector hook for code block wrappers, not a Tailwind utility."codeblock",// Sonner root hook used by group-[.toaster] descendant variants.diff --git a/web/src/components/DiffViewer.tsx b/web/src/components/DiffViewer.tsxindex 85413b97c3..8e2d193bb5 100644--- a/web/src/components/DiffViewer.tsx+++ b/web/src/components/DiffViewer.tsx@@ -197,7 +197,7 @@ const DiffViewer: React.FC<DiffViewerProps> = ({}return (- <div className={cn("w-full", className)}>+ <div className={cn("ph-no-capture w-full", className)}><Card><CardContent className="p-0"><div className="grid grid-cols-2">diff --git a/web/src/components/ui/CodeJsonViewer.tsx b/web/src/components/ui/CodeJsonViewer.tsxindex a07b246e47..7bd2232d4a 100644--- a/web/src/components/ui/CodeJsonViewer.tsx+++ b/web/src/components/ui/CodeJsonViewer.tsx@@ -101,7 +101,7 @@ export function JSONView(props: {<><divclassName={cn(- "io-message-content flex max-w-full min-w-0 gap-2 text-xs wrap-break-word whitespace-pre-wrap",+ "io-message-content ph-no-capture flex max-w-full min-w-0 gap-2 text-xs wrap-break-word whitespace-pre-wrap",props.borderless ? "" : "p-2",props.title === "assistant" || props.title === "Output"? "bg-accent-light-green dark:border-accent-dark-green/30"@@ -168,7 +168,7 @@ export function JSONView(props: {<div className="text-muted-foreground my-1 px-0 py-1 text-xs">Media</div>- <div className="flex flex-wrap gap-2 pt-1 pb-4">+ <div className="ph-no-capture flex flex-wrap gap-2 pt-1 pb-4">{props.media.map((m) => (<LangfuseMediaViewmediaAPIReturnValue={m}@@ -329,7 +329,7 @@ export function CodeView(props: {)}<codeclassName={cn(- "relative max-w-full min-w-0 flex-1 px-4 py-3 font-mono text-xs",+ "ph-no-capture relative max-w-full min-w-0 flex-1 px-4 py-3 font-mono text-xs",!props.title && !lineWrap ? "w-[calc(100%-2.5rem)] pr-12" : "",lineWrap? "wrap-break-word whitespace-pre-wrap"diff --git a/web/src/components/ui/IOTableCell.tsx b/web/src/components/ui/IOTableCell.tsxindex cf0e824fce..6bc75c040c 100644--- a/web/src/components/ui/IOTableCell.tsx+++ b/web/src/components/ui/IOTableCell.tsx@@ -102,7 +102,7 @@ const IOTableCellContent = ({return singleLine ? (<divclassName={cn(- "h-full w-full self-stretch truncate overflow-hidden overflow-y-auto rounded-sm",+ "ph-no-capture h-full w-full self-stretch truncate overflow-hidden overflow-y-auto rounded-sm",paddingClassName,className,)}@@ -238,7 +238,7 @@ export const IOTableCell = ({</div></HoverCardTrigger><HoverCardContent- className="max-h-[40vh] w-[400px] overflow-y-auto"+ className="ph-no-capture max-h-[40vh] w-[400px] overflow-y-auto"side="top"align="start">diff --git a/web/src/components/ui/LargeStringFallback.tsx b/web/src/components/ui/LargeStringFallback.tsxindex 4a97417ce8..d503465ced 100644--- a/web/src/components/ui/LargeStringFallback.tsx+++ b/web/src/components/ui/LargeStringFallback.tsx@@ -56,7 +56,7 @@ export function LargeStringFallback({};return (- <div className="io-message-content">+ <div className="io-message-content ph-no-capture"><div className="my-2 flex flex-col gap-2 rounded-sm border border-dashed p-3"><div className="text-muted-foreground flex flex-wrap items-center gap-2 text-xs">{title ? (diff --git a/web/src/components/ui/MarkdownJsonView.tsx b/web/src/components/ui/MarkdownJsonView.tsxindex c6ac153e85..c6cc035a10 100644--- a/web/src/components/ui/MarkdownJsonView.tsx+++ b/web/src/components/ui/MarkdownJsonView.tsx@@ -33,7 +33,9 @@ export function MarkdownJsonViewHeader({return (<div className="io-message-header group-hover:bg-muted/80 flex flex-row items-center justify-between px-1 py-1 text-sm font-bold capitalize transition-colors">- <div className="flex items-center gap-2">+ {/* Masked from session recordings: the title can be a customer-provided+ message `name` (or tool name) rather than a fixed role string. */}+ <div className="ph-no-capture flex items-center gap-2">{titleIcon}{title}</div>diff --git a/web/src/components/ui/MarkdownViewer.tsx b/web/src/components/ui/MarkdownViewer.tsxindex 4d5cda2872..a52dbff8b4 100644--- a/web/src/components/ui/MarkdownViewer.tsx+++ b/web/src/components/ui/MarkdownViewer.tsx@@ -585,7 +585,7 @@ export function MarkdownView({{afterHeader}<divclassName={cn(- "io-message-content grid grid-flow-row gap-2 px-1 py-2",+ "io-message-content ph-no-capture grid grid-flow-row gap-2 px-1 py-2",title === "assistant" || title === "Output" || title === "Model"? "bg-accent-light-green": "",@@ -649,7 +649,7 @@ export function MarkdownView({<div className="text-muted-foreground mx-3 border-t px-2 py-1 text-xs">Media</div>- <div className="mx-3 flex flex-wrap gap-2 px-2 pt-1 pb-4">+ <div className="ph-no-capture mx-3 flex flex-wrap gap-2 px-2 pt-1 pb-4">{remainingMedia.map((m) => (<LangfuseMediaViewmediaAPIReturnValue={m}diff --git a/web/src/components/ui/PrettyJsonView.tsx b/web/src/components/ui/PrettyJsonView.tsxindex 6b860d7cee..dfe5a5fe09 100644--- a/web/src/components/ui/PrettyJsonView.tsx+++ b/web/src/components/ui/PrettyJsonView.tsx@@ -1274,7 +1274,7 @@ export function PrettyJsonView(props: {{largeStringValue !== null ? (<LargeStringFallback title={props.title} value={largeStringValue} />) : props.isLoading || props.isParsing ? (- <div className="io-message-content">+ <div className="io-message-content ph-no-capture"><divclassName={cn(getContainerClasses(@@ -1297,7 +1297,7 @@ export function PrettyJsonView(props: {</div></div>) : emptyValueDisplay && isPrettyView ? (- <div className="io-message-content">+ <div className="io-message-content ph-no-capture"><divclassName={cn("flex items-center",@@ -1314,7 +1314,7 @@ export function PrettyJsonView(props: {</div></div>) : isMarkdownMode ? (- <div className="io-message-content">+ <div className="io-message-content ph-no-capture">{shouldRenderStandaloneMedia ? (standaloneMediaReferenceStrings.map((referenceString, index) => (<LangfuseMediaView@@ -1334,7 +1334,7 @@ export function PrettyJsonView(props: {<>{/* Always render JsonPrettyTable to preserve internal React Table state */}<div- className="io-message-content"+ className="io-message-content ph-no-capture"style={{ display: shouldUseTableView ? "flex" : "none" }}><div@@ -1372,7 +1372,7 @@ export function PrettyJsonView(props: {{/* Always render JSONView to preserve its state too */}<div- className="io-message-content"+ className="io-message-content ph-no-capture"style={{ display: shouldUseTableView ? "none" : "block" }}><JSONView@@ -1400,7 +1400,7 @@ export function PrettyJsonView(props: {<div className="text-muted-foreground my-1 px-2 py-1 text-xs">Media</div>- <div className="flex flex-wrap gap-2 px-2 pt-1 pb-4">+ <div className="ph-no-capture flex flex-wrap gap-2 px-2 pt-1 pb-4">{remainingMarkdownMedia.map((m) => (<LangfuseMediaViewmediaAPIReturnValue={m}@@ -1419,7 +1419,7 @@ export function PrettyJsonView(props: {<div className="text-muted-foreground my-1 px-2 py-1 text-xs">Media</div>- <div className="flex flex-wrap gap-2 px-2 pt-1 pb-4">+ <div className="ph-no-capture flex flex-wrap gap-2 px-2 pt-1 pb-4">{props.media.map((m) => (<LangfuseMediaViewmediaAPIReturnValue={m}diff --git a/web/src/features/datasets/components/DatasetItemMediaAttachments.tsx b/web/src/features/datasets/components/DatasetItemMediaAttachments.tsxindex b57f3d0957..03ed06083b 100644--- a/web/src/features/datasets/components/DatasetItemMediaAttachments.tsx+++ b/web/src/features/datasets/components/DatasetItemMediaAttachments.tsx@@ -301,7 +301,7 @@ function DatasetItemAttachments({return (<div className="flex flex-col gap-2"><span className="text-sm font-bold">Attachments</span>- <div className="flex flex-wrap gap-2">+ <div className="ph-no-capture flex flex-wrap gap-2">{referenceStrings.map((referenceString) => (<LangfuseMediaViewkey={referenceString}diff --git a/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx b/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsxindex d6580ee15f..733b4e97cc 100644--- a/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreviewJSON.tsx@@ -617,7 +617,7 @@ function IOPreviewJSONInner({);return (- <div className="flex min-h-0 flex-1 flex-col border-t border-b">+ <div className="ph-no-capture flex min-h-0 flex-1 flex-col border-t border-b">{/* Inline comment bubble - shows when text is selected */}{enableInlineComments && (<InlineCommentBubble onAddComment={handleAddComment} />diff --git a/web/src/features/traces/components/IOPreview/components/CorrectedOutputDiffDialog.tsx b/web/src/features/traces/components/IOPreview/components/CorrectedOutputDiffDialog.tsxindex 88305c7790..4afe787ea8 100644--- a/web/src/features/traces/components/IOPreview/components/CorrectedOutputDiffDialog.tsx+++ b/web/src/features/traces/components/IOPreview/components/CorrectedOutputDiffDialog.tsx@@ -110,7 +110,7 @@ export const CorrectedOutputDiffDialog: React.FC<</div><div><p className="mb-1 text-sm font-bold">Corrected Output</p>- <pre className="bg-muted/30 max-h-[50vh] overflow-auto rounded-md border p-3 text-xs break-words whitespace-pre-wrap">+ <pre className="ph-no-capture bg-muted/30 max-h-[50vh] overflow-auto rounded-md border p-3 text-xs break-words whitespace-pre-wrap">{formattedCorrectedOutput}</pre></div>@@ -125,7 +125,7 @@ export const CorrectedOutputDiffDialog: React.FC<</div></div>) : (- <div className="space-y-4">+ <div className="ph-no-capture space-y-4"><DiffVieweroldString={formattedActualOutput}newString={formattedCorrectedOutput}diff --git a/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsx b/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsxindex 982c0bafa6..a5c54dfab6 100644--- a/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsx+++ b/web/src/features/traces/components/IOPreview/components/LargeJsonFieldFallback.tsx@@ -100,7 +100,7 @@ export function LargeJsonFieldFallback({}return (- <div className="io-message-content">+ <div className="io-message-content ph-no-capture"><div className="my-2 flex flex-col gap-2 rounded-sm border border-dashed p-3"><div className="text-muted-foreground flex flex-wrap items-center gap-2 text-xs">{!hideTitle && (diff --git a/web/src/features/traces/components/IOPreview/components/SectionMedia.tsx b/web/src/features/traces/components/IOPreview/components/SectionMedia.tsxindex 17331b1a3b..2a54253389 100644--- a/web/src/features/traces/components/IOPreview/components/SectionMedia.tsx+++ b/web/src/features/traces/components/IOPreview/components/SectionMedia.tsx@@ -17,7 +17,7 @@ export function SectionMedia({ media }: SectionMediaProps) {return (<><div className="text-muted-foreground my-1 px-2 py-1 text-xs">Media</div>- <div className="flex flex-wrap gap-2 px-2 pt-1 pb-4">+ <div className="ph-no-capture flex flex-wrap gap-2 px-2 pt-1 pb-4">{media.map((m) => (<LangfuseMediaViewmediaAPIReturnValue={m}diff --git a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsxindex b0a52d9294..c1b7375b89 100644--- a/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx+++ b/web/src/features/traces/components/IOPreview/components/ToolCallDefinitionCard.tsx@@ -146,7 +146,7 @@ function ToolGroupHoverContent({<div className="flex min-w-0 items-center gap-2"><Wrench className="text-muted-foreground h-3.5 w-3.5 shrink-0" /><span- className="text-foreground block truncate font-mono text-xs font-bold"+ className="ph-no-capture text-foreground block truncate font-mono text-xs font-bold"title={tool.name}>{toolDefinitionNumber !== undefined && (@@ -341,7 +341,7 @@ function ToolDefinitionRow({<div className="flex min-w-0 items-center gap-2"><Wrench className="text-muted-foreground h-3.5 w-3.5 shrink-0" /><span- className="text-foreground block truncate font-mono text-xs font-bold"+ className="ph-no-capture text-foreground block truncate font-mono text-xs font-bold"title={tool.name}>{toolDefinitionNumber !== undefined && (@@ -394,7 +394,7 @@ function ToolDefinitionRow({<div className="text-muted-foreground mb-1.5 text-xs font-bold">Description</div>- <div className="text-foreground text-sm">+ <div className="ph-no-capture text-foreground text-sm">{tool.description}</div></div>diff --git a/web/src/features/traces/components/ThinkingBlock.tsx b/web/src/features/traces/components/ThinkingBlock.tsxindex 4951237b25..29f113847c 100644--- a/web/src/features/traces/components/ThinkingBlock.tsx+++ b/web/src/features/traces/components/ThinkingBlock.tsx@@ -32,12 +32,14 @@ export function ThinkingBlock({/><span className="text-xs font-bold">Thinking</span>{!expanded && (- <span className="line-clamp-1 text-xs italic">{displayContent}</span>+ <span className="ph-no-capture line-clamp-1 text-xs italic">+ {displayContent}+ </span>)}</button>{expanded && (- <div className="text-muted-foreground mt-1 ml-4 text-sm whitespace-pre-wrap italic">+ <div className="ph-no-capture text-muted-foreground mt-1 ml-4 text-sm whitespace-pre-wrap italic">{content}</div>)}@@ -78,7 +80,7 @@ export function RedactedThinkingBlock({</button>{expanded && (- <div className="bg-muted/50 text-muted-foreground mt-1 ml-4 rounded p-2 font-mono text-xs break-all">+ <div className="ph-no-capture bg-muted/50 text-muted-foreground mt-1 ml-4 rounded p-2 font-mono text-xs break-all">{data}</div>)}