Skip to content

Commit

Permalink
use feature flag to control whether to quota limit or not
Browse files Browse the repository at this point in the history
  • Loading branch information
Bianca Yang committed Jan 26, 2024
1 parent 7f79a26 commit bad6b99
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ee/billing/quota_limiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit bad6b99

Please sign in to comment.