Cette page est affichée en anglais. Une traduction française est en cours.
KnowledgeMay 8, 2026·4 min de lecture

PostHog Session Replay — Watch Users Hit Your AI Features

PostHog Session Replay records UI interactions, console logs, network requests. Watch what a user did before clicking your AI chat. PII auto-masked.

PostHog
PostHog · Community
Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Needs Confirmation · 64/100Policy : confirmer
Surface agent
Tout agent MCP/CLI
Type
Knowledge
Installation
Single
Confiance
Confiance : New
Point d'entrée
Asset
Commande CLI universelle
npx tokrepo install 7398300f-ae4a-47af-8fd6-b9b986d7ca7a
Introduction

PostHog Session Replay records user interactions in your app — clicks, scrolls, console logs, network requests — playable as video. When a user reports 'the AI gave wrong answer', you replay their full session, see the prompt they typed, the model's reply, and what they did next. Best for: support and product teams debugging AI feature usability. Works with: web (JS SDK), iOS, Android, React Native. Setup time: 5 minutes.


Enable session replay

import posthog from "posthog-js";

posthog.init("phc_...", {
  api_host: "https://us.posthog.com",
  session_recording: {
    maskAllInputs: false,    // record what users type (mask in PII fields)
    maskTextSelector: ".pii", // anything with class="pii" is masked
    recordCrossOriginIframes: true,
    blockClass: "no-record",  // anything with class="no-record" is blocked
  },
});

posthog.identify("user_42", { plan: "pro" });

Capture LLM-specific context

// Annotate the recording with LLM events for richer playback timeline
posthog.capture("llm_call_started", {
  model: "claude-3-5-sonnet",
  prompt_length: 1234,
});

const response = await client.chat.completions.create(...);

posthog.capture("llm_call_completed", {
  model: "claude-3-5-sonnet",
  latency_ms: 1830,
  tokens: 450,
  user_satisfied: null,  // updated when user reacts
});

Filter recordings by AI events

PostHog → Session Replays → Filter:

  • Has event: llm_call_completed where model = claude-3-5-sonnet
  • And: error occurred within 30s after
  • And: user did NOT click positive feedback button

→ A queue of broken-experience replays for triage.

Privacy-first defaults

  • Password / credit-card / email fields auto-masked
  • Custom mask via maskTextSelector / data-private attribute
  • Block entire elements via blockClass
  • Cookie banner consent integration (recordings only start after consent)

What you'll catch

  • Users abandoning your AI chat after 30s of typing
  • Users reading the AI response then immediately searching elsewhere (signal: bad answer)
  • Crashes on specific browsers/OSes
  • Console errors that don't surface in your error tracker

FAQ

Q: Does session replay slow down my site? A: Negligible — recording happens in a Web Worker, payloads are gzipped and sent in batches. Typical overhead is <50ms on first paint and <2KB/min in network usage.

Q: Can users opt out? A: Yes — call posthog.opt_out_capturing() from your settings page or after a cookie banner decline. PostHog also respects DNT headers when configured.

Q: How long are recordings kept? A: Free tier 1 month, paid plans up to 1 year. Self-hosted is configurable. For long retention without cost, export recordings periodically via the API.


Quick Use

  1. posthog.init(...) with session_recording: { maskAllInputs: false }
  2. Add class="pii" to sensitive fields you want masked
  3. PostHog dashboard → Session Replays — filter by event / user / device

Intro

PostHog Session Replay records user interactions in your app — clicks, scrolls, console logs, network requests — playable as video. When a user reports 'the AI gave wrong answer', you replay their full session, see the prompt they typed, the model's reply, and what they did next. Best for: support and product teams debugging AI feature usability. Works with: web (JS SDK), iOS, Android, React Native. Setup time: 5 minutes.


Enable session replay

import posthog from "posthog-js";

posthog.init("phc_...", {
  api_host: "https://us.posthog.com",
  session_recording: {
    maskAllInputs: false,    // record what users type (mask in PII fields)
    maskTextSelector: ".pii", // anything with class="pii" is masked
    recordCrossOriginIframes: true,
    blockClass: "no-record",  // anything with class="no-record" is blocked
  },
});

posthog.identify("user_42", { plan: "pro" });

Capture LLM-specific context

// Annotate the recording with LLM events for richer playback timeline
posthog.capture("llm_call_started", {
  model: "claude-3-5-sonnet",
  prompt_length: 1234,
});

const response = await client.chat.completions.create(...);

posthog.capture("llm_call_completed", {
  model: "claude-3-5-sonnet",
  latency_ms: 1830,
  tokens: 450,
  user_satisfied: null,  // updated when user reacts
});

Filter recordings by AI events

PostHog → Session Replays → Filter:

  • Has event: llm_call_completed where model = claude-3-5-sonnet
  • And: error occurred within 30s after
  • And: user did NOT click positive feedback button

→ A queue of broken-experience replays for triage.

Privacy-first defaults

  • Password / credit-card / email fields auto-masked
  • Custom mask via maskTextSelector / data-private attribute
  • Block entire elements via blockClass
  • Cookie banner consent integration (recordings only start after consent)

What you'll catch

  • Users abandoning your AI chat after 30s of typing
  • Users reading the AI response then immediately searching elsewhere (signal: bad answer)
  • Crashes on specific browsers/OSes
  • Console errors that don't surface in your error tracker

FAQ

Q: Does session replay slow down my site? A: Negligible — recording happens in a Web Worker, payloads are gzipped and sent in batches. Typical overhead is <50ms on first paint and <2KB/min in network usage.

Q: Can users opt out? A: Yes — call posthog.opt_out_capturing() from your settings page or after a cookie banner decline. PostHog also respects DNT headers when configured.

Q: How long are recordings kept? A: Free tier 1 month, paid plans up to 1 year. Self-hosted is configurable. For long retention without cost, export recordings periodically via the API.


Source & Thanks

Built by PostHog. Licensed under MIT.

PostHog/posthog-js — ⭐ 1,500+

🙏

Source et remerciements

Built by PostHog. Licensed under MIT.

PostHog/posthog-js — ⭐ 1,500+

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires