: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
feat(billing): expose Desktop compute usage breakdown (#76889)
Adam Bowker6873d35a6463
diff --git a/ee/api/quota_limits.py b/ee/api/quota_limits.pyindex cf2fa5eb1eee..107a78c0056f 100644--- a/ee/api/quota_limits.py+++ b/ee/api/quota_limits.py@@ -20,7 +20,7 @@ from rest_framework.response import Responsefrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.constants import AvailableFeature-from ee.billing.quota_limiting import QuotaResource, get_fresh_team_limited_resources+from ee.billing.quota_limiting import INFORMATIONAL_USAGE_RESOURCES, QuotaResource, get_fresh_team_limited_resourcesclass QuotaResourceLimitSerializer(serializers.Serializer):@@ -60,7 +60,14 @@ def _resource_usage(summary: dict[str, Any]) -> float | None:class QuotaLimitsResponseSerializer(serializers.Serializer):limited = serializers.DictField(child=QuotaResourceLimitSerializer(),- help_text="Per-resource limit state for every `QuotaResource` value, e.g. `ai_credits`, `posthog_code_credits`.",+ help_text=(+ "Per-resource limit state for every `QuotaResource` value, e.g. `ai_credits`, "+ "`posthog_code_credits`. Also carries the informational Desktop component resources "+ "(`posthog_code_token_credits`, `sandbox_compute_credits`, "+ "`sandbox_compute_cpu_millicore_seconds`, `sandbox_compute_memory_mib_seconds`) with "+ "usage in their native units, a null limit, and `limited` always false — they are never "+ "quota-enforced; only the combined `posthog_code_credits` is."+ ),)code_usage_billing_active = serializers.BooleanField(help_text=(@@ -102,13 +109,18 @@ class QuotaLimitsViewSet(TeamAndOrgViewSetMixin, viewsets.ViewSet):"usage": _resource_usage(summary),"limit": summary.get("limit"),}- return Response(- QuotaLimitsResponseSerializer(- {- "limited": limited,- "code_usage_billing_active": self.team.organization.is_feature_available(- AvailableFeature.POSTHOG_CODE_USAGE- ),- }- ).data- )+ for field in INFORMATIONAL_USAGE_RESOURCES:+ limited[field] = {+ "limited": False,+ "usage": _resource_usage(org_usage.get(field) or {}),+ "limit": None,+ }+ data = QuotaLimitsResponseSerializer(+ {+ "limited": limited,+ "code_usage_billing_active": self.team.organization.is_feature_available(+ AvailableFeature.POSTHOG_CODE_USAGE+ ),+ }+ ).data+ return Response(data)diff --git a/ee/api/test/test_quota_limits.py b/ee/api/test/test_quota_limits.pyindex a526ea666656..f71f0dcc3cfa 100644--- a/ee/api/test/test_quota_limits.py+++ b/ee/api/test/test_quota_limits.py@@ -11,6 +11,7 @@ from posthog.models.team import Teamfrom posthog.models.utils import generate_random_token_personal, hash_key_valuefrom ee.billing.quota_limiting import (+ INFORMATIONAL_USAGE_RESOURCES,QuotaLimitingCaches,QuotaResource,add_limited_team_tokens,@@ -94,6 +95,46 @@ class TestQuotaLimitsAPI(APIBaseTest):# Never synced: unknown, not zero.self.assertEqual(limited["events"], {"limited": False, "usage": None, "limit": None})+ def test_reports_desktop_component_usage(self) -> None:+ self.organization.usage = {+ "period": ["2026-07-01T00:00:00Z", "2026-08-01T00:00:00Z"],+ "posthog_code_credits": {"usage": 50, "todays_usage": 7, "limit": 1000},+ "posthog_code_token_credits": {"usage": 30, "todays_usage": 3, "limit": None},+ "sandbox_compute_credits": {"usage": 20, "todays_usage": 4, "limit": None},+ "sandbox_compute_cpu_millicore_seconds": {"usage": 0, "todays_usage": 0, "limit": None},+ "sandbox_compute_memory_mib_seconds": {"usage": None, "todays_usage": None, "limit": None},+ }+ self.organization.save()++ response = self.client.get(self._url())++ self.assertEqual(response.status_code, status.HTTP_200_OK)+ limited = response.json()["limited"]+ self.assertEqual(limited["posthog_code_token_credits"], {"limited": False, "usage": 33, "limit": None})+ self.assertEqual(limited["sandbox_compute_credits"], {"limited": False, "usage": 24, "limit": None})+ # Explicit zero stays zero...+ self.assertEqual(+ limited["sandbox_compute_cpu_millicore_seconds"], {"limited": False, "usage": 0, "limit": None}+ )+ # ...while never-synced stays null (unknown), never coerced to zero.+ self.assertEqual(+ limited["sandbox_compute_memory_mib_seconds"], {"limited": False, "usage": None, "limit": None}+ )++ def test_components_absent_from_org_usage_read_as_unknown(self) -> None:+ self.organization.usage = {+ "period": ["2026-07-01T00:00:00Z", "2026-08-01T00:00:00Z"],+ "posthog_code_credits": {"usage": 50, "todays_usage": 7, "limit": 1000},+ }+ self.organization.save()++ response = self.client.get(self._url())++ self.assertEqual(response.status_code, status.HTTP_200_OK)+ limited = response.json()["limited"]+ for field in INFORMATIONAL_USAGE_RESOURCES:+ self.assertEqual(limited[field], {"limited": False, "usage": None, "limit": None}, field)+def test_returns_limited_when_team_is_over_quota(self) -> None:self._set_ai_credits_limit(self.team.api_token, 9_999_999_999)@@ -181,7 +222,7 @@ class TestQuotaLimitsAPI(APIBaseTest):response = self.client.get(self._url())self.assertEqual(response.status_code, status.HTTP_200_OK)limited = response.json()["limited"]- expected_keys = {resource.value for resource in QuotaResource}+ expected_keys = {resource.value for resource in QuotaResource} | set(INFORMATIONAL_USAGE_RESOURCES)self.assertEqual(set(limited.keys()), expected_keys)self.assertTrue(limited["ai_credits"]["limited"])for resource in QuotaResource:diff --git a/services/llm-gateway/src/llm_gateway/api/usage.py b/services/llm-gateway/src/llm_gateway/api/usage.pyindex b3f5b7a32d03..17467e35a3ef 100644--- a/services/llm-gateway/src/llm_gateway/api/usage.py+++ b/services/llm-gateway/src/llm_gateway/api/usage.py@@ -41,6 +41,7 @@ class AiCreditsStatus(BaseModel):# org, resolver fail-open) — clients must not render None as $0.used_usd: float | None = Nonelimit_usd: float | None = None+ breakdown: dict[str, object] | None = Noneclass UsageResponse(BaseModel):@@ -101,7 +102,6 @@ async def get_usage(# through the same decision as the request-path throttle: clients gate on this# response, so it must never disagree with what enforcement would do.credits_exhausted = bucket_block_applies(context)-burst_status: CostLimitStatus | None = Nonesustained_status: CostLimitStatus | None = None@@ -147,6 +147,7 @@ async def get_usage(exhausted=credits_exhausted,used_usd=quota_status.used_usd,limit_usd=quota_status.limit_usd,+ breakdown=quota_status.posthog_desktop_usage if product == POSTHOG_CODE_PRODUCT else None,),is_rate_limited=burst_status.exceeded or sustained_status.exceeded or credits_exhausted,is_pro=is_pro_plan(plan_info.plan_key),diff --git a/services/llm-gateway/src/llm_gateway/services/quota_resolver.py b/services/llm-gateway/src/llm_gateway/services/quota_resolver.pyindex b0839d462b62..86ee5fb33f08 100644--- a/services/llm-gateway/src/llm_gateway/services/quota_resolver.py+++ b/services/llm-gateway/src/llm_gateway/services/quota_resolver.py@@ -18,6 +18,7 @@ paying org's users.from __future__ import annotationsimport asyncio+import hashlibimport jsonfrom dataclasses import dataclassfrom typing import TYPE_CHECKING@@ -63,6 +64,13 @@ _RETRY_DELAYS_SECONDS: tuple[float, ...] = (# (the billing product config for AI credits and `posthog_code_usage`)._USD_PER_CREDIT = 0.01+_POSTHOG_DESKTOP_COMPONENT_RESOURCES = {+ "token_credits": "posthog_code_token_credits",+ "compute_credits": "sandbox_compute_credits",+ "cpu_millicore_seconds": "sandbox_compute_cpu_millicore_seconds",+ "memory_mib_seconds": "sandbox_compute_memory_mib_seconds",+}+@dataclassclass QuotaResourceStatus:@@ -72,6 +80,7 @@ class QuotaResourceStatus:# synced numbers. None means unknown (unsynced org, fail-open) — never $0.used_usd: float | None = Nonelimit_usd: float | None = None+ posthog_desktop_usage: dict[str, object] | None = Nonedef _optional_number(value: object) -> float | None:@@ -85,6 +94,31 @@ def _credits_to_usd(credits: object) -> float | None:return None if value is None else round(value * _USD_PER_CREDIT, 2)+def _optional_integer(value: object) -> int | None:+ if isinstance(value, bool):+ return None+ if isinstance(value, int):+ return value+ if isinstance(value, float) and value.is_integer():+ return int(value)+ return None+++def _posthog_desktop_usage(data: dict[str, object]) -> dict[str, object] | None:+ limited = data.get("limited")+ if not isinstance(limited, dict):+ return None+ components: dict[str, object] = {+ output_key: _optional_integer(resource.get("usage")) if isinstance(resource, dict) else None+ for output_key, resource_key in _POSTHOG_DESKTOP_COMPONENT_RESOURCES.items()+ for resource in (limited.get(resource_key),)+ }+ if all(value is None for value in components.values()):+ return None++ return components++class _TransientUpstreamError(Exception):"""Retryable failure: a 5xx response or a network-level error."""@@ -93,8 +127,9 @@ class _PermanentUpstreamError(Exception):"""Non-retryable failure: a 4xx response — bad token, missing team, scope mismatch."""-def _redis_key(resource_key: str, team_id: int) -> str:- return f"quota:{resource_key}:team:{team_id}"+def _redis_key(resource_key: str, team_id: int, auth_header: str) -> str:+ credential_fingerprint = hashlib.sha256(auth_header.encode()).hexdigest()+ return f"quota:{resource_key}:team:{team_id}:credential:{credential_fingerprint}"def _billing_key(team_id: int) -> str:@@ -131,7 +166,7 @@ class QuotaResolver:self._cache_ttl = get_settings().quota_cache_ttlasync def get_resource_status(self, resource_key: str, team_id: int, auth_header: str) -> QuotaResourceStatus:- cached = await self._get_cached(resource_key, team_id)+ cached = await self._get_cached(resource_key, team_id, auth_header)if cached is not None:return cached@@ -157,7 +192,7 @@ class QuotaResolver:_FAIL_OPEN_CACHE_TTL_SECONDS,)- await self._set_cached(resource_key, team_id, status, ttl)+ await self._set_cached(resource_key, team_id, auth_header, status, ttl)return statusasync def _fetch_with_retry(@@ -209,13 +244,14 @@ class QuotaResolver:code_usage_billing_active=bool(data.get("code_usage_billing_active")),used_usd=_credits_to_usd(resource.get("usage")),limit_usd=_credits_to_usd(resource.get("limit")),+ posthog_desktop_usage=_posthog_desktop_usage(data) if resource_key == "posthog_code_credits" else None,), self._cache_ttl- async def _get_cached(self, resource_key: str, team_id: int) -> QuotaResourceStatus | None:+ async def _get_cached(self, resource_key: str, team_id: int, auth_header: str) -> QuotaResourceStatus | None:if not self._redis:return Nonetry:- val = await self._redis.get(_redis_key(resource_key, team_id))+ val = await self._redis.get(_redis_key(resource_key, team_id, auth_header))if val is None:return Nonepayload = json.loads(val.decode())@@ -226,12 +262,17 @@ class QuotaResolver:code_usage_billing_active=bool(payload.get("code_usage_billing_active")),used_usd=_optional_number(payload.get("used_usd")),limit_usd=_optional_number(payload.get("limit_usd")),+ posthog_desktop_usage=payload.get("posthog_desktop_usage")+ if isinstance(payload.get("posthog_desktop_usage"), dict)+ else None,)except Exception:logger.debug("quota_cache_read_failed", resource=resource_key, team_id=team_id)return None- async def _set_cached(self, resource_key: str, team_id: int, status: QuotaResourceStatus, ttl: int) -> None:+ async def _set_cached(+ self, resource_key: str, team_id: int, auth_header: str, status: QuotaResourceStatus, ttl: int+ ) -> None:if not self._redis:returntry:@@ -241,9 +282,14 @@ class QuotaResolver:"code_usage_billing_active": status.code_usage_billing_active,"used_usd": status.used_usd,"limit_usd": status.limit_usd,+ **(+ {"posthog_desktop_usage": status.posthog_desktop_usage}+ if status.posthog_desktop_usage is not None+ else {}+ ),})- await self._redis.set(_redis_key(resource_key, team_id), payload, ex=ttl)+ await self._redis.set(_redis_key(resource_key, team_id, auth_header), payload, ex=ttl)except Exception:logger.debug("quota_cache_write_failed", resource=resource_key, team_id=team_id)diff --git a/services/llm-gateway/tests/test_quota_resolver.py b/services/llm-gateway/tests/test_quota_resolver.pyindex 583f67ac739b..08d9bf27713c 100644--- a/services/llm-gateway/tests/test_quota_resolver.py+++ b/services/llm-gateway/tests/test_quota_resolver.py@@ -215,21 +215,21 @@ class TestQuotaResolver:assert redis.ttls[_billing_key(42)] == _LAST_KNOWN_BILLING_TTL_SECONDS# The per-team quota entry expires; the refetch fails.- del redis.store[_redis_key("ai_credits", 42)]+ del redis.store[_redis_key("ai_credits", 42, "Bearer phx_test")]status = await resolver.get_resource_status("ai_credits", team_id=42, auth_header="Bearer phx_test")assert status == QuotaResourceStatus(limited=False, code_usage_billing_active=True)if failure_mode == "retries_exhausted":- assert json.loads(redis.store[_redis_key("ai_credits", 42)]) == {+ assert json.loads(redis.store[_redis_key("ai_credits", 42, "Bearer phx_test")]) == {"limited": False,"code_usage_billing_active": True,"used_usd": None,"limit_usd": None,}- assert redis.ttls[_redis_key("ai_credits", 42)] == _FAIL_OPEN_CACHE_TTL_SECONDS+ assert redis.ttls[_redis_key("ai_credits", 42, "Bearer phx_test")] == _FAIL_OPEN_CACHE_TTL_SECONDSelse:# 4xx is caller-specific and must not repopulate the shared entry.- assert _redis_key("ai_credits", 42) not in redis.store+ assert _redis_key("ai_credits", 42, "Bearer phx_test") not in redis.store@pytest.mark.asyncioasync def test_parses_credit_numbers_into_usd(self) -> None:@@ -264,6 +264,7 @@ class TestQuotaResolver:assert status.used_usd is Noneassert status.limit_usd is None+ assert status.posthog_desktop_usage is None@pytest.mark.asyncioasync def test_usd_numbers_round_trip_through_the_cache(self) -> None:@@ -283,6 +284,143 @@ class TestQuotaResolver:assert (cached.used_usd, cached.limit_usd) == (12.34, 50.0)assert http_client.get.await_count == 1+ @pytest.mark.asyncio+ async def test_cached_usage_is_scoped_to_the_callers_credential(self) -> None:+ redis = _FakeRedis()+ http_client = _make_http_client_sequence(+ [+ _make_response(+ 200,+ {+ "limited": {+ "posthog_code_credits": {"limited": False, "usage": 57, "limit": 1000},+ "posthog_code_token_credits": {"limited": False, "usage": 33, "limit": None},+ "sandbox_compute_credits": {"limited": False, "usage": 24, "limit": None},+ }+ },+ ),+ _make_response(403, {"detail": "token is not scoped to this team"}),+ ]+ )+ resolver = QuotaResolver(redis=redis, http_client=http_client) # type: ignore[arg-type]++ allowed = await resolver.get_resource_status("posthog_code_credits", team_id=42, auth_header="Bearer allowed")+ denied = await resolver.get_resource_status("posthog_code_credits", team_id=42, auth_header="Bearer restricted")++ assert allowed.posthog_desktop_usage is not None+ assert denied.posthog_desktop_usage is None+ assert denied.used_usd is None+ assert http_client.get.await_count == 2+ assert "allowed" not in _redis_key("posthog_code_credits", 42, "Bearer allowed")++ @pytest.mark.asyncio+ async def test_component_integers_round_trip_through_cache(self) -> None:+ breakdown = {+ "token_credits": 1234,+ "compute_credits": 67,+ "cpu_millicore_seconds": 9_876_543_210,+ "memory_mib_seconds": 7_654_321_098,+ }+ redis = _FakeRedis()+ resolver = QuotaResolver(+ redis=redis, # type: ignore[arg-type]+ http_client=_make_http_client(+ _make_response(+ 200,+ {+ "limited": {+ "posthog_code_credits": {"limited": False, "usage": 1301, "limit": 2000},+ "posthog_code_token_credits": {"limited": False, "usage": 1234, "limit": None},+ "sandbox_compute_credits": {"limited": False, "usage": 67, "limit": None},+ "sandbox_compute_cpu_millicore_seconds": {+ "limited": False,+ "usage": 9_876_543_210,+ "limit": None,+ },+ "sandbox_compute_memory_mib_seconds": {+ "limited": False,+ "usage": 7_654_321_098,+ "limit": None,+ },+ },+ },+ )+ ),+ )++ first = await resolver.get_resource_status("posthog_code_credits", 42, "Bearer phx_test")+ cached = await resolver.get_resource_status("posthog_code_credits", 42, "Bearer phx_test")++ assert first.posthog_desktop_usage == breakdown+ assert cached.posthog_desktop_usage == breakdown+ token_credits = first.posthog_desktop_usage["token_credits"]+ compute_credits = first.posthog_desktop_usage["compute_credits"]+ assert isinstance(token_credits, int)+ assert isinstance(compute_credits, int)+ assert token_credits + compute_credits == 1301+ assert first.used_usd == 13.01+ assert first.limit_usd == 20.0++ @pytest.mark.asyncio+ async def test_explicit_zero_survives_component_transport(self) -> None:+ resolver = QuotaResolver(+ redis=None,+ http_client=_make_http_client(+ _make_response(+ 200,+ {+ "limited": {+ "posthog_code_credits": {"limited": False, "usage": 0, "limit": 2000},+ "posthog_code_token_credits": {"limited": False, "usage": 0, "limit": None},+ "sandbox_compute_credits": {"limited": False, "usage": 0, "limit": None},+ },+ },+ )+ ),+ )++ status = await resolver.get_resource_status("posthog_code_credits", 42, "Bearer phx_test")++ assert status.posthog_desktop_usage is not None+ assert status.posthog_desktop_usage["token_credits"] == 0+ assert status.posthog_desktop_usage["compute_credits"] == 0++ @pytest.mark.asyncio+ async def test_parses_real_quota_limits_wire_shape(self) -> None:+ # DRF's FloatField emits integral usage values as JSON floats. Preserve+ # those exact integer quantities in the Desktop response.+ resolver = QuotaResolver(+ redis=None,+ http_client=_make_http_client(+ _make_response(+ 200,+ {+ "limited": {+ "events": {"limited": False, "usage": None, "limit": None},+ "ai_credits": {"limited": False, "usage": 50.0, "limit": None},+ "posthog_code_credits": {"limited": False, "usage": 57.0, "limit": 1000.0},+ "posthog_code_token_credits": {"limited": False, "usage": 33.0, "limit": None},+ "sandbox_compute_credits": {"limited": False, "usage": 24.0, "limit": None},+ "sandbox_compute_cpu_millicore_seconds": {"limited": False, "usage": 0.0, "limit": None},+ "sandbox_compute_memory_mib_seconds": {"limited": False, "usage": None, "limit": None},+ },+ "code_usage_billing_active": True,+ },+ )+ ),+ )++ status = await resolver.get_resource_status("posthog_code_credits", 42, "Bearer phx_test")++ assert status.posthog_desktop_usage == {+ "token_credits": 33,+ "compute_credits": 24,+ "cpu_millicore_seconds": 0,+ "memory_mib_seconds": None,+ }+ assert status.used_usd == 0.57+ assert status.limit_usd == 10.0+@pytest.mark.asyncioasync def test_fetches_and_parses_unlimited_response(self) -> None:http_client = _make_http_client(@@ -364,7 +502,7 @@ class TestQuotaResolver:status = await resolver.get_resource_status("ai_credits", team_id=42, auth_header="Bearer phx_test")assert status == QuotaResourceStatus(limited=True)- redis.get.assert_awaited_once_with(_redis_key("ai_credits", 42))+ redis.get.assert_awaited_once_with(_redis_key("ai_credits", 42, "Bearer phx_test"))http_client.get.assert_not_called()@pytest.mark.asyncio@@ -379,7 +517,9 @@ class TestQuotaResolver:# One write per key: the team+resource quota entry and the per-team# last-known billing bit.- quota_writes = [c for c in redis.set.await_args_list if c.args[0] == _redis_key("ai_credits", 42)]+ quota_writes = [+ c for c in redis.set.await_args_list if c.args[0] == _redis_key("ai_credits", 42, "Bearer phx_test")+ ]assert len(quota_writes) == 1call = quota_writes[0]assert json.loads(call.args[1]) == {diff --git a/services/llm-gateway/tests/test_usage.py b/services/llm-gateway/tests/test_usage.pyindex 9a4fca1e926b..e1e91617b59c 100644--- a/services/llm-gateway/tests/test_usage.py+++ b/services/llm-gateway/tests/test_usage.py@@ -378,7 +378,7 @@ class TestUsageEndpoint:)assert response.status_code == 200data = response.json()- assert data["ai_credits"] == {"exhausted": True, "used_usd": None, "limit_usd": None}+ assert data["ai_credits"] == {"exhausted": True, "used_usd": None, "limit_usd": None, "breakdown": None}assert data["is_rate_limited"] is Trueassert resolver_mock.call_args.args[0] == "posthog_code_credits"@@ -404,7 +404,7 @@ class TestUsageEndpoint:)assert response.status_code == 200data = response.json()- assert data["ai_credits"] == {"exhausted": True, "used_usd": None, "limit_usd": None}+ assert data["ai_credits"] == {"exhausted": True, "used_usd": None, "limit_usd": None, "breakdown": None}assert data["is_rate_limited"] is Truedef test_ai_credits_reflects_resolver_for_billable_product(self, authenticated_usage_client: TestClient) -> None:@@ -420,7 +420,7 @@ class TestUsageEndpoint:)assert response.status_code == 200data = response.json()- assert data["ai_credits"] == {"exhausted": True, "used_usd": None, "limit_usd": None}+ assert data["ai_credits"] == {"exhausted": True, "used_usd": None, "limit_usd": None, "breakdown": None}assert data["is_rate_limited"] is Trueassert resolver_mock.call_args.args[0] == "ai_credits"@@ -439,7 +439,40 @@ class TestUsageEndpoint:headers={"Authorization": "Bearer phx_test"},)assert response.status_code == 200- assert response.json()["ai_credits"] == {"exhausted": False, "used_usd": 12.4, "limit_usd": 50.0}+ assert response.json()["ai_credits"] == {+ "exhausted": False,+ "used_usd": 12.4,+ "limit_usd": 50.0,+ "breakdown": None,+ }++ def test_posthog_code_includes_optional_component_breakdown(+ self,+ authenticated_usage_client: TestClient,+ ) -> None:+ from llm_gateway.services.quota_resolver import QuotaResourceStatus++ component_breakdown: dict[str, object] = {+ "token_credits": 1234,+ "compute_credits": 67,+ "cpu_millicore_seconds": 9_876_543_210,+ "memory_mib_seconds": 7_654_321_098,+ }+ authenticated_usage_client.app.state.quota_resolver.get_resource_status = AsyncMock(+ return_value=QuotaResourceStatus(+ limited=False,+ used_usd=13.01,+ limit_usd=20.0,+ posthog_desktop_usage=component_breakdown,+ )+ )+ data = authenticated_usage_client.get(+ "/v1/usage/posthog_code", headers={"Authorization": "Bearer phx_test"}+ ).json()++ assert data["ai_credits"]["used_usd"] == 13.01+ assert data["ai_credits"]["limit_usd"] == 20.0+ assert data["ai_credits"]["breakdown"] == component_breakdown@pytest.mark.parametrize("billing_active", [True, False])def test_code_usage_subscribed_reflects_billing_bit(diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 8d0104720467..621e09b1b82f 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -64654,12 +64654,12 @@ export namespace Schemas {}/**- * Per-resource limit state for every `QuotaResource` value, e.g. `ai_credits`, `posthog_code_credits`.+ * Per-resource limit state for every `QuotaResource` value, e.g. `ai_credits`, `posthog_code_credits`. Also carries the informational Desktop component resources (`posthog_code_token_credits`, `sandbox_compute_credits`, `sandbox_compute_cpu_millicore_seconds`, `sandbox_compute_memory_mib_seconds`) with usage in their native units, a null limit, and `limited` always false — they are never quota-enforced; only the combined `posthog_code_credits` is.*/export type QuotaLimitsResponseLimited = {[key: string]: QuotaResourceLimit};export interface QuotaLimitsResponse {- /** Per-resource limit state for every `QuotaResource` value, e.g. `ai_credits`, `posthog_code_credits`. */+ /** Per-resource limit state for every `QuotaResource` value, e.g. `ai_credits`, `posthog_code_credits`. Also carries the informational Desktop component resources (`posthog_code_token_credits`, `sandbox_compute_credits`, `sandbox_compute_cpu_millicore_seconds`, `sandbox_compute_memory_mib_seconds`) with usage in their native units, a null limit, and `limited` always false — they are never quota-enforced; only the combined `posthog_code_credits` is. */limited: QuotaLimitsResponseLimited;/** Whether the team's organization pays for PostHog Desktop usage: billing grants the `posthog_code_usage` product feature only on the Desktop usage product's paid plan, synced into the organization's available features. Consumers gate paid-tier Desktop behavior on this; an org unknown to billing reads as not paying. */code_usage_billing_active: boolean;