AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

querying-posthog-data

Explains how to query PostHog data, defaulting to typed runners for supported product analytics. Read it before you write HogQL/SQL. Also read it before you call execute-sql against PostHog. Use it to find or aggregate PostHog entities. These entities include insights, dashboards, cohorts, feature flags, experiments, surveys, hog flows, warehouse data, and persons. Use it for trends, funnels, retention, lifecycle, paths, stickiness, web analytics, error tracking, logs, sessions, and LLM traces. Before you calculate a governed business or telemetry measure, check system.information_schema.metrics for an approved definition. Examples include MRR, activation, billable usage, active organizations, and failure rates. Use the approved definition before you derive a measure from raw events or use a typed domain tool. It also covers HogQL differences, system table schemas, functions, query examples, and schema discovery.

Original source
posthog
License
MIT
Pinned revision
cac7c80a9e5b73484d18eda1bffb47297c938e0c

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

Ask your assistant

Use Agentic Memory skills to read posthog--querying-posthog-data at revision cac7c80a9e5b73484d18eda1bffb47297c938e0c, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 65

references/example-session-replay.md

Session replay (listing recordings with activity filters)

SELECT
    s.session_id,
    any(s.team_id),
    any(s.distinct_id),
    min(s.min_first_timestamp) AS start_time,
    max(s.max_last_timestamp) AS end_time,
    dateDiff('SECOND', start_time, end_time) AS duration,
    argMinMerge(s.first_url) AS first_url,
    sum(s.click_count) AS click_count,
    sum(s.keypress_count) AS keypress_count,
    sum(s.mouse_activity_count) AS mouse_activity_count,
    divide(sum(s.active_milliseconds), 1000) AS active_seconds,
    greatest(minus(duration, active_seconds), 0) AS inactive_seconds,
    sum(s.console_log_count) AS console_log_count,
    sum(s.console_warn_count) AS console_warn_count,
    sum(s.console_error_count) AS console_error_count,
    max(s.retention_period_days) AS retention_period_days,
    plus(dateTrunc('DAY', start_time), toIntervalDay(coalesce(retention_period_days, 30))) AS expiry_time,
    date_diff('DAY', toDateTime('2026-10-30 12:02:54.932410'), expiry_time) AS recording_ttl,
    greaterOrEquals(max(s._timestamp), toDateTime('2026-10-30 11:57:54.931874')) AS ongoing,
    round(least(greatest(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 0), 100), 2) AS activity_score,
    coalesce(max(s.surfacing_score), 0.36) AS surfacing_score
FROM
    raw_session_replay_events AS s
WHERE
    and(greaterOrEquals(s.min_first_timestamp, toDateTime('2026-10-27 00:00:00.000000')), lessOrEquals(s.min_first_timestamp, toDateTime('2026-10-30 12:02:54.932041')))
GROUP BY
    session_id
HAVING
    and(greaterOrEquals(expiry_time, toDateTime('2026-10-30 12:02:54.932266')), equals(max(s.is_deleted), 0), greater(active_seconds, 5.0))
ORDER BY
    start_time DESC,
    session_id DESC
LIMIT 50000