Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(replay): document how investigating-replay gets the event session id (#85159)

posthog[bot]aae37f6bc997
diff --git a/products/replay/skills/investigating-replay/SKILL.md b/products/replay/skills/investigating-replay/SKILL.md
index 37bc1eaf84e7..6879842ba300 100644
--- a/products/replay/skills/investigating-replay/SKILL.md
+++ b/products/replay/skills/investigating-replay/SKILL.md
@@ -39,11 +39,13 @@ Start with the recording to get metadata and the person's distinct ID:
```json
posthog:session-recording-get
{
- "id": "<recording_id>"
+ "id": "<session_id>"
}
```
-The response includes `distinct_id`, `person`, duration, interaction counts,
+The recording `id` and the event `$session_id` are the same value. It selects the
+recording here and the same-session events in Step 2. The response includes
+`distinct_id`, `person`, `start_time`, `end_time`, duration, interaction counts,
console error counts, and viewing status. Use the `distinct_id` to fetch
the full person profile:
@@ -56,7 +58,8 @@ posthog:persons-retrieve
### Step 2 — Query same-session events
-Get the timeline of what the user did during the session:
+Use the recording `id` from Step 1 as the `$session_id` value. Get the timeline
+of what the user did during the session:
```sql
posthog:execute-sql
@@ -91,6 +94,34 @@ ORDER BY timestamp ASC
LIMIT 100
```
+#### No rows? Recover the event session ID
+
+The recording `id` is the session ID. No rows means the session's events were
+ingested without it. Find candidates from the person's events in the recording
+window, padded by 100 seconds like the replay events query. `person_id` covers
+all of the person's distinct IDs:
+
+```sql
+posthog:execute-sql
+SELECT
+ properties.$session_id AS session_id,
+ count() AS event_count,
+ min(timestamp) AS first_seen,
+ max(timestamp) AS last_seen
+FROM events
+WHERE person_id = '<person_uuid>'
+ AND timestamp >= toDateTime('<start_time>') - INTERVAL 100 SECOND
+ AND timestamp <= toDateTime('<end_time>') + INTERVAL 100 SECOND
+ AND properties.$session_id IS NOT NULL
+GROUP BY session_id
+ORDER BY event_count DESC
+LIMIT 10
+```
+
+Continue only when one session ID clearly matches. Use it for the Step 2 and
+Step 3 queries only. The replay URL and all Replay Vision calls take the
+recording `id`.
+
### Step 3 — Check for linked error tracking issues
If the recording has console errors or exceptions, find related error tracking issues: