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-vision): type the replay_scanners id as a uuid and document the join (#106636)

Tue Haulundb230a3b02463
diff --git a/posthog/hogql/database/schema/system.py b/posthog/hogql/database/schema/system.py
index f6c3a593a99d..903c6ea5e84b 100644
--- a/posthog/hogql/database/schema/system.py
+++ b/posthog/hogql/database/schema/system.py
@@ -1266,7 +1266,10 @@ replay_scanners: PostgresTable = PostgresTable(
predicates=[parse_expr("origin = 'configured'")],
description="Replay Vision scanners: standing LLM probes over session recordings; one row per saved scanner.",
fields={
- "id": StringDatabaseField(name="id", description="Scanner UUID."),
+ "id": UUIDDatabaseField(
+ name="id",
+ description="Scanner UUID. Cast with toString(id) to join on a string property such as scanner_id.",
+ ),
"team_id": IntegerDatabaseField(name="team_id"),
"origin": StringDatabaseField(name="origin", hidden=True),
"name": StringDatabaseField(name="name", description="Scanner name, unique within the project."),
diff --git a/products/posthog_ai/skills/querying-posthog-data/references/models-replay-vision.md.j2 b/products/posthog_ai/skills/querying-posthog-data/references/models-replay-vision.md.j2
index d68f143a75f9..9e35907f8b3d 100644
--- a/products/posthog_ai/skills/querying-posthog-data/references/models-replay-vision.md.j2
+++ b/products/posthog_ai/skills/querying-posthog-data/references/models-replay-vision.md.j2
@@ -17,6 +17,17 @@ One-off inline scans are not listed.
- `$recording_observed` events carry the scanner as `properties.scanner_id` and the recording as `properties.session_id`
+To join scanners to their observations, cast the UUID `id`, since `properties.scanner_id` is a string:
+
+```sql
+SELECT s.name, count() AS observations
+FROM events e
+JOIN system.replay_scanners s ON toString(s.id) = e.properties.scanner_id
+WHERE e.event = '$recording_observed' AND e.timestamp > now() - INTERVAL 7 DAY
+GROUP BY s.name
+ORDER BY observations DESC
+```
+
### Important Notes
- Alerts and backfills are not system tables, because their API checks permissions a system table cannot. Read them with `vision-alerts-list` and `vision-scanners-backfills-list`.