diff --git a/ee/billing/quota_limiting.py b/ee/billing/quota_limiting.py index 0809266b1db647..feb1dfe0c966c3 100644 --- a/ee/billing/quota_limiting.py +++ b/ee/billing/quota_limiting.py @@ -4,6 +4,7 @@ from typing import Dict, List, Mapping, Optional, Sequence, TypedDict, cast import dateutil.parser +import posthoganalytics from django.db.models import Q from django.utils import timezone from sentry_sdk import capture_exception @@ -23,6 +24,8 @@ QUOTA_LIMITER_CACHE_KEY = "@posthog/quota-limits/" +QUOTA_LIMIT_DATA_RETENTION_FLAG = "retain-data-past-quota-limit" + class QuotaResource(Enum): EVENTS = "events" @@ -89,6 +92,14 @@ def org_quota_limited_until(organization: Organization, resource: QuotaResource) if is_quota_limited and organization.never_drop_data: return None + if posthoganalytics.feature_enabled(QUOTA_LIMIT_DATA_RETENTION_FLAG): + # Don't drop data for this user but record that they __would have__ been + # limited. + report_organization_action( + organization.id, "quota_limiting_suspended", properties={"current_usage": todays_usage} + ) + return None + if is_quota_limited and billing_period_end: return billing_period_end