Skip to content

: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.

feat(billing): enforce a free-tier api queries read-bytes quota (#82372)

Andy Zhao4449b3dbe1e7
diff --git a/ee/billing/billing_manager.py b/ee/billing/billing_manager.py
index c133f3278ffa..cc380695feef 100644
--- a/ee/billing/billing_manager.py
+++ b/ee/billing/billing_manager.py
@@ -9,6 +9,8 @@ from uuid import UUID
from django.conf import settings
from django.db.models import F
+from django.utils import timezone
+from django.utils.dateparse import parse_datetime
import jwt
import requests
@@ -28,7 +30,7 @@ from posthog.models.team.event_retention import (
from posthog.models.team.logs_retention import reset_revoked_logs_retention
from posthog.models.user import User
-from ee.billing.billing_types import BillingProvider, BillingStatus
+from ee.billing.billing_types import BillingProvider, BillingStatus, CustomerInfo
from ee.billing.quota_limiting import set_org_usage_summary, update_org_billing_quotas
from ee.models import License
from ee.settings import BILLING_SERVICE_URL
@@ -63,6 +65,19 @@ def _has_quota_limiting_markers(usage: dict | None) -> bool:
return False
+def _free_trial_active(customer: CustomerInfo) -> bool:
+ free_trial_until = customer.get("free_trial_until")
+ if not free_trial_until:
+ return False
+ expires = parse_datetime(free_trial_until) if isinstance(free_trial_until, str) else free_trial_until
+ if expires is None:
+ return False
+ # An offset-less timestamp parses naive, and comparing naive to aware raises TypeError.
+ if timezone.is_naive(expires):
+ expires = expires.replace(tzinfo=UTC)
+ return expires > timezone.now()
+
+
def _get_user_organization_role(user: User, organization: Organization) -> Optional[str]:
"""
Get a user role display string in a given organization, if membership doesn't exist return None.
@@ -535,6 +550,17 @@ class BillingManager:
organization.never_drop_data = never_drop_data
org_modified = True
+ # A missing key (partial or error-path response) must not reset a known value to unknown.
+ if "has_active_subscription" in data:
+ has_active_subscription = data.get("has_active_subscription")
+ # Trials run without a Stripe subscription, so a trialing org would otherwise read
+ # as free tier and get metered; count an active trial as paid until it expires.
+ if has_active_subscription is False and _free_trial_active(data):
+ has_active_subscription = True
+ if has_active_subscription != organization.has_active_subscription:
+ organization.has_active_subscription = has_active_subscription
+ org_modified = True
+
customer_trust_scores = data.get("customer_trust_scores", {})
if customer_trust_scores:
diff --git a/ee/billing/test/test_billing_manager.py b/ee/billing/test/test_billing_manager.py
index dc78961c56ee..1a9c343757f1 100644
--- a/ee/billing/test/test_billing_manager.py
+++ b/ee/billing/test/test_billing_manager.py
@@ -6,6 +6,7 @@ import datetime
from types import SimpleNamespace
from typing import Any, cast
+from freezegun import freeze_time
from posthog.test.base import BaseTest
from unittest.mock import MagicMock, patch
@@ -685,6 +686,100 @@ class TestBillingManager(BaseTest):
assert "Open invoices must be resolved first" in str(context.exception)
+ def test_update_org_details_persists_has_active_subscription(self):
+ organization = self.organization
+ billing_status = {
+ "customer": {
+ "has_active_subscription": False,
+ "usage_summary": {
+ "events": {"usage": 1000, "limit": None},
+ "recordings": {"usage": 0, "limit": None},
+ },
+ "billing_period": {
+ "current_period_start": "2026-08-01T00:00:00Z",
+ "current_period_end": "2026-09-01T00:00:00Z",
+ },
+ }
+ }
+ BillingManager(license=None).update_org_details(organization, cast(BillingStatus, billing_status))
+ organization.refresh_from_db()
+ assert organization.has_active_subscription is False
+
+ def test_update_org_details_missing_key_keeps_existing_has_active_subscription(self):
+ organization = self.organization
+ organization.has_active_subscription = False
+ organization.save()
+ billing_status = {
+ "customer": {
+ "usage_summary": {
+ "events": {"usage": 1000, "limit": None},
+ "recordings": {"usage": 0, "limit": None},
+ },
+ "billing_period": {
+ "current_period_start": "2026-08-01T00:00:00Z",
+ "current_period_end": "2026-09-01T00:00:00Z",
+ },
+ }
+ }
+ BillingManager(license=None).update_org_details(organization, cast(BillingStatus, billing_status))
+ organization.refresh_from_db()
+ assert organization.has_active_subscription is False
+
+ @parameterized.expand(
+ [
+ ("downgrade", True, False),
+ ("upgrade", False, True),
+ ]
+ )
+ def test_update_org_details_syncs_has_active_subscription_transition(self, _name, before, after):
+ organization = self.organization
+ organization.has_active_subscription = before
+ organization.save()
+ billing_status = {
+ "customer": {
+ "has_active_subscription": after,
+ "usage_summary": {
+ "events": {"usage": 1000, "limit": None},
+ "recordings": {"usage": 0, "limit": None},
+ },
+ "billing_period": {
+ "current_period_start": "2026-08-01T00:00:00Z",
+ "current_period_end": "2026-09-01T00:00:00Z",
+ },
+ }
+ }
+ BillingManager(license=None).update_org_details(organization, cast(BillingStatus, billing_status))
+ organization.refresh_from_db()
+ assert organization.has_active_subscription is after
+
+ @parameterized.expand(
+ [
+ ("active_trial_counts_as_paid", "2027-01-01T00:00:00Z", True),
+ ("expired_trial_counts_as_free", "2026-01-01T00:00:00Z", False),
+ ("naive_timestamp_treated_as_utc", "2027-01-01T00:00:00", True),
+ ]
+ )
+ def test_update_org_details_trial_handling(self, _name, free_trial_until, expected):
+ organization = self.organization
+ billing_status = {
+ "customer": {
+ "has_active_subscription": False,
+ "free_trial_until": free_trial_until,
+ "usage_summary": {
+ "events": {"usage": 1000, "limit": None},
+ "recordings": {"usage": 0, "limit": None},
+ },
+ "billing_period": {
+ "current_period_start": "2026-08-01T00:00:00Z",
+ "current_period_end": "2026-09-01T00:00:00Z",
+ },
+ }
+ }
+ with freeze_time("2026-08-13"):
+ BillingManager(license=None).update_org_details(organization, cast(BillingStatus, billing_status))
+ organization.refresh_from_db()
+ assert organization.has_active_subscription is expected
+
class TestBillingProviderWebhookSigning(SimpleTestCase):
def setUp(self):
diff --git a/ee/billing/test/test_quota_limiting.py b/ee/billing/test/test_quota_limiting.py
index 0c23ad57dab7..59b01df2d3dc 100644
--- a/ee/billing/test/test_quota_limiting.py
+++ b/ee/billing/test/test_quota_limiting.py
@@ -1804,11 +1804,12 @@ class TestQuotaLimiting(BaseTest):
def test_usage_keys_stay_in_sync(self):
"""
- Ensure QuotaResource, UsageCounters, and OrganizationUsageInfo all use the same keys (except for `period`).
+ Ensure QuotaResource, UsageCounters, and OrganizationUsageInfo all use the same keys
+ (except for `period`).
"""
from posthog.models.organization import OrganizationUsageInfo
- # OrganizationUsageInfo is source of truth (excluding 'period``)
+ # OrganizationUsageInfo is source of truth (excluding 'period`)
org_usage_keys = set(OrganizationUsageInfo.__annotations__.keys()) - {"period"}
quota_resource_keys = {resource.value for resource in QuotaResource}
diff --git a/posthog/api/query.py b/posthog/api/query.py
index c0c0c5670fc5..75bcee3c59fd 100644
--- a/posthog/api/query.py
+++ b/posthog/api/query.py
@@ -52,6 +52,7 @@ from posthog.clickhouse.query_tagging import get_query_tag_value, get_query_tags
from posthog.constants import AvailableFeature
from posthog.errors import ExposedCHQueryError, InternalCHQueryError
from posthog.event_usage import EventSource, get_request_analytics_properties, report_user_or_team_action
+from posthog.exceptions import QuotaLimitExceeded
from posthog.exceptions_capture import capture_exception
from posthog.hogql_queries.apply_dashboard_filters import apply_dashboard_filters, apply_dashboard_variables
from posthog.hogql_queries.hogql_query_runner import HogQLQueryRunner
@@ -362,6 +363,9 @@ class QueryViewSet(QueryCoalescingMixin, TeamAndOrgViewSetMixin, PydanticModelMi
raise
except ConcurrencyLimitExceeded as c:
self._raise_concurrency_throttled(c)
+ except QuotaLimitExceeded:
+ # Expected while an org is over quota - a 402 the caller can act on, not error noise.
+ raise
except Exception as e:
# Breaker replays were already captured when the original failure happened.
if not getattr(e, "served_from_query_failure_cache", False):
@@ -466,6 +470,9 @@ class QueryViewSet(QueryCoalescingMixin, TeamAndOrgViewSetMixin, PydanticModelMi
return Response(result.model_dump(), status=200)
except ConcurrencyLimitExceeded as c:
self._raise_concurrency_throttled(c)
+ except QuotaLimitExceeded:
+ # Expected while an org is over quota - a 402 the caller can act on, not error noise.
+ raise
except Exception as e:
# Breaker replays were already captured when the original failure happened.
if not getattr(e, "served_from_query_failure_cache", False):
diff --git a/posthog/api/test/__snapshots__/test_element.ambr b/posthog/api/test/__snapshots__/test_element.ambr
index 21cb978c1a35..7e61e7c04240 100644
--- a/posthog/api/test/__snapshots__/test_element.ambr
+++ b/posthog/api/test/__snapshots__/test_element.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -376,6 +377,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -427,6 +429,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -505,6 +508,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/posthog/api/test/__snapshots__/test_preflight.ambr b/posthog/api/test/__snapshots__/test_preflight.ambr
index cd39e1e7ffdd..245ac729815f 100644
--- a/posthog/api/test/__snapshots__/test_preflight.ambr
+++ b/posthog/api/test/__snapshots__/test_preflight.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr
index 444e8dd0b92d..0847a47530e0 100644
--- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr
+++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -548,6 +549,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -593,6 +595,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -732,6 +735,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -784,6 +788,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -862,6 +867,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1423,6 +1429,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2401,6 +2408,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2563,6 +2571,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2632,6 +2641,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3043,6 +3053,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3088,6 +3099,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3227,6 +3239,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3279,6 +3292,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3357,6 +3371,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3576,6 +3591,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3654,6 +3670,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3928,6 +3945,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4269,6 +4287,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4408,6 +4427,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4472,6 +4492,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4550,6 +4571,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4844,6 +4866,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5160,6 +5183,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5306,6 +5330,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5358,6 +5383,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5436,6 +5462,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7429,6 +7456,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7528,6 +7556,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7667,6 +7696,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7719,6 +7749,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7797,6 +7828,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7886,6 +7918,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8620,6 +8653,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8759,6 +8793,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8811,6 +8846,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8889,6 +8925,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8962,6 +8999,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9265,6 +9303,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9594,6 +9633,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9733,6 +9773,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9785,6 +9826,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9872,6 +9914,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10147,6 +10190,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10479,6 +10523,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10618,6 +10663,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10670,6 +10716,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10850,6 +10897,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11125,6 +11173,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12186,6 +12235,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12325,6 +12375,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12377,6 +12428,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12455,6 +12507,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12669,6 +12722,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13315,6 +13369,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13414,6 +13469,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13553,6 +13609,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13605,6 +13662,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13683,6 +13741,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13772,6 +13831,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14506,6 +14566,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14645,6 +14706,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14697,6 +14759,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14775,6 +14838,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14848,6 +14912,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr
index f6c91d86471e..9b2a64ba6ae8 100644
--- a/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr
+++ b/posthog/api/test/notebooks/__snapshots__/test_notebook.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -170,6 +171,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -309,6 +311,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -375,6 +378,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -453,6 +457,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -850,6 +855,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -997,6 +1003,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1265,6 +1272,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1404,6 +1412,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1470,6 +1479,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1548,6 +1558,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1670,6 +1681,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1748,6 +1760,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/posthog/api_queries_quota.py b/posthog/api_queries_quota.py
new file mode 100644
index 000000000000..a7b32370f80c
--- /dev/null
+++ b/posthog/api_queries_quota.py
@@ -0,0 +1,57 @@
+"""Per-organization monthly counter of chargeable API query bytes read.
+
+The product-owned metering for the free-tier API queries quota: incremented from the
+ClickHouse client for chargeable queries, read by the query runner's quota check. Kept
+dependency-light (Redis only) so both layers can import it without cycles.
+"""
+
+from datetime import UTC, datetime
+
+from dateutil.relativedelta import relativedelta
+from prometheus_client import Counter
+
+from posthog.exceptions_capture import capture_exception
+from posthog.redis import get_client
+
+COUNTER_KEY_PREFIX = "@posthog/api-queries-bytes/"
+# Keys are month-scoped; TTL only has to outlive the month it closes over.
+COUNTER_TTL_SECONDS = 63 * 24 * 3600
+
+API_QUERIES_QUOTA_ERRORS_COUNTER = Counter(
+ "posthog_api_queries_quota_errors_total",
+ "Errors swallowed by the fail-open api queries quota paths.",
+ labelnames=["op"],
+)
+
+
+def _counter_key(org_id: str, now: datetime) -> str:
+ return f"{COUNTER_KEY_PREFIX}{org_id}/{now.strftime('%Y%m')}"
+
+
+def increment_api_queries_bytes(org_id: str, bytes_read: int) -> None:
+ if not bytes_read:
+ return
+ try:
+ key = _counter_key(org_id, datetime.now(UTC))
+ pipe = get_client().pipeline(transaction=False)
+ pipe.incrby(key, bytes_read)
+ pipe.expire(key, COUNTER_TTL_SECONDS)
+ pipe.execute()
+ except Exception as e:
+ API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="increment").inc()
+ capture_exception(e)
+
+
+def get_api_queries_bytes(org_id: str) -> int:
+ try:
+ value = get_client().get(_counter_key(org_id, datetime.now(UTC)))
+ return int(value) if value else 0
+ except Exception as e:
+ API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="read").inc()
+ capture_exception(e)
+ return 0
+
+
+def next_counter_reset(now: datetime) -> datetime:
+ """First instant of the next UTC month, when the counter key rolls over."""
+ return datetime(now.year, now.month, 1, tzinfo=UTC) + relativedelta(months=1)
diff --git a/posthog/clickhouse/client/execute.py b/posthog/clickhouse/client/execute.py
index 2547a3cbd40a..f26e0b11d64d 100644
--- a/posthog/clickhouse/client/execute.py
+++ b/posthog/clickhouse/client/execute.py
@@ -19,6 +19,7 @@ from clickhouse_driver import Client as SyncClient
from opentelemetry import trace
from prometheus_client import Counter
+from posthog.api_queries_quota import increment_api_queries_bytes
from posthog.clickhouse.client.connection import (
ClickHouseUser,
Workload,
@@ -517,14 +518,30 @@ def sync_execute(
_llm_analytics_concurrency_slot(ch_user, team_id),
sync_client or get_client_from_pool(workload, team_id, readonly, ch_user) as client,
):
- result = client.execute(
- prepared_sql,
- params=prepared_args,
- settings=settings,
- with_column_types=with_column_types,
- query_id=query_id,
- external_tables=external_tables,
- )
+ query_info_before = getattr(client, "last_query", None)
+ try:
+ result = client.execute(
+ prepared_sql,
+ params=prepared_args,
+ settings=settings,
+ with_column_types=with_column_types,
+ query_id=query_id,
+ external_tables=external_tables,
+ )
+ finally:
+ # A query killed mid-scan (timeout, memory limit) has already cost the read, so
+ # meter the progress the server reported before it died. The driver only resets
+ # `last_query` once the connection is established; the identity check keeps a
+ # pooled client's previous query from being re-metered when connecting fails.
+ query_info = getattr(client, "last_query", None)
+ if (
+ tags.chargeable
+ and tags.org_id
+ and query_info is not None
+ and query_info is not query_info_before
+ and query_info.progress
+ ):
+ increment_api_queries_bytes(str(tags.org_id), query_info.progress.bytes)
if (
"INSERT INTO" in prepared_sql
and hasattr(client, "last_query")
diff --git a/posthog/exceptions.py b/posthog/exceptions.py
index c2ea6aa3c819..19f0a632a04d 100644
--- a/posthog/exceptions.py
+++ b/posthog/exceptions.py
@@ -29,6 +29,15 @@ class QuotaLimitExceeded(APIException):
default_detail = "Your organization reached its billing limit for this resource. Increase the limits in Billing settings, or ask an org admin to do so."
+class APIQueriesQuotaExceeded(QuotaLimitExceeded):
+ default_code = "api_queries_quota_exceeded"
+ default_detail = (
+ "Your organization has read more query data over the API than its free allowance for this month. "
+ "API queries will be available again when the allowance resets. "
+ "Upgrade your plan in Billing settings to restore access sooner, or ask an org admin to do so."
+ )
+
+
class EnterpriseFeatureException(APIException):
status_code = status.HTTP_402_PAYMENT_REQUIRED
default_code = "payment_required"
diff --git a/posthog/hogql_queries/query_runner.py b/posthog/hogql_queries/query_runner.py
index 3aad4f838610..8f1b836c4178 100644
--- a/posthog/hogql_queries/query_runner.py
+++ b/posthog/hogql_queries/query_runner.py
@@ -3,11 +3,15 @@ from collections.abc import Sequence
from datetime import UTC, datetime, timedelta
from enum import StrEnum
from functools import cache, cached_property
-from time import perf_counter
+from time import monotonic, perf_counter
from types import UnionType
from typing import Any, Generic, NamedTuple, Optional, Protocol, TypeGuard, TypeVar, Union, cast, get_args, get_origin
+from zoneinfo import ZoneInfo
+
+from django.conf import settings as django_settings
import orjson
+import structlog
import posthoganalytics
from prometheus_client import Counter, Histogram
from pydantic import BaseModel, ConfigDict
@@ -102,6 +106,7 @@ from posthog.hogql.timings import HogQLTimings
from posthog.hogql.warehouse_warnings import accumulator_scope
from posthog import settings
+from posthog.api_queries_quota import API_QUERIES_QUOTA_ERRORS_COUNTER, get_api_queries_bytes, next_counter_reset
from posthog.caching.utils import ThresholdMode, cache_target_age, is_stale, last_refresh_from_cached_result
from posthog.clickhouse.client.connection import ClickHouseUser, Workload
from posthog.clickhouse.client.execute_async import QueryNotFoundError, enqueue_process_query_task, get_query_status
@@ -116,6 +121,7 @@ from posthog.clickhouse.query_tagging import get_query_tag_value, is_api_key_acc
from posthog.constants import AvailableFeature
from posthog.errors import QueryErrorCategory, classify_query_error, clickhouse_error_type
from posthog.event_usage import AnalyticsProps, groups, report_user_or_team_action
+from posthog.exceptions import APIQueriesQuotaExceeded
from posthog.exceptions_capture import capture_exception
from posthog.hogql_queries.access_controlled_resources import queried_access_controlled_resources
from posthog.hogql_queries.insights.utils.breakdowns import has_multi_breakdown, has_single_breakdown
@@ -155,6 +161,8 @@ from posthog.utils import generate_cache_key, get_from_dict_or_attr, to_json
from products.web_analytics.backend.hogql_queries.first_pageview_flag import resolve_first_pageview_filters_modifier
+logger = structlog.get_logger(__name__)
+
QUERY_EXECUTION_TOTAL = Counter(
"posthog_query_execution_total",
"Query executions by category",
@@ -181,6 +189,14 @@ SURVEY_QUERY_EXECUTION_DURATION = Histogram(
buckets=[0.05, 0.1, 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0, 5.0, 7.5, 10.0, 15.0, 20.0, 30.0, 60.0, 120.0],
)
+API_QUERIES_QUOTA_ENFORCEMENT_FLAG = "api-queries-quota-enforcement"
+
+API_QUERIES_QUOTA_LIMITED_COUNTER = Counter(
+ "posthog_api_queries_quota_limited_total",
+ "Query executions for teams whose organization is over its api_queries_read_bytes quota.",
+ labelnames=["surface", "outcome"], # surface: api; outcome: observed | enforced
+)
+
def _contains_user_hogql_label() -> str:
# Read the tag set by `tag_contains_user_hogql()` at HogQL parse sites; lets
@@ -338,6 +354,89 @@ def shared_insights_execution_mode(execution_mode: ExecutionMode) -> SharedExecu
)
+def get_api_queries_quota_limited_until(team: Team) -> Optional[datetime]:
+ """When a free org is over its monthly chargeable-bytes allowance, returns the moment
+ the counter resets; otherwise None.
+
+ Recomputed live from the synced subscription column and the Redis counter on every
+ call, so there is no verdict to go stale after an upgrade. Fails open on error.
+ """
+ if not django_settings.API_QUERIES_ENABLED or not django_settings.API_QUERIES_FREE_TIER_READ_BYTES_LIMIT:
+ return None
+ try:
+ if team.organization.has_active_subscription is not False:
+ return None
+ if get_api_queries_bytes(str(team.organization_id)) <= django_settings.API_QUERIES_FREE_TIER_READ_BYTES_LIMIT:
+ return None
+ return next_counter_reset(datetime.now(UTC))
+ except Exception as e:
+ API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="check").inc()
+ capture_exception(e)
+ return None
+
+
+# Flag evaluation is a network call to the flags service, and it runs once per chargeable
+# query from an over-quota org, so a runaway API consumer would hammer that service at its
+# own query rate. The short per-process cache bounds that load; the TTL also bounds how long
+# a flag flip takes to apply on any one worker.
+_ENFORCEMENT_FLAG_TTL_SECONDS = 30
+_enforcement_flag_cache: dict[str, tuple[bool, float]] = {}
+
+
+def _api_queries_enforcement_enabled(team: Team) -> bool:
+ org_id = str(team.organization_id)
+ cached = _enforcement_flag_cache.get(org_id)
+ now = monotonic()
+ if cached is not None and cached[1] > now:
+ return cached[0]
+ try:
+ enabled = bool(
+ posthoganalytics.feature_enabled(
+ API_QUERIES_QUOTA_ENFORCEMENT_FLAG,
+ org_id,
+ groups={"organization": org_id},
+ group_properties={"organization": {"id": org_id}},
+ only_evaluate_locally=False,
+ send_feature_flag_events=False,
+ )
+ )
+ except Exception:
+ # Not cached, so enforcement resumes as soon as the flags service recovers.
+ return False
+ if len(_enforcement_flag_cache) > 1024:
+ _enforcement_flag_cache.clear()
+ _enforcement_flag_cache[org_id] = (enabled, now + _ENFORCEMENT_FLAG_TTL_SECONDS)
+ return enabled
+
+
+def _format_data_size(bytes_count: int) -> str:
+ # Decimal units, to match how the allowance is defined (50 TB = 50e12 bytes).
+ for unit, size in (("TB", 1_000_000_000_000), ("GB", 1_000_000_000), ("MB", 1_000_000)):
+ if bytes_count >= size:
+ value = f"{bytes_count / size:.1f}".removesuffix(".0")
+ return f"{value} {unit}"
+ return f"{bytes_count:,} bytes"
+
+
+def _api_queries_quota_detail(*, used: int, limit: int, limited_until: datetime, project_timezone: str) -> str:
+ try:
+ local = limited_until.astimezone(ZoneInfo(project_timezone))
+ except Exception:
+ local = limited_until
+ reset = f"{local:%B} {local.day}, {local.year}"
+ # The reset is midnight UTC, so in most project timezones it lands mid-day; show the
+ # time whenever it isn't local midnight.
+ if local.hour or local.minute:
+ reset += f" at {local:%H:%M}"
+ reset += f" ({local.tzinfo})"
+ return (
+ f"Your organization used {_format_data_size(used)} of its {_format_data_size(limit)} "
+ "monthly free allowance for API queries. "
+ f"The allowance resets on {reset}. "
+ "Upgrade your plan in Billing settings to restore access sooner, or ask an org admin to do so."
+ )
+
+
RunnableQueryNode = Union[
TrendsQuery,
FunnelsQuery,
@@ -1803,6 +1902,7 @@ class QueryRunner(ABC, Generic[Q, R, CR]):
if self.is_query_service:
tag_queries(chargeable=1)
+ self._enforce_api_queries_quota()
with (
get_materialized_endpoints_rate_limiter().run(
@@ -2247,7 +2347,7 @@ class QueryRunner(ABC, Generic[Q, R, CR]):
def get_api_queries_concurrency_limit(self):
"""
- :return: None - no feature, 0 - rate limited, 1,3,<other> for actual concurrency limit
+ :return: None - no feature, 1,3,<other> for actual concurrency limit
"""
# TODO - remove once no longer needed, as per https://posthog.slack.com/archives/C075D3C5HST/p1766275591753869
@@ -2259,16 +2359,39 @@ class QueryRunner(ABC, Generic[Q, R, CR]):
from posthog.constants import AvailableFeature
- from ee.billing.quota_limiting import QuotaLimitingCaches, QuotaResource, list_limited_team_attributes
-
- if self.team.api_token in list_limited_team_attributes(
- QuotaResource.API_QUERIES, QuotaLimitingCaches.QUOTA_LIMITER_CACHE_KEY
- ):
- return 0
-
feature = self.team.organization.get_available_feature(AvailableFeature.API_QUERIES_CONCURRENCY)
return feature.get("limit") if feature else None
+ def _enforce_api_queries_quota(self) -> None:
+ """402 chargeable API queries for orgs over quota, when enforcement is flagged on.
+
+ Observe-only (counter, no block) when the flag is off. Never blocks unless the
+ live counter confirms over-quota.
+ """
+ limited_until = get_api_queries_quota_limited_until(self.team)
+ if limited_until is None:
+ return
+ used = get_api_queries_bytes(str(self.team.organization_id))
+ limit = django_settings.API_QUERIES_FREE_TIER_READ_BYTES_LIMIT
+ outcome = "enforced" if _api_queries_enforcement_enabled(self.team) else "observed"
+ API_QUERIES_QUOTA_LIMITED_COUNTER.labels(surface="api", outcome=outcome).inc()
+ logger.info(
+ "api_queries_quota_limited",
+ organization_id=str(self.team.organization_id),
+ team_id=self.team.pk,
+ usage_bytes=used,
+ limit_bytes=limit,
+ limited_until=limited_until.isoformat(),
+ outcome=outcome,
+ )
+ if outcome == "observed":
+ return
+ raise APIQueriesQuotaExceeded(
+ detail=_api_queries_quota_detail(
+ used=used, limit=limit, limited_until=limited_until, project_timezone=self.team.timezone
+ )
+ )
+
@abstractmethod
def to_query(self) -> ast.SelectQuery | ast.SelectSetQuery:
raise NotImplementedError()
diff --git a/posthog/hogql_queries/test/test_api_queries_quota.py b/posthog/hogql_queries/test/test_api_queries_quota.py
new file mode 100644
index 000000000000..06f24e194a26
--- /dev/null
+++ b/posthog/hogql_queries/test/test_api_queries_quota.py
@@ -0,0 +1,232 @@
+from datetime import UTC, datetime
+
+import pytest
+from posthog.test.base import BaseTest
+from unittest.mock import patch
+
+from django.test import SimpleTestCase, override_settings
+
+from parameterized import parameterized
+
+from posthog.schema import HogQLQuery
+
+from posthog.api_queries_quota import API_QUERIES_QUOTA_ERRORS_COUNTER, increment_api_queries_bytes
+from posthog.exceptions import APIQueriesQuotaExceeded
+from posthog.hogql_queries.hogql_query_runner import HogQLQueryRunner
+from posthog.hogql_queries.query_runner import (
+ API_QUERIES_QUOTA_LIMITED_COUNTER,
+ _api_queries_enforcement_enabled,
+ _api_queries_quota_detail,
+ _enforcement_flag_cache,
+ _format_data_size,
+ get_api_queries_quota_limited_until,
+)
+
+
+@override_settings(API_QUERIES_ENABLED=True, API_QUERIES_FREE_TIER_READ_BYTES_LIMIT=1000)
+class TestGetApiQueriesQuotaLimitedUntil(BaseTest):
+ def _set(self, has_active_subscription, counter_bytes):
+ self.organization.has_active_subscription = has_active_subscription
+ self.organization.save()
+ if counter_bytes:
+ increment_api_queries_bytes(str(self.organization.id), counter_bytes)
+
+ @parameterized.expand(
+ [
+ # (has_active_subscription, counter_bytes, expect_limited)
+ ("free_over_limit", False, 2000, True),
+ ("free_under_limit", False, 500, False),
+ ("paying_over_limit", True, 2000, False),
+ ("unknown_subscription_over_limit", None, 2000, False),
+ ]
+ )
+ def test_check_matrix(self, _name, has_active_subscription, counter_bytes, expect_limited):
+ self._set(has_active_subscription, counter_bytes)
+ result = get_api_queries_quota_limited_until(self.team)
+ if expect_limited:
+ assert result is not None and result.tzinfo is not None
+ else:
+ assert result is None
+
+ @override_settings(API_QUERIES_FREE_TIER_READ_BYTES_LIMIT=0)
+ def test_zero_setting_disables(self):
+ self._set(False, 2000)
+ assert get_api_queries_quota_limited_until(self.team) is None
+
+ def test_counter_error_fails_open(self):
+ self._set(False, 2000)
+ with patch("posthog.hogql_queries.query_runner.get_api_queries_bytes", side_effect=Exception("redis down")):
+ assert get_api_queries_quota_limited_until(self.team) is None
+
+ def test_counter_error_increments_error_counter(self):
+ self._set(False, 2000)
+ before = API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="check")._value.get()
+ with patch("posthog.hogql_queries.query_runner.get_api_queries_bytes", side_effect=Exception("redis down")):
+ get_api_queries_quota_limited_until(self.team)
+ after = API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="check")._value.get()
+ assert after == before + 1
+
+ @override_settings(API_QUERIES_ENABLED=False)
+ def test_disabled_setting_returns_none(self):
+ self._set(False, 2000)
+ assert get_api_queries_quota_limited_until(self.team) is None
+
+
+class TestApiQueriesQuotaDetail(SimpleTestCase):
+ def test_detail_includes_usage_limit_and_reset(self):
+ detail = _api_queries_quota_detail(
+ used=62_500_000_000_000,
+ limit=50_000_000_000_000,
+ limited_until=datetime(2026, 9, 1, tzinfo=UTC),
+ project_timezone="UTC",
+ )
+ assert "62.5 TB" in detail
+ assert "50 TB" in detail
+ assert "September 1, 2026 (UTC)" in detail
+ assert "Billing settings" in detail
+
+ def test_detail_renders_reset_in_project_timezone(self):
+ detail = _api_queries_quota_detail(
+ used=62_500_000_000_000,
+ limit=50_000_000_000_000,
+ limited_until=datetime(2026, 9, 1, tzinfo=UTC),
+ project_timezone="America/Los_Angeles",
+ )
+ assert "August 31, 2026 at 17:00 (America/Los_Angeles)" in detail
+
+ def test_detail_falls_back_to_utc_on_bad_timezone(self):
+ detail = _api_queries_quota_detail(
+ used=62_500_000_000_000,
+ limit=50_000_000_000_000,
+ limited_until=datetime(2026, 9, 1, tzinfo=UTC),
+ project_timezone="Not/AZone",
+ )
+ assert "September 1, 2026 (UTC)" in detail
+
+ @parameterized.expand(
+ [
+ ("terabytes_trimmed", 50_000_000_000_000, "50 TB"),
+ ("terabytes_fraction", 62_500_000_000_000, "62.5 TB"),
+ ("gigabytes", 500_000_000_000, "500 GB"),
+ ("small_values_stay_bytes", 999, "999 bytes"),
+ ]
+ )
+ def test_format_data_size(self, _name, bytes_count, expected):
+ assert _format_data_size(bytes_count) == expected
+
+
+class TestApiQueriesEnforcementEnabled(BaseTest):
+ def setUp(self):
+ super().setUp()
+ _enforcement_flag_cache.clear()
+
+ def test_flag_on_returns_true(self):
+ with patch("posthog.hogql_queries.query_runner.posthoganalytics.feature_enabled", return_value=True):
+ assert _api_queries_enforcement_enabled(self.team) is True
+
+ def test_flag_result_is_cached_within_ttl(self):
+ with patch(
+ "posthog.hogql_queries.query_runner.posthoganalytics.feature_enabled", return_value=True
+ ) as mock_flag:
+ assert _api_queries_enforcement_enabled(self.team) is True
+ assert _api_queries_enforcement_enabled(self.team) is True
+ assert mock_flag.call_count == 1
+
+ def test_flag_service_error_fails_open_to_false(self):
+ with patch(
+ "posthog.hogql_queries.query_runner.posthoganalytics.feature_enabled",
+ side_effect=Exception("flag service down"),
+ ):
+ assert _api_queries_enforcement_enabled(self.team) is False
+
+
+@override_settings(API_QUERIES_ENABLED=True)
+class TestApiQueriesQuotaEnforcement(BaseTest):
+ def setUp(self):
+ super().setUp()
+ _enforcement_flag_cache.clear()
+
+ def _runner(self):
+ runner = HogQLQueryRunner(query=HogQLQuery(query="select 1"), team=self.team)
+ runner.is_query_service = True
+ return runner
+
+ def test_not_limited_is_noop(self):
+ with patch("posthog.hogql_queries.query_runner.get_api_queries_quota_limited_until", return_value=None):
+ self._runner()._enforce_api_queries_quota() # must not raise
+
+ def test_limited_flag_off_observes_and_runs(self):
+ before = API_QUERIES_QUOTA_LIMITED_COUNTER.labels(surface="api", outcome="observed")._value.get()
+ with (
+ patch(
+ "posthog.hogql_queries.query_runner.get_api_queries_quota_limited_until",
+ return_value=datetime(2026, 9, 1, tzinfo=UTC),
+ ),
+ patch("posthog.hogql_queries.query_runner._api_queries_enforcement_enabled", return_value=False),
+ ):
+ self._runner()._enforce_api_queries_quota() # must not raise
+ after = API_QUERIES_QUOTA_LIMITED_COUNTER.labels(surface="api", outcome="observed")._value.get()
+ assert after == before + 1
+
+ def test_limited_flag_on_raises_402(self):
+ before = API_QUERIES_QUOTA_LIMITED_COUNTER.labels(surface="api", outcome="enforced")._value.get()
+ with (
+ patch(
+ "posthog.hogql_queries.query_runner.get_api_queries_quota_limited_until",
+ return_value=datetime(2026, 9, 1, tzinfo=UTC),
+ ),
+ patch("posthog.hogql_queries.query_runner._api_queries_enforcement_enabled", return_value=True),
+ ):
+ with pytest.raises(APIQueriesQuotaExceeded) as exc_info:
+ self._runner()._enforce_api_queries_quota()
+ assert exc_info.value.status_code == 402
+ after = API_QUERIES_QUOTA_LIMITED_COUNTER.labels(surface="api", outcome="enforced")._value.get()
+ assert after == before + 1
+
+ def test_flag_service_error_fails_open_to_observe(self):
+ with (
+ patch(
+ "posthog.hogql_queries.query_runner.get_api_queries_quota_limited_until",
+ return_value=datetime(2026, 9, 1, tzinfo=UTC),
+ ),
+ patch(
+ "posthog.hogql_queries.query_runner.posthoganalytics.feature_enabled",
+ side_effect=Exception("flag service down"),
+ ),
+ ):
+ self._runner()._enforce_api_queries_quota() # must not raise
+
+ def test_call_with_rate_limits_enforces_quota_for_query_service(self):
+ runner = self._runner()
+ with (
+ patch.object(runner, "calculate", return_value="stub result"),
+ patch(
+ "posthog.hogql_queries.query_runner.get_api_queries_quota_limited_until",
+ return_value=datetime(2026, 9, 1, tzinfo=UTC),
+ ),
+ patch("posthog.hogql_queries.query_runner._api_queries_enforcement_enabled", return_value=True),
+ ):
+ with pytest.raises(APIQueriesQuotaExceeded):
+ runner._call_with_rate_limits(dashboard_id=None)
+
+ def test_call_with_rate_limits_skips_enforcement_for_non_query_service(self):
+ runner = HogQLQueryRunner(query=HogQLQuery(query="select 1"), team=self.team)
+ runner.is_query_service = False
+ with (
+ patch.object(runner, "calculate", return_value="stub result"),
+ patch("posthog.hogql_queries.query_runner.get_api_queries_quota_limited_until") as check,
+ ):
+ result, _duration_ms = runner._call_with_rate_limits(dashboard_id=None)
+ assert result == "stub result"
+ check.assert_not_called()
+
+ def test_concurrency_limit_no_longer_returns_zero_for_limited_teams(self):
+ # get_api_queries_concurrency_limit reads the plain `posthog.settings` module
+ # (not django.conf.settings), so @override_settings on the class doesn't reach it.
+ runner = self._runner()
+ with (
+ patch("posthog.hogql_queries.query_runner.settings.API_QUERIES_ENABLED", True),
+ patch("ee.billing.quota_limiting.list_limited_team_attributes", return_value=[self.team.api_token]),
+ ):
+ # Quota state (list_limited_team_attributes) must not affect the concurrency limit.
+ assert runner.get_api_queries_concurrency_limit() != 0
diff --git a/posthog/management/migration_analysis/hot_table_acknowledged_migrations.txt b/posthog/management/migration_analysis/hot_table_acknowledged_migrations.txt
index f2895cb095c9..91f021b57389 100644
--- a/posthog/management/migration_analysis/hot_table_acknowledged_migrations.txt
+++ b/posthog/management/migration_analysis/hot_table_acknowledged_migrations.txt
@@ -20,3 +20,4 @@ posthog.1244_team_event_retention_months
posthog.1262_organization_members_can_see_org_members
posthog.1272_user_ui_configuration
posthog.1284_organization_enforce_verified_domains
+posthog.1304_organization_has_active_subscription
diff --git a/posthog/migrations/1304_organization_has_active_subscription.py b/posthog/migrations/1304_organization_has_active_subscription.py
new file mode 100644
index 000000000000..7b519323c1e5
--- /dev/null
+++ b/posthog/migrations/1304_organization_has_active_subscription.py
@@ -0,0 +1,15 @@
+# Generated by Django 5.2.17 on 2026-08-12 21:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [("posthog", "1303_taggeditem_replay_scanner_unique_constraint")]
+
+ operations = [
+ migrations.AddField(
+ model_name="organization",
+ name="has_active_subscription",
+ field=models.BooleanField(blank=True, null=True),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 4502addd95d2..0679f7ce6c96 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1303_taggeditem_replay_scanner_unique_constraint
+1304_organization_has_active_subscription
diff --git a/posthog/models/organization.py b/posthog/models/organization.py
index a1298c4750f8..cb8a31024665 100644
--- a/posthog/models/organization.py
+++ b/posthog/models/organization.py
@@ -335,6 +335,9 @@ class Organization(ModelActivityMixin, UUIDTModel):
oauth_applications: models.Manager[Any]
# Scoring levels defined in billing::customer::TrustScores
customer_trust_scores = models.JSONField(default=dict, null=True, blank=True)
+ # Managed by Billing: whether the org had an active subscription (or active trial)
+ # at last customer sync. NULL = never synced = unknown; consumers must fail open on NULL.
+ has_active_subscription = models.BooleanField(null=True, blank=True)
# DEPRECATED attributes (should be removed on next major version)
setup_section_2_completed = models.BooleanField(default=True)
diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
index 60a2b63cf8b6..daca293b0b59 100644
--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
@@ -378,6 +378,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -517,6 +518,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -569,6 +571,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -647,6 +650,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1498,6 +1502,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1637,6 +1642,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1689,6 +1695,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1760,6 +1767,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1811,6 +1819,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2262,6 +2271,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2314,6 +2324,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2392,6 +2403,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr
index 31466b8aa350..d96f172e4ce6 100644
--- a/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr
+++ b/posthog/session_recordings/test/__snapshots__/test_session_recordings.ambr
@@ -88,6 +88,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -432,6 +433,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -484,6 +486,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -562,6 +565,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -613,6 +617,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -918,6 +923,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1259,6 +1265,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1311,6 +1318,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1389,6 +1397,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1440,6 +1449,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1745,6 +1755,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2083,6 +2094,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2135,6 +2147,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2213,6 +2226,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2264,6 +2278,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2569,6 +2584,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2907,6 +2923,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -2959,6 +2976,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3037,6 +3055,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3088,6 +3107,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3393,6 +3413,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3734,6 +3755,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3786,6 +3808,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3864,6 +3887,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -3915,6 +3939,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4220,6 +4245,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4561,6 +4587,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4613,6 +4640,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4691,6 +4719,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -4742,6 +4771,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5047,6 +5077,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5388,6 +5419,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5440,6 +5472,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5518,6 +5551,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5569,6 +5603,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -5874,6 +5909,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -6471,6 +6507,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -6610,6 +6647,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -6662,6 +6700,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -6740,6 +6779,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -6791,6 +6831,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7319,6 +7360,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7458,6 +7500,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7510,6 +7553,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7634,6 +7678,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -7685,6 +7730,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8133,6 +8179,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8241,6 +8288,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8380,6 +8428,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8432,6 +8481,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8510,6 +8560,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8561,6 +8612,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -8902,6 +8954,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9216,6 +9269,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9355,6 +9409,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9407,6 +9462,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9460,6 +9516,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9538,6 +9595,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -9589,6 +9647,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10093,6 +10152,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10144,6 +10204,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10285,6 +10346,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10782,6 +10844,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10828,6 +10891,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -10967,6 +11031,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11019,6 +11084,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11097,6 +11163,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11148,6 +11215,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11667,6 +11735,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11806,6 +11875,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11858,6 +11928,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11936,6 +12007,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -11987,6 +12059,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12038,6 +12111,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12483,6 +12557,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12588,6 +12663,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12727,6 +12803,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12779,6 +12856,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12857,6 +12935,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -12908,6 +12987,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13512,6 +13592,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13651,6 +13732,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13799,6 +13881,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13877,6 +13960,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -13928,6 +14012,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14469,6 +14554,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14608,6 +14694,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14660,6 +14747,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14738,6 +14826,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -14789,6 +14878,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index e70a61c6bc63..3a992d2cf252 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -1077,6 +1077,12 @@ KAFKA_PRODUCE_ACK_TIMEOUT_SECONDS = int(os.getenv("KAFKA_PRODUCE_ACK_TIMEOUT_SEC
# if `true` we highly increase the rate limit on /query endpoint and limit the number of concurrent queries
API_QUERIES_ENABLED = get_from_env("API_QUERIES_ENABLED", False, type_cast=str_to_bool)
+# Monthly read-bytes allowance for organizations without an active subscription,
+# enforced from the product-owned counter in posthog/api_queries_quota.py. 0 disables it.
+API_QUERIES_FREE_TIER_READ_BYTES_LIMIT: int = get_from_env(
+ "API_QUERIES_FREE_TIER_READ_BYTES_LIMIT", 50_000_000_000_000, type_cast=int
+)
+
####
# /api/environments deprecation
diff --git a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
index 4490b452775b..85f8eac75236 100644
--- a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
+++ b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
@@ -475,6 +475,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -760,6 +761,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1399,6 +1401,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1780,6 +1783,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/posthog/test/test_api_queries_quota_counter.py b/posthog/test/test_api_queries_quota_counter.py
new file mode 100644
index 000000000000..11958456f2f8
--- /dev/null
+++ b/posthog/test/test_api_queries_quota_counter.py
@@ -0,0 +1,105 @@
+from datetime import UTC, datetime
+from types import SimpleNamespace
+
+import pytest
+from posthog.test.base import BaseTest, ClickhouseTestMixin
+from unittest.mock import MagicMock, patch
+
+from posthog.api_queries_quota import (
+ API_QUERIES_QUOTA_ERRORS_COUNTER,
+ get_api_queries_bytes,
+ increment_api_queries_bytes,
+ next_counter_reset,
+)
+from posthog.clickhouse.client import sync_execute
+from posthog.clickhouse.query_tagging import reset_query_tags, tag_queries
+
+
+class TestApiQueriesQuotaCounter(BaseTest):
+ def test_increment_then_read_round_trips(self):
+ increment_api_queries_bytes("org-a", 1000)
+ increment_api_queries_bytes("org-a", 500)
+ assert get_api_queries_bytes("org-a") == 1500
+
+ def test_missing_key_reads_zero(self):
+ assert get_api_queries_bytes("org-never-seen") == 0
+
+ def test_zero_bytes_is_noop(self):
+ increment_api_queries_bytes("org-a", 0)
+ assert get_api_queries_bytes("org-a") == 0
+
+ def test_redis_errors_fail_open(self):
+ with patch("posthog.api_queries_quota.get_client", side_effect=Exception("redis down")):
+ increment_api_queries_bytes("org-a", 1000) # must not raise
+ assert get_api_queries_bytes("org-a") == 0
+
+ def test_increment_error_increments_error_counter(self):
+ before = API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="increment")._value.get()
+ with patch("posthog.api_queries_quota.get_client", side_effect=Exception("redis down")):
+ increment_api_queries_bytes("org-a", 1000)
+ after = API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="increment")._value.get()
+ assert after == before + 1
+
+ def test_read_error_increments_error_counter(self):
+ before = API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="read")._value.get()
+ with patch("posthog.api_queries_quota.get_client", side_effect=Exception("redis down")):
+ get_api_queries_bytes("org-a")
+ after = API_QUERIES_QUOTA_ERRORS_COUNTER.labels(op="read")._value.get()
+ assert after == before + 1
+
+ def test_next_counter_reset_rolls_month_and_year(self):
+ assert next_counter_reset(datetime(2026, 8, 12, tzinfo=UTC)) == datetime(2026, 9, 1, tzinfo=UTC)
+ assert next_counter_reset(datetime(2026, 12, 31, tzinfo=UTC)) == datetime(2027, 1, 1, tzinfo=UTC)
+
+
+class TestChargeableByteMetering(ClickhouseTestMixin, BaseTest):
+ # LIMIT applies to the aggregate's single output row, not to system.numbers itself,
+ # so bound the scan inside a subquery or the read never terminates.
+ BOUNDED_QUERY = "SELECT sum(number) FROM (SELECT number FROM system.numbers LIMIT 10000)"
+
+ def test_chargeable_tagged_query_increments_counter(self):
+ tag_queries(chargeable=1, org_id=self.organization.id)
+ try:
+ sync_execute(self.BOUNDED_QUERY)
+ finally:
+ reset_query_tags()
+ assert get_api_queries_bytes(str(self.organization.id)) > 0
+
+ def test_untagged_query_does_not_count(self):
+ sync_execute(self.BOUNDED_QUERY)
+ assert get_api_queries_bytes(str(self.organization.id)) == 0
+
+
+class QueryDied(Exception):
+ pass
+
+
+class TestFailedQueryMetering(BaseTest):
+ def _sync_execute_with_fake_client(self, fake_client):
+ pool = MagicMock()
+ pool.__enter__.return_value = fake_client
+ tag_queries(chargeable=1, org_id=self.organization.id)
+ try:
+ with patch("posthog.clickhouse.client.execute.get_client_from_pool", return_value=pool):
+ with pytest.raises(QueryDied):
+ sync_execute("SELECT 1")
+ finally:
+ reset_query_tags()
+
+ def test_killed_query_meters_progress_reported_before_death(self):
+ fake_client = MagicMock()
+
+ def die_mid_scan(*args, **kwargs):
+ fake_client.last_query = SimpleNamespace(progress=SimpleNamespace(bytes=4444))
+ raise QueryDied("timeout")
+
+ fake_client.execute.side_effect = die_mid_scan
+ self._sync_execute_with_fake_client(fake_client)
+ assert get_api_queries_bytes(str(self.organization.id)) == 4444
+
+ def test_connection_failure_does_not_remeter_previous_query(self):
+ fake_client = MagicMock()
+ fake_client.last_query = SimpleNamespace(progress=SimpleNamespace(bytes=9999))
+ fake_client.execute.side_effect = QueryDied("network down before connecting")
+ self._sync_execute_with_fake_client(fake_client)
+ assert get_api_queries_bytes(str(self.organization.id)) == 0
diff --git a/products/actions/backend/api/test/__snapshots__/test_action.ambr b/products/actions/backend/api/test/__snapshots__/test_action.ambr
index b275a50d7b25..ff7054bf4152 100644
--- a/products/actions/backend/api/test/__snapshots__/test_action.ambr
+++ b/products/actions/backend/api/test/__snapshots__/test_action.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -219,6 +220,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -285,6 +287,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -363,6 +366,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -563,6 +567,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -702,6 +707,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -842,6 +848,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -908,6 +915,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -986,6 +994,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1161,6 +1170,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1239,6 +1249,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1412,6 +1423,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr b/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr
index da65dd65a14a..37a433e501ff 100644
--- a/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr
+++ b/products/annotations/backend/api/test/__snapshots__/test_annotation.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -219,6 +220,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -285,6 +287,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -363,6 +366,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -572,6 +576,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -711,6 +716,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -851,6 +857,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -917,6 +924,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -995,6 +1003,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1179,6 +1188,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1257,6 +1267,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1363,6 +1374,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/products/cdp/backend/api/test/__snapshots__/test_plugin.ambr b/products/cdp/backend/api/test/__snapshots__/test_plugin.ambr
index 26527a9804cf..277c69ae1185 100644
--- a/products/cdp/backend/api/test/__snapshots__/test_plugin.ambr
+++ b/products/cdp/backend/api/test/__snapshots__/test_plugin.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -133,6 +134,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -184,6 +186,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -269,6 +272,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -367,6 +371,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -411,6 +416,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -464,6 +470,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -508,6 +515,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -559,6 +567,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -644,6 +653,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -742,6 +752,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -786,6 +797,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -839,6 +851,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -890,6 +903,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -984,6 +998,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1036,6 +1051,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1087,6 +1103,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1193,6 +1210,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1237,6 +1255,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr
index 1aed8df5c0ba..1347d8c4bac2 100644
--- a/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr
+++ b/products/feature_flags/backend/api/test/__snapshots__/test_feature_flag.ambr
@@ -528,6 +528,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -982,6 +983,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1496,6 +1498,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1574,6 +1577,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr
index 72972ad6a034..7cee74b255fc 100644
--- a/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr
+++ b/products/feature_flags/backend/api/test/__snapshots__/test_organization_feature_flag.ambr
@@ -80,6 +80,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -407,6 +408,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -583,6 +585,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -671,6 +674,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -888,6 +892,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -979,6 +984,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1065,6 +1071,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1310,6 +1317,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1434,6 +1442,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1485,6 +1494,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1559,6 +1569,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1758,6 +1769,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1818,6 +1830,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1989,6 +2002,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
diff --git a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr
index 38cc5436f565..9aa221d4f6ca 100644
--- a/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr
+++ b/products/product_analytics/backend/api/test/__snapshots__/test_insight.ambr
@@ -490,6 +490,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -736,6 +737,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -875,6 +877,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1015,6 +1018,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1067,6 +1071,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1145,6 +1150,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1462,6 +1468,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",
@@ -1540,6 +1547,7 @@
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
+ "posthog_organization"."has_active_subscription",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist",