Skip to content

Commit

Permalink
feat: add decide field based on env var for rollout of identified_onl…
Browse files Browse the repository at this point in the history
…y as default (#25662)
  • Loading branch information
raquelmsmith authored Oct 17, 2024
1 parent c4a87c7 commit 532ecc6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 15 additions & 4 deletions posthog/api/decide.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
from sentry_sdk import capture_exception
from statshog.defaults.django import statsd

from posthog.geoip import get_geoip_properties
from posthog.api.survey import SURVEY_TARGETING_FLAG_PREFIX
from posthog.api.utils import get_project_id, get_token, hostname_in_allowed_url_list, parse_domain
from posthog.api.utils import (
get_project_id,
get_token,
hostname_in_allowed_url_list,
parse_domain,
)
from posthog.database_healthcheck import DATABASE_FOR_FLAG_MATCHING
from posthog.exceptions import (
UnspecifiedCompressionFallbackParsingError,
RequestParsingError,
UnspecifiedCompressionFallbackParsingError,
generate_exception_response,
)
from posthog.geoip import get_geoip_properties
from posthog.logging.timing import timed
from posthog.metrics import LABEL_TEAM_ID
from posthog.models import Team, User
Expand Down Expand Up @@ -265,7 +270,11 @@ def get_decide(request: HttpRequest):
response["sessionRecording"] = _session_recording_config_response(request, team, token)

if settings.DECIDE_SESSION_REPLAY_QUOTA_CHECK:
from ee.billing.quota_limiting import QuotaLimitingCaches, QuotaResource, list_limited_team_attributes
from ee.billing.quota_limiting import (
QuotaLimitingCaches,
QuotaResource,
list_limited_team_attributes,
)

limited_tokens_recordings = list_limited_team_attributes(
QuotaResource.RECORDINGS, QuotaLimitingCaches.QUOTA_LIMITER_CACHE_KEY
Expand All @@ -277,6 +286,8 @@ def get_decide(request: HttpRequest):

response["surveys"] = True if team.surveys_opt_in else False
response["heatmaps"] = True if team.heatmaps_opt_in else False
default_identified_only = team.pk >= settings.DEFAULT_IDENTIFIED_ONLY_TEAM_ID_MIN
response["defaultIdentifiedOnly"] = bool(default_identified_only)

site_apps = []
# errors mean the database is unavailable, bail in this case
Expand Down
5 changes: 4 additions & 1 deletion posthog/settings/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
from datetime import timedelta

from corsheaders.defaults import default_headers
import structlog
from corsheaders.defaults import default_headers

from posthog.settings.base_variables import BASE_DIR, DEBUG, TEST
from posthog.settings.utils import get_from_env, get_list, str_to_bool
Expand Down Expand Up @@ -41,6 +41,9 @@
DECIDE_BILLING_SAMPLING_RATE = get_from_env("DECIDE_BILLING_SAMPLING_RATE", 0.1, type_cast=float)
DECIDE_BILLING_ANALYTICS_TOKEN = get_from_env("DECIDE_BILLING_ANALYTICS_TOKEN", None, type_cast=str, optional=True)

# temporary, used for safe rollout of defaulting people into anonymous events / process_persons: identified_only
DEFAULT_IDENTIFIED_ONLY_TEAM_ID_MIN: int = get_from_env("DEFAULT_IDENTIFIED_ONLY_TEAM_ID_MIN", 1000000, type_cast=int)

# Decide regular request analytics
# Takes 3 possible formats, all separated by commas:
# A number: "2"
Expand Down

0 comments on commit 532ecc6

Please sign in to comment.