🪢 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
fix(posthog): protect customer payloads in session replay (#16693)
Max Deichmann303fa2e9d765
diff --git a/.agents/skills/code-review/SKILL.md b/.agents/skills/code-review/SKILL.mdindex e819628d7f..8b3d3f1f39 100644--- a/.agents/skills/code-review/SKILL.md+++ b/.agents/skills/code-review/SKILL.md@@ -19,8 +19,9 @@ feature.- If the review touches backend code, also use the shared`backend-dev-guidelines` skill where relevant.- If the change accepts a user-supplied URL, adds outbound HTTP, introduces a- new integration, or touches secrets, RBAC, or redirect handling, also use- the shared [`security-review`](../security-review/SKILL.md) skill. Run its+ new integration, touches secrets, RBAC, redirect handling, product+ analytics, browser monitoring, or session replay, also use the shared+ [`security-review`](../security-review/SKILL.md) skill. Run its[`references/checklist.md`](../security-review/references/checklist.md)before signoff.diff --git a/.agents/skills/code-review/references/review-checklist.md b/.agents/skills/code-review/references/review-checklist.mdindex 788a9eb8df..f0ddc0757a 100644--- a/.agents/skills/code-review/references/review-checklist.md+++ b/.agents/skills/code-review/references/review-checklist.md@@ -59,7 +59,8 @@ This is the canonical shared review checklist for Langfuse.`validateBlobStorageEndpoint`, or a new wrapper around`validateOutboundUrlHost`) is a finding.- For changes that add a new integration, secret-bearing field, redirect- follower, or RBAC scope, run the rest of the+ follower, RBAC scope, product analytics, browser monitoring, or session+ replay, run the rest of the[`security-review/references/checklist.md`](../../security-review/references/checklist.md).- For changes that shape what a read route returns — a repository or domainconverter, a `Safe*` type, a response projection — a catch-all branch thatdiff --git a/.agents/skills/posthog-instrumentation/SKILL.md b/.agents/skills/posthog-instrumentation/SKILL.mdindex b2f2d5354a..c677510f36 100644--- a/.agents/skills/posthog-instrumentation/SKILL.md+++ b/.agents/skills/posthog-instrumentation/SKILL.md@@ -3,7 +3,7 @@ name: posthog-instrumentationdescription: |Product analytics with posthog.Use when adding a meaningful user action or feature in `web/**`, touching PostHog capture code,- or answering product-usage questions.+ changing session replay or its privacy boundaries, or answering product-usage questions.---# PostHog Instrumentation@@ -118,6 +118,52 @@ should emit an event — do not skip the question silently./ search text / prompt / id appears.** A green typecheck ≠correctanalytics; the dimension-populated and privacy checks catch the real bugs.+## Session replay privacy++Treat session replay as a separate data-export surface from analytics events.+Apply these rules when changing `posthog.init`, replay configuration, or a UI+renderer that can display customer-controlled data:++1. **Allowlist eligible deployments.** Keep replay disabled by default and+ enable it only in explicitly approved hosted regions. A configured PostHog+ key is not proof that a deployment is eligible. In Langfuse, replay remains+ disabled when the cloud region is absent and in the HIPAA region; cover an+ eligible region, HIPAA, and no cloud region in config tests.+2. **Classify by data provenance, not HTML element.** Customer-controlled data+ includes trace/observation payloads, dataset items, prompts, generated+ output, evaluator/code input, identifiers, comments, names, tags, metadata,+ schemas, provider options, media previews/URLs, and values copied into+ `title`, `aria-*`, or other attributes. Ordinary rendered text can be as+ sensitive as an `<input>` value.+3. **Protect the shared render boundary.** Prefer `ph-no-capture` on the+ smallest shared component or renderer that owns a sensitive value. Block+ the complete subtree so text, attributes, nested media, and later view-mode+ changes inherit the protection. Keep native input masking and a+ `contenteditable` selector as backstops, not the primary policy.+4. **Follow actual DOM topology.** Audit read-only, edit, history, diff,+ loading, empty, virtualized, hover, and dialog variants. Portaled content is+ outside a blocked trigger's subtree and needs its own protection. Custom+ editors and syntax highlighters are not covered merely because they behave+ like inputs.+5. **Redact non-DOM channels.** Never record request/response bodies, console+ payloads, or custom replay events containing customer content. Keep network+ body redaction even when the visible DOM is blocked.+6. **Prove the emitted replay, not only the JSX.** Add config contract tests+ for deployment gating and focused component tests for blocking boundaries.+ For meaningful masking changes, run the installed recorder in a browser+ with unique sentinels in ordinary text, native inputs, custom editors,+ blocked subtrees, attributes, and portals; inspect emitted replay events and+ prove sensitive sentinels are absent while intended UI text remains.++Before implementation, write a one-paragraph data-boundary plan: what remains+visible, what must never leave the browser, which deployment classes are+eligible, and which shared renderers enforce it. If that boundary includes+customer-controlled content, get an explicit product/legal decision rather+than inferring consent from existing analytics. Also run the+[`security-review`](../security-review/SKILL.md) skill and its+[`client-telemetry-privacy.md`](../security-review/references/client-telemetry-privacy.md)+checklist.+## Workflow1. **Tracking plan first (tiny).** Write the question(s) → the events + props@@ -130,6 +176,9 @@ should emit an event — do not skip the question silently.5. **PR** with the taxonomy table + an explicit "metadata-only, no raw values"note. Fix any pre-existing leaks you pass.+For replay-only changes, use the session-replay data-boundary plan and recorder+probe above instead of inventing an analytics event or taxonomy entry.+## Anti-patterns- Raw values / PII in props (Rule 1).@@ -141,6 +190,9 @@ should emit an event — do not skip the question silently.spaces or rename existing events.- Raw `posthog.capture` in a component instead of the typed hook.- Trusting a typecheck as verification (Rule 6).+- Assuming `maskAllInputs` covers rendered text, custom editors, attributes,+ or portals.+- Enabling replay wherever PostHog credentials happen to be configured.## Referencesdiff --git a/.agents/skills/security-review/SKILL.md b/.agents/skills/security-review/SKILL.mdindex 068ba3f3b9..02ac965b48 100644--- a/.agents/skills/security-review/SKILL.md+++ b/.agents/skills/security-review/SKILL.md@@ -1,6 +1,6 @@---name: security-review-description: Review Langfuse changes for SSRF, tenant isolation, secret handling, unsafe redirects or uploads, and RBAC drift. Use when a design or change accepts URLs or host fields, handles secrets or cross-tenant data, makes outbound requests, adds an integration, follows redirects, or widens permissions.+description: Review Langfuse changes for SSRF, tenant isolation, secret handling, unsafe redirects or uploads, RBAC drift, and client telemetry privacy. Use when a design or change accepts URLs or host fields, handles secrets or cross-tenant data, makes outbound requests, adds an integration, follows redirects, widens permissions, or can send customer-controlled UI data through analytics, monitoring, or session replay.---# Security Review@@ -25,6 +25,8 @@ Apply this skill when the change touches any of:- secrets, API keys, signing secrets, or encryption-at-rest fields- redirect-following or cross-origin header handling- file uploads, image proxies, or other binary data flowing in or out+- product analytics, browser monitoring, session replay, or another client-side+ telemetry path that can transmit customer-controlled contentApply this skill during **plan mode** when designing a new integration so thecorrect validation surfaces land in the plan, not in a follow-up CVE.@@ -35,10 +37,11 @@ correct validation surfaces land in the plan, not in a follow-up CVE.sweep against the change.2. For each bullet that fires, open the matching topic reference.-| Topic | Open when | File |-| --- | --- | --- |-| SSRF and outbound URL validation | The change accepts or fetches a user-supplied URL, host, or endpoint | [references/outbound-url-validation.md](references/outbound-url-validation.md) |-| Secret read paths | The change shapes what a read route returns for an entity or config blob that also stores a credential | [references/secret-read-paths.md](references/secret-read-paths.md) |+| Topic | Open when | File |+| ----------------------------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |+| SSRF and outbound URL validation | The change accepts or fetches a user-supplied URL, host, or endpoint | [references/outbound-url-validation.md](references/outbound-url-validation.md) |+| Secret read paths | The change shapes what a read route returns for an entity or config blob that also stores a credential | [references/secret-read-paths.md](references/secret-read-paths.md) |+| Client telemetry and session replay | The change records DOM, browser state, events, logs, or network data in a third-party system | [references/client-telemetry-privacy.md](references/client-telemetry-privacy.md) |The catalog is intentionally short today. New topic files are added as newfinding classes recur (see "Extending This Skill").diff --git a/.agents/skills/security-review/references/checklist.md b/.agents/skills/security-review/references/checklist.mdindex 2d5294a1b4..a818ffecb4 100644--- a/.agents/skills/security-review/references/checklist.md+++ b/.agents/skills/security-review/references/checklist.md@@ -70,6 +70,16 @@ restate them here so the security sweep stays self-contained.`web/src/features/blobstorage-integration/blobstorage-integration-router.ts`and similar routers.+## Client Telemetry and Session Replay++- Can analytics, browser monitoring, replay, logs, or network capture transmit+ customer-controlled values or identifiers to a third party?+ - If yes, see+ [client-telemetry-privacy.md](client-telemetry-privacy.md). Required: an+ explicit data boundary, deployment/compliance allowlisting, protection at+ shared render boundaries including portals and attributes, negative tests,+ and inspection of the emitted payload.+## Negative Tests- Does the change include tests that prove **blocked** inputs are rejecteddiff --git a/.agents/skills/security-review/references/client-telemetry-privacy.md b/.agents/skills/security-review/references/client-telemetry-privacy.mdnew file mode 100644index 0000000000..4b7036e4d8--- /dev/null+++ b/.agents/skills/security-review/references/client-telemetry-privacy.md@@ -0,0 +1,67 @@+# Client Telemetry and Session Replay Privacy++## Threat++Browser analytics and session replay can export customer-controlled data to a+third party even when the application never sends that value in an explicit+analytics event. Replay recorders observe the rendered DOM, attributes,+portals, network metadata, and optional console/custom events. Input masking+alone does not protect values later rendered as text, and a compliance-sensitive+deployment must not start recording merely because telemetry credentials exist.++## Canonical Langfuse controls++- `web/src/pages/_app.tsx` owns PostHog initialization, deployment gating,+ native/custom input masking, the `ph-no-capture` block class, and network+ body redaction.+- Shared renderers should own `ph-no-capture` whenever they display a value+ whose provenance is customer-controlled. This protects all call sites and+ the subtree's text, attributes, and nested media.+- Portaled hover cards and dialogs need a blocking boundary on the portaled+ content itself; a blocked trigger or logical React parent is insufficient.+- The `posthog-instrumentation` skill owns the implementation and browser-probe+ workflow. Use it together with this review.++## Required review++1. **State the data policy.** Identify what ordinary UI may remain visible,+ what customer-controlled values must never leave the browser, which third+ party receives data, and which deployments/regions are eligible. Escalate+ an ambiguous boundary for product/legal approval.+2. **Trace provenance through every renderer.** Include inputs and outputs,+ dataset records, prompts, generated content, code, identifiers, names,+ tags, comments, metadata, schemas, options, media/URLs, and values copied+ into attributes. Check read-only, edit, history, diff, loading, empty,+ virtualized, hover, and dialog paths.+3. **Enforce at shared boundaries.** Block the smallest shared renderer that+ owns sensitive content. Do not build a fragile page-by-page selector list+ when one editor/viewer component can enforce the rule for every caller.+4. **Follow DOM boundaries.** Treat custom editors, syntax highlighters,+ contenteditable elements, and portaled content independently from native+ inputs. Protect the complete subtree when attributes or nested media can+ carry the same value.+5. **Gate by explicit eligibility.** Default replay to disabled. Use an+ allowlist of approved hosted deployment classes and exclude compliance+ regions and self-hosted/unknown environments. Telemetry keys, hostnames, or+ remote feature flags do not replace the local gate.+6. **Cover non-DOM exports.** Redact request/response bodies and reject raw+ customer values in analytics properties, console capture, custom replay+ events, error breadcrumbs, and URLs.+7. **Test the negative contract.** Add configuration tests for eligible,+ compliance-restricted, and unknown/self-hosted deployments; component tests+ for shared block boundaries; and a real-browser recorder probe with unique+ sentinels. Inspect emitted events and prove forbidden text and attributes+ are absent.++## Findings to raise++- Replay becomes active by default or wherever a telemetry key is configured.+- A customer value is protected while editable but exposed in read-only,+ preview, history, diff, hover, or generated-output form.+- A blocked trigger opens unblocked portaled content.+- A protection covers text but leaves the same value in `title`, `aria-*`, a+ URL, network body, console entry, or custom event.+- A new sensitive renderer relies only on `maskAllInputs`, CSS appearance, or+ a page-specific selector.+- Tests assert configuration or JSX classes without inspecting a representative+ emitted replay after a meaningful recorder-policy change.diff --git a/web/src/__tests__/posthog-session-replay-mask.clienttest.ts b/web/src/__tests__/posthog-session-replay-mask.clienttest.tsindex b1a25b195a..c7331fcf53 100644--- a/web/src/__tests__/posthog-session-replay-mask.clienttest.ts+++ b/web/src/__tests__/posthog-session-replay-mask.clienttest.ts@@ -17,9 +17,16 @@ vi.mock("posthog-js/react", () => ({}));describe("PostHog session replay privacy", () => {- it("masks all rendered text and input values", async () => {+ beforeEach(() => {+ vi.resetModules();+ vi.unstubAllEnvs();+ initMock.mockReset();+ });++ it("records regular UI text while masking input values", async () => {vi.stubEnv("NEXT_PUBLIC_POSTHOG_KEY", "phc_test");vi.stubEnv("NEXT_PUBLIC_POSTHOG_HOST", "https://eu.i.posthog.com");+ vi.stubEnv("NEXT_PUBLIC_LANGFUSE_CLOUD_REGION", "EU");await import("@/src/pages/_app");@@ -27,7 +34,35 @@ describe("PostHog session replay privacy", () => {const config = initMock.mock.calls[0]![1] as Partial<PostHogConfig>;expect(config.session_recording).toMatchObject({maskAllInputs: true,- maskTextSelector: "*",+ blockClass: "ph-no-capture",});+ expect(config.session_recording?.maskTextSelector).toBe(+ '[contenteditable="true"]',+ );+ expect(config.disable_session_recording).toBe(false);+ });++ it("disables session recording in the HIPAA cloud region", async () => {+ vi.stubEnv("NEXT_PUBLIC_POSTHOG_KEY", "phc_test");+ vi.stubEnv("NEXT_PUBLIC_POSTHOG_HOST", "https://us.i.posthog.com");+ vi.stubEnv("NEXT_PUBLIC_LANGFUSE_CLOUD_REGION", "HIPAA");++ await import("@/src/pages/_app");++ expect(initMock).toHaveBeenCalledTimes(1);+ const config = initMock.mock.calls[0]![1] as Partial<PostHogConfig>;+ expect(config.disable_session_recording).toBe(true);+ });++ it("disables session recording outside Langfuse Cloud", async () => {+ vi.stubEnv("NEXT_PUBLIC_POSTHOG_KEY", "phc_test");+ vi.stubEnv("NEXT_PUBLIC_POSTHOG_HOST", "https://eu.i.posthog.com");+ vi.stubEnv("NEXT_PUBLIC_LANGFUSE_CLOUD_REGION", "");++ await import("@/src/pages/_app");++ expect(initMock).toHaveBeenCalledTimes(1);+ const config = initMock.mock.calls[0]![1] as Partial<PostHogConfig>;+ expect(config.disable_session_recording).toBe(true);});});diff --git a/web/src/components/MediaTag/MediaTag.clienttest.tsx b/web/src/components/MediaTag/MediaTag.clienttest.tsxindex 796c4eb782..ac5c580530 100644--- a/web/src/components/MediaTag/MediaTag.clienttest.tsx+++ b/web/src/components/MediaTag/MediaTag.clienttest.tsx@@ -14,6 +14,24 @@ const OFFICE_CONTENT_TYPES = [] as const;describe("MediaTag", () => {+ it("blocks the portaled preview from PostHog session recordings", () => {+ const description = "customer-provided media description";++ render(+ <MediaTag+ contentType="image/png"+ description={description}+ status="ready"+ url="data:image/png;base64,"+ open+ />,+ );++ expect(screen.getByText(description).parentElement).toHaveClass(+ "ph-no-capture",+ );+ });+it("opens the preview on click", async () => {const onOpenChange = vi.fn();diff --git a/web/src/components/MediaTag/MediaTag.tsx b/web/src/components/MediaTag/MediaTag.tsxindex 7d6cd17da2..ca6d5206e9 100644--- a/web/src/components/MediaTag/MediaTag.tsx+++ b/web/src/components/MediaTag/MediaTag.tsx@@ -289,7 +289,7 @@ export const MediaTag = React.forwardRef<HTMLButtonElement, MediaTagProps>(</HoverCardTrigger><HoverCardContentalign="start"- className="flex w-auto max-w-sm flex-col gap-2 p-2"+ className="ph-no-capture flex w-auto max-w-sm flex-col gap-2 p-2"><div className="flex items-center justify-between gap-4"><div className="text-muted-foreground flex min-w-0 items-center gap-1.5 text-xs">diff --git a/web/src/components/editor/CodeMirrorEditor.clienttest.tsx b/web/src/components/editor/CodeMirrorEditor.clienttest.tsxindex 6db8dd47d9..6efa6619f6 100644--- a/web/src/components/editor/CodeMirrorEditor.clienttest.tsx+++ b/web/src/components/editor/CodeMirrorEditor.clienttest.tsx@@ -1,6 +1,30 @@-// @vitest-environment node+// @vitest-environment jsdom-import { getPromptVariableDiagnostics } from "@/src/components/editor/CodeMirrorEditor";+import { render, screen } from "@testing-library/react";+import type * as ReactCodeMirror from "@uiw/react-codemirror";+import {+ CodeMirrorEditor,+ getPromptVariableDiagnostics,+} from "@/src/components/editor/CodeMirrorEditor";++vi.mock("@uiw/react-codemirror", async (importOriginal) => {+ const actual = await importOriginal<typeof ReactCodeMirror>();++ return {+ ...actual,+ default: ({ className }: { className?: string }) => (+ <div className={className} data-testid="code-mirror" />+ ),+ };+});++describe("CodeMirrorEditor session recording privacy", () => {+ it("blocks editor values from PostHog session recordings", () => {+ render(<CodeMirrorEditor value="customer payload" mode="text" />);++ expect(screen.getByTestId("code-mirror")).toHaveClass("ph-no-capture");+ });+});describe("getPromptVariableDiagnostics", () => {it("accepts triple-brace prompt variables as an inner variable with literal outer braces", () => {diff --git a/web/src/components/editor/CodeMirrorEditor.tsx b/web/src/components/editor/CodeMirrorEditor.tsxindex f082f30d02..7c7c294880 100644--- a/web/src/components/editor/CodeMirrorEditor.tsx+++ b/web/src/components/editor/CodeMirrorEditor.tsx@@ -567,7 +567,7 @@ export function CodeMirrorEditor({onChange={handleChange}onBlur={onBlur}className={cn(- "overflow-hidden overflow-y-auto rounded-md border text-xs",+ "ph-no-capture overflow-hidden overflow-y-auto rounded-md border text-xs",className,)}editable={editable}diff --git a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/components/JsonPathInput.tsx b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/components/JsonPathInput.tsxindex 641cfb9018..7de7bc757a 100644--- a/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/components/JsonPathInput.tsx+++ b/web/src/features/batch-actions/components/AddObservationsToDatasetDialog/components/JsonPathInput.tsx@@ -155,7 +155,7 @@ export function JsonPathInput({onBlur={onBlur}placeholder={placeholder}className={cn(- "overflow-hidden rounded-md border text-sm",+ "ph-no-capture overflow-hidden rounded-md border text-sm",displayError && "border-destructive",showWarning && "border-amber-500/50",className,diff --git a/web/src/features/evals/components/code-eval-template-form-body.clienttest.tsx b/web/src/features/evals/components/code-eval-template-form-body.clienttest.tsxindex f5624c31a7..e34d409344 100644--- a/web/src/features/evals/components/code-eval-template-form-body.clienttest.tsx+++ b/web/src/features/evals/components/code-eval-template-form-body.clienttest.tsx@@ -40,6 +40,24 @@ describe("CodeEvalTemplateFormBody", () => {vi.clearAllMocks();});+ it("blocks evaluator source from PostHog session recordings", () => {+ const { container } = render(+ <CodeEvalTemplateFormBody+ sourceCode="customer evaluator source"+ sourceCodeLanguage="PYTHON"+ onSourceCodeChange={vi.fn()}+ editable={false}+ validationResult={null}+ ctxSample={null}+ />,+ { wrapper: TestTooltipProvider },+ );++ expect(container.querySelector(".ph-no-capture")).toContainElement(+ container.querySelector(".cm-editor"),+ );+ });+it("shows Python validation errors that arrive after the editor mounts", async () => {const sourceCode = "def evaluate(ctx):\n return missing_name";const props = {diff --git a/web/src/features/evals/components/code-eval-template-form-body.tsx b/web/src/features/evals/components/code-eval-template-form-body.tsxindex 317a8770f0..d91eac5297 100644--- a/web/src/features/evals/components/code-eval-template-form-body.tsx+++ b/web/src/features/evals/components/code-eval-template-form-body.tsx@@ -433,7 +433,7 @@ export function CodeEvalTemplateFormBody({editable={editable}onChange={handleSourceCodeChange}onCreateEditor={handleCreateEditor}- className="overflow-hidden rounded-md border text-xs"+ className="ph-no-capture overflow-hidden rounded-md border text-xs"/><p className="text-muted-foreground text-xs">Hover over <code className="font-mono">ctx</code> to preview its typediff --git a/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.clienttest.tsx b/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.clienttest.tsxindex e37ba9fd2a..991d8cefd3 100644--- a/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.clienttest.tsx+++ b/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.clienttest.tsx@@ -21,6 +21,7 @@ describe("PromptVariableEditor", () => {const preview = container.querySelector("pre");expect(preview).toHaveClass(+ "ph-no-capture","bg-muted/50","px-3","py-2",diff --git a/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsx b/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsxindex 88d33cd80a..6f6d287850 100644--- a/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsx+++ b/web/src/features/evals/v2/components/Evaluators/Judges/PromptVariableEditor/PromptVariableEditor.tsx@@ -235,11 +235,11 @@ export function PromptVariableEditor({{previewEnabled && preview ? (preview.status === "unavailable" ? (- <p className="bg-muted/50 text-muted-foreground min-h-[140px] rounded-b-md border px-3 py-2 text-sm">+ <p className="ph-no-capture bg-muted/50 text-muted-foreground min-h-[140px] rounded-b-md border px-3 py-2 text-sm">{preview.message}</p>) : (- <pre className="bg-muted/50 text-card-foreground max-h-[50dvh] min-h-[140px] overflow-y-auto rounded-b-md border px-3 py-2 font-sans text-sm whitespace-pre-wrap">+ <pre className="ph-no-capture bg-muted/50 text-card-foreground max-h-[50dvh] min-h-[140px] overflow-y-auto rounded-b-md border px-3 py-2 font-sans text-sm whitespace-pre-wrap">{preview.fragments.map((fragment, index) => (<Fragment key={index}>{fragment.type === "text" ? (diff --git a/web/src/features/playground/page/components/GenerationOutput.clienttest.tsx b/web/src/features/playground/page/components/GenerationOutput.clienttest.tsxnew file mode 100644index 0000000000..3bcffc5d03--- /dev/null+++ b/web/src/features/playground/page/components/GenerationOutput.clienttest.tsx@@ -0,0 +1,24 @@+import { render, screen } from "@testing-library/react";++import { GenerationOutput } from "./GenerationOutput";++vi.mock("../context", () => ({+ usePlaygroundContext: () => ({+ output: "customer-generated output",+ outputReasoning: "",+ outputJson: '{"secret":"customer-generated output"}',+ addMessage: vi.fn(),+ outputToolCalls: [],+ scrollToMessage: vi.fn(),+ }),+}));++describe("GenerationOutput session recording privacy", () => {+ it("blocks generated output from PostHog session recordings", () => {+ render(<GenerationOutput />);++ expect(screen.getByText("customer-generated output")).toHaveClass(+ "ph-no-capture",+ );+ });+});diff --git a/web/src/features/playground/page/components/GenerationOutput.tsx b/web/src/features/playground/page/components/GenerationOutput.tsxindex 9d688c183b..6b77c1d43e 100644--- a/web/src/features/playground/page/components/GenerationOutput.tsx+++ b/web/src/features/playground/page/components/GenerationOutput.tsx@@ -117,7 +117,7 @@ export const GenerationOutput = () => {<ThinkingBlock content={outputReasoning} /></div>)}- <pre className="text-xs wrap-break-word whitespace-break-spaces">+ <pre className="ph-no-capture text-xs wrap-break-word whitespace-break-spaces">{isJson ? outputJson : output}</pre>{outputToolCalls.length > 0diff --git a/web/src/features/search-bar/components/SearchBarAiPrompt.tsx b/web/src/features/search-bar/components/SearchBarAiPrompt.tsxindex 908435045f..44f3f7c0d4 100644--- a/web/src/features/search-bar/components/SearchBarAiPrompt.tsx+++ b/web/src/features/search-bar/components/SearchBarAiPrompt.tsx@@ -219,7 +219,7 @@ export function SearchBarAiPrompt({><span className="shrink-0">Refining</span><code- className="bg-muted text-foreground/80 min-w-0 truncate rounded px-1.5 py-0.5 font-mono text-[11px]"+ className="ph-no-capture bg-muted text-foreground/80 min-w-0 truncate rounded px-1.5 py-0.5 font-mono text-[11px]"title={refineContext}>{refineContext}diff --git a/web/src/features/search-bar/components/SearchComposer.tsx b/web/src/features/search-bar/components/SearchComposer.tsxindex 3874fa5920..054cf363f4 100644--- a/web/src/features/search-bar/components/SearchComposer.tsx+++ b/web/src/features/search-bar/components/SearchComposer.tsx@@ -1433,7 +1433,7 @@ export function SearchComposer({// wrapped lines of pills (single-line is unaffected).className={cn(COMPOSER_TEXT_CLASSES,- "caret-[hsl(var(--foreground))] outline-none",+ "ph-no-capture caret-[hsl(var(--foreground))] outline-none",)}onInput={(event) => {if (!(event.nativeEvent as InputEvent).isComposing) syncFromDom();diff --git a/web/src/features/traces/components/IOPreview/IOPreviewJSON.clienttest.tsx b/web/src/features/traces/components/IOPreview/IOPreviewJSON.clienttest.tsxindex bba75f2449..b5c16feefe 100644--- a/web/src/features/traces/components/IOPreview/IOPreviewJSON.clienttest.tsx+++ b/web/src/features/traces/components/IOPreview/IOPreviewJSON.clienttest.tsx@@ -127,6 +127,23 @@ const manyRows = () =>// gate constant, so it keeps guarding the regression if the constant moves.const deadZoneRows = () => Array.from({ length: 5_000 }, (_, i) => i);+describe("IOPreviewJSON session recording privacy", () => {+ it("blocks trace input and output from session recordings", () => {+ const { container } = render(+ <IOPreviewJSON+ input={{ secret: "input" }}+ output={{ secret: "output" }}+ hideIfNull+ showCorrections={false}+ projectId="p"+ traceId="t"+ />,+ );++ expect(container.firstElementChild).toHaveClass("ph-no-capture");+ });+});+describe("IOPreviewJSON node-count gating", () => {it("routes a dead-zone field (thousands of rows) to the lazy viewer, not the eager tree", () => {render(diff --git a/web/src/features/traces/components/TraceMetadataBadges.clienttest.tsx b/web/src/features/traces/components/TraceMetadataBadges.clienttest.tsxnew file mode 100644index 0000000000..63c37f25d3--- /dev/null+++ b/web/src/features/traces/components/TraceMetadataBadges.clienttest.tsx@@ -0,0 +1,30 @@+// @vitest-environment jsdom++import { render, screen } from "@testing-library/react";+import {+ SessionBadge,+ TargetTraceBadge,+ UserIdBadge,+} from "./TraceMetadataBadges";++describe("TraceMetadataBadges session replay privacy", () => {+ it("blocks trace identifiers from PostHog session recordings", () => {+ render(+ <>+ <SessionBadge sessionId="customer-session" projectId="project" />+ <UserIdBadge userId="customer-user" projectId="project" />+ <TargetTraceBadge targetTraceId="target-trace" projectId="project" />+ </>,+ );++ expect(+ screen.getByText("Session: customer-session").closest("a"),+ ).toHaveClass("ph-no-capture");+ expect(screen.getByText("User ID: customer-user").closest("a")).toHaveClass(+ "ph-no-capture",+ );+ expect(+ screen.getByText("Target Trace: target-trace").closest("a"),+ ).toHaveClass("ph-no-capture");+ });+});diff --git a/web/src/features/traces/components/TraceMetadataBadges.tsx b/web/src/features/traces/components/TraceMetadataBadges.tsxindex 3ae7477a42..04f93cd331 100644--- a/web/src/features/traces/components/TraceMetadataBadges.tsx+++ b/web/src/features/traces/components/TraceMetadataBadges.tsx@@ -23,7 +23,7 @@ export function SessionBadge({return (<Linkhref={`/project/${projectId}/sessions/${encodeURIComponent(sessionId)}`}- className="inline-flex"+ className="ph-no-capture inline-flex"><Badge><span className="truncate" title={text}>@@ -49,7 +49,7 @@ export function UserIdBadge({return (<Linkhref={`/project/${projectId}/users/${encodeURIComponent(userId)}`}- className="inline-flex"+ className="ph-no-capture inline-flex"><Badge><span className="truncate" title={text}>@@ -75,7 +75,7 @@ export function TargetTraceBadge({return (<Linkhref={`/project/${projectId}/traces/${encodeURIComponent(targetTraceId)}`}- className="inline-flex"+ className="ph-no-capture inline-flex"><Badge><span className="truncate" title={text}>diff --git a/web/src/pages/_app.tsx b/web/src/pages/_app.tsxindex 6d026f107a..51cf036c78 100644--- a/web/src/pages/_app.tsx+++ b/web/src/pages/_app.tsx@@ -93,6 +93,10 @@ import { ScoreCacheProvider } from "@/src/features/scores/contexts/ScoreCacheConimport { CorrectionCacheProvider } from "@/src/features/corrections/contexts/CorrectionCacheContext";import { V4_BETA_ENABLED_POSTHOG_PROPERTY } from "@/src/features/posthog-analytics/usePostHogClientCapture";+const isPostHogSessionRecordingEnabled =+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined &&+ env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== "HIPAA";+// Check that PostHog is client-side (used to handle Next.js SSR) and that env vars are setif (typeof window !== "undefined" &&@@ -106,9 +110,17 @@ if (loaded: (posthog) => {if (process.env.NODE_ENV === "development") posthog.debug();},+ // Session replay is a Langfuse Cloud feature and must stay disabled in the+ // HIPAA region. Other PostHog analytics remain independently configured.+ disable_session_recording: !isPostHogSessionRecordingEnabled,session_recording: {maskAllInputs: true,- maskTextSelector: "*",+ // Custom editors and the trace search composer render customer text in+ // contenteditable elements, which maskAllInputs does not cover.+ maskTextSelector: '[contenteditable="true"]',+ // Trace/observation payload renderers use this class so recordings show+ // the surrounding UI without capturing customer input/output values.+ blockClass: "ph-no-capture",maskCapturedNetworkRequestFn(request) {request.requestBody = request.requestBody ? "REDACTED" : undefined;request.responseBody = request.responseBody ? "REDACTED" : undefined;