원클릭으로
posthog-cli-queries
// Use when querying this project's PostHog data from the terminal, including recent events, event breakdowns, active-user metrics, and dashboard metadata or cached insight results.
// Use when querying this project's PostHog data from the terminal, including recent events, event breakdowns, active-user metrics, and dashboard metadata or cached insight results.
| name | posthog-cli-queries |
| description | Use when querying this project's PostHog data from the terminal, including recent events, event breakdowns, active-user metrics, and dashboard metadata or cached insight results. |
Query this project's PostHog data from the terminal without guessing command syntax.
posthog-cli must be installed and authenticatedquery:read~/.posthog/credentials.json292804 on https://us.posthog.com, but scripts read the active local credentials instead of hardcoding valuesposthog-cli exp query run 'SELECT 1 AS ok'
posthog-cli exp query run '<hogql>'Shell quoting rule:
$app_version or $os, otherwise the shell may expand them before the CLI sees the queryRecent events:
posthog-cli exp query run 'SELECT event, timestamp FROM events ORDER BY timestamp DESC LIMIT 20'
Top events in the last 7 days:
posthog-cli exp query run 'SELECT event, count() AS c FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY event ORDER BY c DESC LIMIT 15'
Top pageview pages in the last 7 days:
posthog-cli exp query run "SELECT properties.page_name AS page_name, count() AS c FROM events WHERE event = 'pageview' AND timestamp > now() - INTERVAL 7 DAY GROUP BY page_name ORDER BY c DESC LIMIT 15"
Top click targets in the last 7 days:
posthog-cli exp query run "SELECT properties.element_name AS element_name, count() AS c FROM events WHERE event = 'click' AND timestamp > now() - INTERVAL 7 DAY GROUP BY element_name ORDER BY c DESC LIMIT 15"
Recent app versions from events:
posthog-cli exp query run 'SELECT properties.$app_version AS app_version, count() AS c FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY app_version ORDER BY c DESC LIMIT 20'
Recent OS breakdown:
posthog-cli exp query run 'SELECT properties.$os AS os, count(DISTINCT person_id) AS users FROM events WHERE timestamp > now() - INTERVAL 7 DAY GROUP BY os ORDER BY users DESC LIMIT 20'
Hourly volume in the last 24 hours:
posthog-cli exp query run 'SELECT toStartOfHour(timestamp) AS hour, count() AS c FROM events WHERE timestamp > now() - INTERVAL 24 HOUR GROUP BY hour ORDER BY hour DESC LIMIT 24'
List dashboards:
bash .agents/skills/posthog-cli-queries/scripts/dashboard_list.sh
Fetch a dashboard as JSON:
bash .agents/skills/posthog-cli-queries/scripts/dashboard_fetch.sh 1075953
Fetch a dashboard summary:
bash .agents/skills/posthog-cli-queries/scripts/dashboard_fetch.sh 1075953 --summary
Current known dashboard:
bash .agents/skills/posthog-cli-queries/scripts/dashboard_fetch.sh 1075953 --summary
last_refresh mattersfilterTestAccounts before comparing tiles with each other$os or $app_version has a large null bucket, call out that the property coverage is incompleteapp_open and Application Opened, mention that the taxonomy is splitExtract tile names from a fetched dashboard JSON:
jq -r '.tiles[] | select(.insight != null) | [.id, .insight.id, .insight.name] | @tsv'
Show top breakdown rows from one insight result:
jq -r '.tiles[] | select(.insight.id==6334935) | .insight.result[] | [.label, .count, (.data[-1] // 0)] | @tsv'
posthog-cli exp query run says missing required scope 'query:read', fix the personal API key scopes first~/.posthog/credentials.json exists and contains host, token, and env_id