: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(data-modeling): correct managed revenue view names in modeling-revenue-metrics (#113420)
Anna Szell14c4826dfa98
diff --git a/products/data_modeling/skills/modeling-revenue-metrics/SKILL.md b/products/data_modeling/skills/modeling-revenue-metrics/SKILL.mdindex c089dabd6472..bd9d9710b82e 100644--- a/products/data_modeling/skills/modeling-revenue-metrics/SKILL.md+++ b/products/data_modeling/skills/modeling-revenue-metrics/SKILL.md@@ -5,7 +5,7 @@ description: >per-customer/per-account revenue — on either PostHog data-warehouse views (HogQL) or an external dbtproject. Use when the user wants to model, define, or compute recurring revenue, monthly/annual recurringrevenue, churn or retention of revenue, lifetime value, average revenue per user, or revenue by customer,- cohort, product, or currency. On PostHog, build on the managed revenue_analytics_* views (revenue_item,+ cohort, product, or currency. On PostHog, build on the managed *_revenue_view views (revenue_item,mrr, customer, subscription, charge, product) fed by Stripe or custom revenue events — not raw Stripetables — and normalize money with convertCurrency(). In dbt, stage the payment source and computefct_mrr / fct_revenue_item / dim_customer marts with tests. Covers picking the right source, the@@ -23,7 +23,7 @@ layer on top. Metric definitions live in## Step 1 — find where revenue lives-Revenue reaches PostHog two ways; both feed the same **managed `revenue_analytics_*` views**:+Revenue reaches PostHog two ways; both feed the same **managed revenue views**:- **A payment platform as a warehouse source** — Stripe today (Chargebee/Polar/RevenueCat coming). Best whenthe business runs on a billing platform. Connect via `setting-up-a-data-warehouse-source`.@@ -38,13 +38,25 @@ staging whichever billing tables landed in the warehouse.PostHog auto-generates a curated set of views per source. **Do not re-derive revenue from raw Stripetables** — the managed views already handle deferred-revenue recognition, currency, and a stable schema.-Discover the exact names (they're prefixed by source, e.g. `stripe.<prefix>.…`, plus a cross-source-`revenue_analytics.all.…`):+Each source gets its own views. There is no cross-source view. Names depend on the source type:++- Warehouse source: `<source>.<prefix>.<kind>_revenue_view`, for example `stripe.prod.mrr_revenue_view`. The+ `<prefix>.` part is absent when the source has no prefix.+- Custom revenue events: `revenue_analytics.events.<event_name>.<kind>_events_revenue_view`, where every+ non-alphanumeric character in the event name becomes `_`.++`<kind>` is one of the managed views in the table below. Discover the exact names. Do not search for+`revenue_analytics`, because it does not match warehouse source views:```sql-SELECT table_name FROM system.information_schema.tables WHERE table_name ILIKE '%revenue_analytics%'+SELECT table_name FROM system.information_schema.tables+WHERE position(table_name, 'revenue_view') > 0 ORDER BY table_name```+If this returns nothing, the project has no revenue source configured yet. Check the governed `mrr` metric+(`metric-list`) or discover warehouse billing tables, and read their columns before modeling. Do not guess+view names.+| Managed view | Grain | Use for || ------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------- || `revenue_item` (**start here**) | 1 / invoice line item | Gross revenue, monthly recurring revenue, revenue by product/customer/period. Implements deferred revenue + currency. |@@ -73,7 +85,7 @@ base currency), `original_amount` / `original_currency` (as charged), `is_recurr`posthog_person_distinct_id` metadata on the Stripe customer (or the person join). Without it, revenue iscustomer-level only.5. **Don't build on the Revenue dashboard** — it's being retired (~2026-06-30). Model against the- `revenue_analytics_*` views and the person/group revenue properties.+ managed revenue views and the person/group revenue properties.6. **Exclude test accounts.** Confirm `filter_test_accounts` behaviour so QA/internal charges don't inflaterevenue.diff --git a/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/mrr_and_arr.sql b/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/mrr_and_arr.sqlindex 06f1454a396e..c9e4168c8be4 100644--- a/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/mrr_and_arr.sql+++ b/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/mrr_and_arr.sql@@ -2,8 +2,8 @@-- The managed `mrr` view is only a live snapshot, so derive the time series from recurring revenue_item rows.---- Before creating the view, replace <revenue_item_view> with the real name for your project:--- SELECT table_name FROM system.information_schema.tables WHERE table_name ILIKE '%revenue_item%';--- e.g. `revenue_analytics.all.revenue_item_revenue_view` (cross-source) or `stripe.<prefix>.…`.+-- SELECT table_name FROM system.information_schema.tables WHERE position(table_name, 'revenue_item') > 0;+-- e.g. `stripe.<prefix>.revenue_item_revenue_view` or `revenue_analytics.events.<event>.revenue_item_events_revenue_view`.---- `amount` is already in the project base currency. Every output column is aliased (required by view-create).SELECTdiff --git a/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/revenue_by_customer.sql b/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/revenue_by_customer.sqlindex 6ced25d32eef..6215ca73c99a 100644--- a/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/revenue_by_customer.sql+++ b/products/data_modeling/skills/modeling-revenue-metrics/references/posthog/revenue_by_customer.sql@@ -3,7 +3,7 @@-- to a chosen reporting currency (here EUR) from the ORIGINAL amount as charged.---- Replace the two managed view names with the discovered ones:--- SELECT table_name FROM system.information_schema.tables WHERE table_name ILIKE '%revenue_analytics%';+-- SELECT table_name FROM system.information_schema.tables WHERE position(table_name, 'revenue_view') > 0;SELECTc.id AS customer_id,any(c.name) AS customer_name,