modeling-revenue-metrics
Skill này làm gì
Skill này xây dựng các chỉ số doanh thu định kỳ và tổng doanh thu, gồm MRR, ARR, tỷ lệ rời bỏ và giá trị vòng đời, từ dữ liệu thanh toán hoặc sự kiện doanh thu. Nó dành cho các nhóm tài chính và tăng trưởng muốn có con số doanh thu đáng tin cậy.
Khi nào nên dùng
- ✓Khi bạn muốn tính doanh thu định kỳ hằng tháng hoặc hằng năm từ dữ liệu thanh toán.
- ✓Khi bạn muốn xem tỷ lệ rời bỏ doanh thu, mở rộng hoặc giá trị vòng đời theo từng khách hàng.
- ✓Khi bạn muốn con số doanh thu đến từ các view doanh thu được quản lý của PostHog.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/data_modeling/skills/modeling-revenue-metrics/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tính doanh thu định kỳ hằng tháng và tỷ lệ rời bỏ của chúng tôi trong sáu tháng qua từ dữ liệu Stripe.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI dùng các view doanh thu được quản lý của PostHog cho một nền tảng thanh toán đã kết nối, hoặc các sự kiện doanh thu tùy chỉnh nếu không có nền tảng nào được kết nối. Sau đó, AI tính các chỉ số đã chọn và lưu chúng thành mô hình có thể tái sử dụng, để các con số luôn nhất quán.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Modeling revenue metrics
Turn payment/subscription data into durable revenue models. Read modeling-warehouse-foundations first for
the view-vs-dbt decision, the view-* workflow, and convertCurrency(); this skill is the revenue-specific
layer on top. Metric definitions live in
references/revenue-metric-definitions.md; copy-paste recipes in
references/posthog/ and references/dbt/.
Step 1 — find where revenue lives
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 when
the business runs on a billing platform. Connect via
setting-up-a-data-warehouse-source. - Custom revenue events — you send events (e.g.
purchase_completed) with a revenue property. Best when there's no supported platform or you already track revenue in-product.
If neither exists yet, use suggesting-data-imports to recommend a source. In dbt, the equivalent is
staging whichever billing tables landed in the warehouse.
Step 2 — model on the managed views, not raw tables
PostHog auto-generates a curated set of views per source. Do not re-derive revenue from raw Stripe tables — the managed views already handle deferred-revenue recognition, currency, and a stable schema.
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 examplestripe.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:
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. |
mrr |
1 / (customer, subscription) | Live snapshot of current MRR — not a time series. |
customer |
1 / customer | dim_customer: email, country, cohort, metadata. |
subscription |
1 / subscription | Subscription state for churn/expansion logic. |
charge |
1 / charge | Raw charges; prefer revenue_item unless you specifically need charges. |
product |
1 / product | Product dimension. |
Key revenue_item columns: amount (already converted to the project base currency), currency (that
base currency), original_amount / original_currency (as charged), is_recurring, customer_id,
subscription_id, product_id, group_0_key…group_4_key (B2B account keys), timestamp.
Rules before you model (revenue gotchas)
- MRR is empty without a subscription config. For event-based revenue, MRR only populates when a subscription property is configured. Empty MRR + populated gross revenue is expected behaviour, not a bug — say so instead of "fixing" it.
- **The
mrrmanag
Câu hỏi thường gặp
Tôi có cần Stripe không?
Hiện tại Stripe được hỗ trợ như một nguồn thanh toán. Nếu không có nền tảng được hỗ trợ, bạn có thể gửi doanh thu dưới dạng sự kiện tùy chỉnh.
Doanh thu có nên tính từ các bảng thanh toán thô không?
Không. Các view được quản lý đã xử lý việc ghi nhận doanh thu và tiền tệ, nên skill dùng chúng thay vì các bảng thô.
Skill có thể tính những chỉ số doanh thu nào?
Nó bao gồm doanh thu định kỳ như MRR và ARR, doanh thu mới, mở rộng và rời bỏ, doanh thu trung bình trên mỗi người dùng và giá trị vòng đời.
Chi tiết
Mô tả gốc của tác giả
Build reusable revenue models — MRR, ARR, gross revenue, new/expansion/contraction/churn, ARPU, LTV, and per-customer/per-account revenue — on either PostHog data-warehouse views (HogQL) or an external dbt project. Use when the user wants to model, define, or compute recurring revenue, monthly/annual recurring revenue, 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_view views (revenue_item, mrr, customer, subscription, charge, product) fed by Stripe or custom revenue event
repo: PostHog/posthog
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6852
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
gitcrawl
394kCho phép agent của bạn tìm trong kho lưu trữ issue và pull request GitHub, gom các mục trùng lặp và kiểm tra trạng thái hiện tại trên GitHub.
slacrawl
394kCho phép agent của bạn tìm và đếm tin nhắn trong kho lưu trữ Slack cục bộ, kiểm tra kho đó mới đến mức nào và làm mới khi cần.
goplaces
394kGiúp agent của bạn tìm địa điểm, lấy chi tiết và đánh giá, và xác định tên địa điểm bằng Google Places, với đầu ra JSON cho script.