posthog-summary
GitHub基于 PostHog MCP 集成,通过 HogQL 查询获取指定时间窗口的产品分析指标,生成包含当前与上期对比的指标摘要报告,支持按周/月等周期自动汇总。
Trigger Scenarios
Install
npx skills add Tracer-Cloud/opensre --skill posthog-summary -g -y
SKILL.md
Frontmatter
{
"name": "posthog-summary",
"tools": [
"list_posthog_tools",
"call_posthog_tool"
],
"description": "Summarise PostHog product analytics into a per-metric team pulse. Use for PostHog usage overviews, per-metric summaries, product-analytics digests, or \"what happened this week\" reporting."
}
PostHog Summary
PostHog product-analytics reporting for chat delivery. Produce a per-metric pulse over a window — what moved, why it matters — not a raw dashboard export. Single source (PostHog MCP); finish here, then optionally suggest a multi-source follow-up.
Requires the PostHog MCP integration (posthog_mcp). The REST-only
posthog integration cannot serve this skill.
1. Discover
list_posthog_tools once with name_filter: "insights dashboard sql events" to
find the query surface. Then call read-data-schema (or the equivalent schema
tool) BEFORE any aggregation query and only reference events and properties it
confirms exist. Do not reference a property (e.g. properties.$mcp_error)
without seeing it in the schema first — HogQL rejects queries against unknown
properties. To pull metric data, use call_posthog_tool with
tool_name: "execute-sql" and SQL as a top-level string:
{
"tool_name": "execute-sql",
"arguments": { "query": "SELECT count() FROM events WHERE event = '$pageview'" }
}
Never nest the SQL ({"query": {"query": "SELECT …"}}) — PostHog rejects that
with parameter "query" must be of type string. Use insight/dashboard tools
when the user names a specific dashboard.
2. Fetch metrics
Map user words to windows:
- 24h — "today", "overnight", morning report
- 7d — "this week", default weekly report
- 30d — "this month", monthly rollup
Run one small HogQL query per metric — do NOT combine multiple metrics into a
single aggregated statement, and never cross-join events against synthetic
"window" rows. That combined shape is the most common cause of PostHog's
unknown error running this query. Return only aggregate numbers (two
columns: current / previous) — never event-level rows. Compute the two windows
with an explicit conditional aggregate over a single time filter, e.g.:
SELECT
countIf(timestamp >= now() - INTERVAL 7 DAY) AS current,
countIf(timestamp >= now() - INTERVAL 14 DAY
AND timestamp < now() - INTERVAL 7 DAY) AS previous
FROM events
WHERE event = '$pageview'
Swap event = '...' (or count(DISTINCT person_id) for active users) per
metric. If a query still fails, retry that single metric once with a simpler
SELECT count() ... WHERE timestamp >= now() - INTERVAL 7 DAY, then report the
metric as failed rather than aborting the whole report.
Default metric set when the user does not name specific metrics (restrict to events confirmed present in the schema):
- Active users (
count(DISTINCT person_id)) - Key events (
$pageview, sessions, or the project's top custom events) - New signups / new users only when schema confirms a signup event
(
user_signed_up,signed_up,signup, …). Never substituteuser_signed_in/ login /$identifyfor signup or for “signed up” retention cohorts — if signup is unverified, skip the metric and say so. - Notable custom events surfaced by the schema
3. Compute per-metric deltas
For each metric: current value, previous value, absolute change, percent change, and direction (up / down / flat). Flag a metric as notable when the percent change exceeds ~15% in either direction, or when a value hits zero unexpectedly.
4. Summarise (team pulse)
Open with I found: a one-line scope summary (window + project + metric count). Then a per-metric table:
Metric | Current | Previous | Change | % | Trend
- Trend: use up / down / flat words, never rely on colour alone.
- After the table, call out the 1-3 most notable movers with a short "why it matters" line and one clear next action when the data supports it.
- When a window returns no data, say so explicitly for that metric — never silently widen the window or invent numbers.
Traps
- HogQL time ranges are relative; state the absolute window in the report.
- Distinguish "metric returned zero" (real) from "query failed" (report the failure, do not present it as zero).
execute-sqlarguments must be{"query": "<sql string>"}. Nested{"query": {"query": "…"}}fails before any data is read — unwrap and retry once, then mark the metric failed if it still errors.- The MCP server exposes 240+ tools; narrow with
name_filterbefore calling — never dump the full listing. - One bounded query per metric group; event-level scans are expensive.
unknown error running this queryalmost always means the statement was too complex (multiple metrics combined, cross-joins, or an unverified property). Recover by splitting into one simple per-metric query, not by giving up.
Version History
- 8bfe7b1 Current 2026-08-19 21:46


