{"skill":{"slug":"posthog-query","displayName":"PostHog Query","summary":"Run SQL queries against PostHog product analytics data using the PostHog CLI. Use when checking pageviews, event counts, trends, or any analytics data from P...","description":"---\nname: posthog-query\ndescription: Run SQL queries against PostHog product analytics data using the PostHog CLI. Use when checking pageviews, event counts, trends, or any analytics data from PostHog.\nmetadata: {\"openclaw\": {\"emoji\": \"🦔\", \"requires\": {\"bins\": [\"posthog-cli\"]}, \"install\": \"npm install -g posthog-cli\"}}\n---\n\n# PostHog Query Skill\n\nRun HogQL (ClickHouse-compatible SQL) queries against PostHog via the CLI.\n\n## One-Time Setup\n\n```bash\nposthog-cli login  # authenticate interactively; stores token in ~/.posthog/credentials.json\n```\n\nRequires API key scope: `query:read`.\n\n## Command\n\n```bash\nposthog-cli exp query run \"<SQL>\"\n```\n\nResults are printed as JSON lines to stdout. The CLI reads auth from `~/.posthog/credentials.json` (set up via `posthog-cli login`).\n\n## Property Access Syntax\n\nUse bracket notation for event properties — dot notation with quoted keys does not work:\n\n```sql\n-- ✅ Correct\nproperties['$current_url']\nproperties['$browser']\n\n-- ❌ Wrong\nproperties.'$current_url'\n```\n\n## Examples\n\n**Count all pageviews:**\n```bash\nposthog-cli exp query run \"SELECT count() as pageviews FROM events WHERE event = '\\$pageview'\"\n```\n\n**Filter by URL:**\n```bash\nposthog-cli exp query run \"SELECT count() as pageviews FROM events WHERE event = '\\$pageview' AND properties['\\$current_url'] LIKE 'https://example.com/%'\"\n```\n\n**7-day daily trend:**\n```bash\nposthog-cli exp query run \"SELECT toDate(timestamp) as date, count() as pageviews FROM events WHERE event = '\\$pageview' AND timestamp >= now() - INTERVAL 7 DAY GROUP BY date ORDER BY date\"\n```\n\n**Recent events:**\n```bash\nposthog-cli exp query run \"SELECT event, timestamp FROM events ORDER BY timestamp DESC LIMIT 10\"\n```\n\n## Other Subcommands\n\n- `posthog-cli exp query editor` — interactive query editor\n- `posthog-cli exp query check \"<SQL>\"` — syntax/type check without running\n- Append `--debug` to `run` to get the full JSON response (columns, types, cache info)\n\n## Notes\n\n- HogQL is ClickHouse-compatible SQL — standard ClickHouse functions apply\n- Shell-escape `$` in event names: `'\\$pageview'` or use double quotes carefully\n- The `--debug` flag returns full metadata including column types and cache status\n","topics":["SQL"],"tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":247,"installsAllTime":9,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1771542362135,"updatedAt":1778491585715},"latestVersion":{"version":"1.0.0","createdAt":1771542362135,"changelog":"Initial release: run HogQL queries against PostHog via the posthog-cli","license":null},"metadata":{"setup":[],"os":null,"systems":null},"owner":{"handle":"quinlanjager","userId":"s17237q7p7t3b3fsepgqbgxq9n884g5a","displayName":"Quinlan Jager","image":"https://avatars.githubusercontent.com/u/31021631?v=4"},"moderation":null}