feat(workflows): bill and quota-limit push sends
Problem
Workflow push sends were billed as generic fetch invocations and couldn't be limited at all — the whole push billing/quota lifecycle was built for email and skipped push.
The published pricing (posthog.com/docs/workflows) gives push its own column at roughly half of email at every tier:
| Tier (starting at) | Email unit charge | Push unit charge |
|---|---|---|
| 10,000 | $0.003 | $0.0015 |
| 50,000 | $0.0018 | $0.0009 |
| 100,000 | $0.001 | $0.00045 |
| 1,000,000 | $0.0005 | $0.0003 |
| 10,000,000 | $0.000375 | $0.00015 |
| 100,000,000 | $0.00025 | $0.000075 |
Two gaps blocked that:
- Emit:
function_pushactions ran through the genericHogFunctionHandler(billing type'fetch'), so every push send emittedbillable_invocationwithmetric_kind: 'fetch'. The usage report'sworkflow_push_sent_in_periodquery filters onmetric_kind = 'push'— so it was always 0, and push was indistinguishable from generic invocations. - Quota/surfacing: push had no
QuotaResource, no send-time enforcement, and was invisible in every billing/usage surface. Email is a first-class resource enforced both in the quota cron and at send time; push (and SMS) were neither.
Changes
Two commits, mirroring how email already works end to end.
1. Emit a distinct push billing kind. Give function_push its own HogFunctionHandler with a 'push' billing type, so it emits billable_invocation with metric_kind: 'push' — exactly what the usage report already reads.
- function_push: hogFunctionHandler,
+ function_push: hogFunctionPushHandler,
2. Quota-limit push and surface its usage. Add a WORKFLOW_PUSH quota resource mirroring WORKFLOW_EMAILS across the stack:
ee/billing/quota_limiting.py—QuotaResourceenum,OVERAGE_BUFFER,UsageCounters, and the real-time usage build.posthog/models/organization.py+ee/billing/billing_manager.py—workflow_pushonOrganizationUsageInfoand the usage-summary mapping.nodejs/.../hogflow-quota-limiting.ts— send-time check: afunction_pushflow is blocked when the team is push quota-limited.- Surfacing: push option in the Max billing tool (
read_billing_tool) and the frontend billing spend dropdown (billing/constants.ts).
[!NOTE] Free tier is per-channel, not pooled. Each billable channel is its own
QuotaResourcewith its own Redis key, usage counter, and limit (email and generic destinations are already separate; SMS, like push before this, has none). So push gets its ownWORKFLOW_PUSHwith its own limit — no shared-bucket decision needed on our side.
[!IMPORTANT] Enforcement safely no-ops until the billing service defines a push limit. A
Nonelimit is never over-limit (quota_limiting.py), so this can ship ahead of the billing-side config and lights up automatically once the push allocation is set there. The per-unit rates live in the billing service (separate repo); this PR only makes the usage signal distinguishable and limitable.
[!NOTE] SMS has the identical gap (bills as
'fetch', no quota resource) — left as-is here since there's no confirmed SMS rate to target. Flagging, not silently changing.
How did you test this code?
- nodejs quota check (
hogflow-quota-limiting.test.ts): added a push case asserting afunction_pushflow is blocked when the team is push quota-limited (mirrors the email case — catches exactly the regression this enforcement introduces), and updated the resource-count assertions. Ran locally: 11/11 pass (this suite is fully mocked, no hub needed). - nodejs emit (
hog_function.test.ts): parameterized the billing-kind test over fetch/email/push, asserting a completed invocation emits onebillable_invocationcarrying the handler's kind. - Python (
test_quota_limiting.py): addedworkflow_pushto the fullUsageCountersfixture so the TypedDict stays complete under mypy. The usage-report read side for push is already covered bytest_usage_report.py.
Update (QA): the two things this sandbox couldn't cover were later validated end-to-end on a local hub-backed env (see the two items below). Beyond that, I verified statically: ruff format/ruff check, prettier/eslint, and oxfmt/oxlint are clean on all changed files, and tsc --noEmit reports no errors in any changed nodejs file. CI runs the full matrix — that's the backstop.
[!NOTE] Validated in QA (the previously-untested executor path). On a local hub-backed env, triggering a real
function_pushaction emittedbillable_invocationwithmetric_kind: 'push'— a clean before/after: the same action billed asfetchacross its historical runs andpushon the new run (email billedquota_limitedmetric emitted, zero actions executed). Both confirm the two gaps this PR closes.
Automatic notifications
- [ ] Publish to changelog?
- [ ] Alert Sales and Marketing teams?
Docs update
No docs change — the pricing page already documents the push rate; this aligns the emitted usage and quota plumbing with it.
🤖 Agent context
Autonomy: Human-driven (agent-assisted). Directed by the requester (session owner), assigned as DRI.
Authored with Claude Code, following the merged push metrics (#71078) and observability (#70913) work. Started as the emit-only fix, then a parity audit (four parallel exploration agents across send-path, delivery-status, frontend, and ops/lifecycle) surfaced that quota limiting and billing surfaces were the other half of "push billing." Confirmed from the code that each channel is quota-limited independently (per-resource, not pooled), which removed the only open policy question and made it safe to fold quota + surfacing into this PR rather than a separate one. Invoked /writing-tests before the test changes — which is why the emit test was parameterized and the push quota case mirrors the email one rather than being a redundant clone.
Deferred (flagged for a reviewer to sequence): the per-unit rate config in the billing service, and the equivalent SMS wiring.
🤖 Generated with Claude Code
| Failed Test | Failure Summary | Logs |
|---|---|---|
MemoryCachedKeyStore custom options should expire cached items after ttlMs |
A mock function was called when it was expected not to be called. | Logs ↗︎ |
🤖 CI report
⚠️ Bundle size — 🔺 +434 B (+0.0%)
Uncompressed size of every built .js bundle, compared against the base branch.
Total: 64.81 MiB · 🔺 +434 B (+0.0%)
No file changed by more than 1000 B.
Posted automatically by build-bundle-size-report · uncompressed bytes from dist-report
✅ Eager graph — within budget
How much code each root ships on the eager path — downloaded and parsed before the surface is interactive. Measured from the esbuild output chunks (post-tree-shake, static imports only); lazy import() / React.lazy chunks are not counted.
| Root | Eager (shipped) | Δ vs base | Budget |
|---|---|---|---|
entry (logged-out pages, app bootstrap)src/index.tsx |
1.23 MiB · 22 files | 🔺 +125 B (+0.0%) | ███░░░░░░░ 28.6% of 4.29 MiB |
authenticated shell (every logged-in page)src/scenes/AuthenticatedShell.tsx |
8.15 MiB · 2,987 files | 🔺 +429 B (+0.0%) | █████████░ 88.1% of 9.25 MiB |
🟢 node_modules/monaco-editor/ stays out of src/index.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 [object Object] stays out of src/index.tsx
🟢 node_modules/monaco-editor/ stays out of src/scenes/AuthenticatedShell.tsx
🟢 src/lib/components/ActivityLog/describers stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
🟢 [object Object] stays out of src/scenes/AuthenticatedShell.tsx
Largest files eagerly shipped from src/index.tsx
| Size | File |
|---|---|
| 126.8 KiB | ../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js |
| 24.6 KiB | ../node_modules/.pnpm/[email protected]/node_modules/buffer/index.js |
| 6.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/react/cjs/react.production.min.js |
| 4.5 KiB | ../node_modules/.pnpm/@[email protected]/node_modules/@jspm/core/nodelibs/browser/process.js |
| 3.9 KiB | ../node_modules/.pnpm/[email protected]/node_modules/scheduler/cjs/scheduler.production.min.js |
| 1.4 KiB | ../node_modules/.pnpm/[email protected]/node_modules/base64-js/index.js |
| 1.3 KiB | src/RootErrorBoundary.tsx |
| 912 B | ../node_modules/.pnpm/[email protected]/node_modules/ieee754/index.js |
| 789 B | src/scenes/ChunkLoadErrorBoundary.tsx |
| 762 B | src/index.tsx |
Largest files eagerly shipped from src/scenes/AuthenticatedShell.tsx
| Size | File |
|---|---|
| 281.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/rrweb.js |
| 267.7 KiB | ../node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@posthog/icons/dist/posthog-icons.es.js |
| 235.5 KiB | src/taxonomy/core-filter-definitions-by-group.json |
| 223.2 KiB | ../node_modules/.pnpm/[email protected]/node_modules/posthog-js/dist/module.js |
| 164.0 KiB | src/queries/validators.js |
| 154.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/re2js/build/index.esm.js |
| 126.8 KiB | ../node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom.production.min.js |
| 105.8 KiB | src/lib/api.ts |
| 93.3 KiB | ../node_modules/.pnpm/[email protected]/node_modules/prosemirror-view/dist/index.js |
| 93.3 KiB | ../packages/quill/packages/quill/dist/index.js |
Posted automatically by check-eager-graph · sizes are eager output bytes (shipped, post-tree-shake) from the esbuild metafile · part of #32479
✅ Dist folder size — 🔺 +58.1 KiB (+0.0%)
Total size of the built frontend/dist folder (all assets), compared against the base branch.
Total: 1333.82 MiB · 🔺 +58.1 KiB (+0.0%)
🦔 Hogbox preview · ✅ ready
▶ Open the preview
| 🔑 Login | [email protected] / 12345678 (demo data) |
| 🧩 Running | this PR's backend and frontend, on the PostHog :master base |
| 🔗 Link | stable across rebuilds — a re-push swaps the box underneath, the URL stays |
| 🔒 Access | tailnet only (PostHog VPN) |
| 🛠️ Admin | inspect & debug state in hogland |
| 💤 Idle | sleeps after ~30 min idle (snapshot to S3, zero node cost) and wakes on your next visit in ~30s, behind a brief "waking up" screen |
commit f619861 · box box-255759cb7c63 · ready in 748s (push → usable) · build log · rebuilds on every push, torn down on close
👀 Auto-assigned reviewers
These soft owners were skipped because they only have minor changes here. Nothing blocks merge, so self-assign if you'd like a look:
@PostHog/team-self-driving(ee/owners.yaml)
Soft owners come from each directory's owners.yaml and each product's product.yaml (resolved nearest-file-wins). The locator after each owner is the file that decided it. Generated files and lockfiles are ignored when deciding ownership.
Reviews (1): Last reviewed commit: "Merge branch 'master' into claude/push-b..." | Re-trigger Greptile
👋 Visual changes detected for this PR.
Review and approve in PostHog Visual Review
If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.