Skip to content

Commit

Permalink
fix: python when sample rate is 0 (PostHog#27909)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
pauldambra and github-actions[bot] authored Jan 28, 2025
1 parent 0b7e875 commit 8c5a64d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 345 deletions.
5 changes: 4 additions & 1 deletion posthog/api/decide.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ def _session_recording_config_response(request: HttpRequest, team: Team) -> bool
try:
if team.session_recording_opt_in and not _session_recording_domain_not_allowed(team, request):
capture_console_logs = True if team.capture_console_log_opt_in else False
sample_rate = str(team.session_recording_sample_rate) if team.session_recording_sample_rate else None
sample_rate = (
str(team.session_recording_sample_rate) if team.session_recording_sample_rate is not None else None
)

if sample_rate == "1.00":
sample_rate = None

Expand Down
340 changes: 0 additions & 340 deletions posthog/api/test/__snapshots__/test_decide.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -1858,47 +1858,6 @@
LIMIT 21
'''
# ---
# name: TestDecide.test_flag_with_behavioural_cohorts.22
'''
SELECT "posthog_cohort"."id",
"posthog_cohort"."name",
"posthog_cohort"."description",
"posthog_cohort"."team_id",
"posthog_cohort"."deleted",
"posthog_cohort"."filters",
"posthog_cohort"."query",
"posthog_cohort"."version",
"posthog_cohort"."pending_version",
"posthog_cohort"."count",
"posthog_cohort"."created_by_id",
"posthog_cohort"."created_at",
"posthog_cohort"."is_calculating",
"posthog_cohort"."last_calculation",
"posthog_cohort"."errors_calculating",
"posthog_cohort"."last_error_at",
"posthog_cohort"."is_static",
"posthog_cohort"."groups"
FROM "posthog_cohort"
WHERE (NOT "posthog_cohort"."deleted"
AND "posthog_cohort"."team_id" = 99999)
'''
# ---
# name: TestDecide.test_flag_with_behavioural_cohorts.23
'''
SELECT "posthog_group"."id",
"posthog_group"."team_id",
"posthog_group"."group_key",
"posthog_group"."group_type_index",
"posthog_group"."group_properties",
"posthog_group"."created_at",
"posthog_group"."properties_last_updated_at",
"posthog_group"."properties_last_operation",
"posthog_group"."version"
FROM "posthog_group"
WHERE "posthog_group"."team_id" = 99999
LIMIT 21
'''
# ---
# name: TestDecide.test_flag_with_behavioural_cohorts.3
'''
SELECT "posthog_team"."id",
Expand Down Expand Up @@ -2936,43 +2895,6 @@
AND "posthog_person"."team_id" = 99999)
'''
# ---
# name: TestDecide.test_flag_with_regular_cohorts.22
'''
SELECT "posthog_cohort"."id",
"posthog_cohort"."name",
"posthog_cohort"."description",
"posthog_cohort"."team_id",
"posthog_cohort"."deleted",
"posthog_cohort"."filters",
"posthog_cohort"."query",
"posthog_cohort"."version",
"posthog_cohort"."pending_version",
"posthog_cohort"."count",
"posthog_cohort"."created_by_id",
"posthog_cohort"."created_at",
"posthog_cohort"."is_calculating",
"posthog_cohort"."last_calculation",
"posthog_cohort"."errors_calculating",
"posthog_cohort"."last_error_at",
"posthog_cohort"."is_static",
"posthog_cohort"."groups"
FROM "posthog_cohort"
WHERE (NOT "posthog_cohort"."deleted"
AND "posthog_cohort"."team_id" = 99999)
'''
# ---
# name: TestDecide.test_flag_with_regular_cohorts.23
'''
SELECT (("posthog_person"."properties" -> '$some_prop_1') = '"something_1"'::jsonb
AND "posthog_person"."properties" ? '$some_prop_1'
AND NOT (("posthog_person"."properties" -> '$some_prop_1') = 'null'::jsonb)) AS "flag_X_condition_0"
FROM "posthog_person"
INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id")
WHERE ("posthog_persondistinctid"."distinct_id" = 'another_id'
AND "posthog_persondistinctid"."team_id" = 99999
AND "posthog_person"."team_id" = 99999)
'''
# ---
# name: TestDecide.test_flag_with_regular_cohorts.3
'''
SELECT "posthog_team"."id",
Expand Down Expand Up @@ -4007,38 +3929,6 @@
AND "posthog_pluginconfig"."team_id" = 99999)
'''
# ---
# name: TestDecide.test_web_app_queries.22
'''
SELECT "posthog_pluginconfig"."id",
"posthog_pluginconfig"."web_token",
"posthog_pluginsourcefile"."updated_at",
"posthog_plugin"."updated_at",
"posthog_pluginconfig"."updated_at"
FROM "posthog_pluginconfig"
INNER JOIN "posthog_plugin" ON ("posthog_pluginconfig"."plugin_id" = "posthog_plugin"."id")
INNER JOIN "posthog_pluginsourcefile" ON ("posthog_plugin"."id" = "posthog_pluginsourcefile"."plugin_id")
WHERE ("posthog_pluginconfig"."enabled"
AND "posthog_pluginsourcefile"."filename" = 'site.ts'
AND "posthog_pluginsourcefile"."status" = 'TRANSPILED'
AND "posthog_pluginconfig"."team_id" = 99999)
'''
# ---
# name: TestDecide.test_web_app_queries.23
'''
SELECT "posthog_pluginconfig"."id",
"posthog_pluginconfig"."web_token",
"posthog_pluginsourcefile"."updated_at",
"posthog_plugin"."updated_at",
"posthog_pluginconfig"."updated_at"
FROM "posthog_pluginconfig"
INNER JOIN "posthog_plugin" ON ("posthog_pluginconfig"."plugin_id" = "posthog_plugin"."id")
INNER JOIN "posthog_pluginsourcefile" ON ("posthog_plugin"."id" = "posthog_pluginsourcefile"."plugin_id")
WHERE ("posthog_pluginconfig"."enabled"
AND "posthog_pluginsourcefile"."filename" = 'site.ts'
AND "posthog_pluginsourcefile"."status" = 'TRANSPILED'
AND "posthog_pluginconfig"."team_id" = 99999)
'''
# ---
# name: TestDecide.test_web_app_queries.3
'''
SELECT "posthog_hogfunction"."id",
Expand Down Expand Up @@ -6070,36 +5960,6 @@
'site_app'))
'''
# ---
# name: TestDecideRemoteConfig.test_decide_doesnt_error_out_when_database_is_down.48
'''
SELECT "posthog_hogfunction"."id",
"posthog_hogfunction"."team_id",
"posthog_hogfunction"."name",
"posthog_hogfunction"."description",
"posthog_hogfunction"."created_at",
"posthog_hogfunction"."created_by_id",
"posthog_hogfunction"."deleted",
"posthog_hogfunction"."updated_at",
"posthog_hogfunction"."enabled",
"posthog_hogfunction"."type",
"posthog_hogfunction"."icon_url",
"posthog_hogfunction"."hog",
"posthog_hogfunction"."bytecode",
"posthog_hogfunction"."transpiled",
"posthog_hogfunction"."inputs_schema",
"posthog_hogfunction"."inputs",
"posthog_hogfunction"."encrypted_inputs",
"posthog_hogfunction"."filters",
"posthog_hogfunction"."mappings",
"posthog_hogfunction"."masking",
"posthog_hogfunction"."template_id"
FROM "posthog_hogfunction"
WHERE ("posthog_hogfunction"."enabled"
AND "posthog_hogfunction"."team_id" = 99999
AND "posthog_hogfunction"."type" IN ('site_destination',
'site_app'))
'''
# ---
# name: TestDecideRemoteConfig.test_decide_doesnt_error_out_when_database_is_down.5
'''
SELECT "posthog_organizationmembership"."id",
Expand Down Expand Up @@ -7579,108 +7439,6 @@
LIMIT 21
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_behavioural_cohorts.34
'''
SELECT "posthog_hogfunction"."id",
"posthog_hogfunction"."team_id",
"posthog_hogfunction"."name",
"posthog_hogfunction"."description",
"posthog_hogfunction"."created_at",
"posthog_hogfunction"."created_by_id",
"posthog_hogfunction"."deleted",
"posthog_hogfunction"."updated_at",
"posthog_hogfunction"."enabled",
"posthog_hogfunction"."type",
"posthog_hogfunction"."icon_url",
"posthog_hogfunction"."hog",
"posthog_hogfunction"."bytecode",
"posthog_hogfunction"."transpiled",
"posthog_hogfunction"."inputs_schema",
"posthog_hogfunction"."inputs",
"posthog_hogfunction"."encrypted_inputs",
"posthog_hogfunction"."filters",
"posthog_hogfunction"."mappings",
"posthog_hogfunction"."masking",
"posthog_hogfunction"."template_id"
FROM "posthog_hogfunction"
WHERE ("posthog_hogfunction"."enabled"
AND "posthog_hogfunction"."team_id" = 99999
AND "posthog_hogfunction"."type" IN ('site_destination',
'site_app'))
LIMIT 21
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_behavioural_cohorts.35
'''
SELECT "posthog_hogfunction"."id",
"posthog_hogfunction"."team_id",
"posthog_hogfunction"."name",
"posthog_hogfunction"."description",
"posthog_hogfunction"."created_at",
"posthog_hogfunction"."created_by_id",
"posthog_hogfunction"."deleted",
"posthog_hogfunction"."updated_at",
"posthog_hogfunction"."enabled",
"posthog_hogfunction"."type",
"posthog_hogfunction"."icon_url",
"posthog_hogfunction"."hog",
"posthog_hogfunction"."bytecode",
"posthog_hogfunction"."transpiled",
"posthog_hogfunction"."inputs_schema",
"posthog_hogfunction"."inputs",
"posthog_hogfunction"."encrypted_inputs",
"posthog_hogfunction"."filters",
"posthog_hogfunction"."mappings",
"posthog_hogfunction"."masking",
"posthog_hogfunction"."template_id"
FROM "posthog_hogfunction"
WHERE ("posthog_hogfunction"."enabled"
AND "posthog_hogfunction"."team_id" = 99999
AND "posthog_hogfunction"."type" IN ('site_destination',
'site_app'))
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_behavioural_cohorts.36
'''
SELECT "posthog_cohort"."id",
"posthog_cohort"."name",
"posthog_cohort"."description",
"posthog_cohort"."team_id",
"posthog_cohort"."deleted",
"posthog_cohort"."filters",
"posthog_cohort"."query",
"posthog_cohort"."version",
"posthog_cohort"."pending_version",
"posthog_cohort"."count",
"posthog_cohort"."created_by_id",
"posthog_cohort"."created_at",
"posthog_cohort"."is_calculating",
"posthog_cohort"."last_calculation",
"posthog_cohort"."errors_calculating",
"posthog_cohort"."last_error_at",
"posthog_cohort"."is_static",
"posthog_cohort"."groups"
FROM "posthog_cohort"
WHERE (NOT "posthog_cohort"."deleted"
AND "posthog_cohort"."team_id" = 99999)
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_behavioural_cohorts.37
'''
SELECT "posthog_group"."id",
"posthog_group"."team_id",
"posthog_group"."group_key",
"posthog_group"."group_type_index",
"posthog_group"."group_properties",
"posthog_group"."created_at",
"posthog_group"."properties_last_updated_at",
"posthog_group"."properties_last_operation",
"posthog_group"."version"
FROM "posthog_group"
WHERE "posthog_group"."team_id" = 99999
LIMIT 21
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_behavioural_cohorts.4
'''
SELECT COUNT(*) AS "__count"
Expand Down Expand Up @@ -9316,104 +9074,6 @@
AND "posthog_person"."team_id" = 99999)
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_regular_cohorts.34
'''
SELECT "posthog_hogfunction"."id",
"posthog_hogfunction"."team_id",
"posthog_hogfunction"."name",
"posthog_hogfunction"."description",
"posthog_hogfunction"."created_at",
"posthog_hogfunction"."created_by_id",
"posthog_hogfunction"."deleted",
"posthog_hogfunction"."updated_at",
"posthog_hogfunction"."enabled",
"posthog_hogfunction"."type",
"posthog_hogfunction"."icon_url",
"posthog_hogfunction"."hog",
"posthog_hogfunction"."bytecode",
"posthog_hogfunction"."transpiled",
"posthog_hogfunction"."inputs_schema",
"posthog_hogfunction"."inputs",
"posthog_hogfunction"."encrypted_inputs",
"posthog_hogfunction"."filters",
"posthog_hogfunction"."mappings",
"posthog_hogfunction"."masking",
"posthog_hogfunction"."template_id"
FROM "posthog_hogfunction"
WHERE ("posthog_hogfunction"."enabled"
AND "posthog_hogfunction"."team_id" = 99999
AND "posthog_hogfunction"."type" IN ('site_destination',
'site_app'))
LIMIT 21
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_regular_cohorts.35
'''
SELECT "posthog_hogfunction"."id",
"posthog_hogfunction"."team_id",
"posthog_hogfunction"."name",
"posthog_hogfunction"."description",
"posthog_hogfunction"."created_at",
"posthog_hogfunction"."created_by_id",
"posthog_hogfunction"."deleted",
"posthog_hogfunction"."updated_at",
"posthog_hogfunction"."enabled",
"posthog_hogfunction"."type",
"posthog_hogfunction"."icon_url",
"posthog_hogfunction"."hog",
"posthog_hogfunction"."bytecode",
"posthog_hogfunction"."transpiled",
"posthog_hogfunction"."inputs_schema",
"posthog_hogfunction"."inputs",
"posthog_hogfunction"."encrypted_inputs",
"posthog_hogfunction"."filters",
"posthog_hogfunction"."mappings",
"posthog_hogfunction"."masking",
"posthog_hogfunction"."template_id"
FROM "posthog_hogfunction"
WHERE ("posthog_hogfunction"."enabled"
AND "posthog_hogfunction"."team_id" = 99999
AND "posthog_hogfunction"."type" IN ('site_destination',
'site_app'))
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_regular_cohorts.36
'''
SELECT "posthog_cohort"."id",
"posthog_cohort"."name",
"posthog_cohort"."description",
"posthog_cohort"."team_id",
"posthog_cohort"."deleted",
"posthog_cohort"."filters",
"posthog_cohort"."query",
"posthog_cohort"."version",
"posthog_cohort"."pending_version",
"posthog_cohort"."count",
"posthog_cohort"."created_by_id",
"posthog_cohort"."created_at",
"posthog_cohort"."is_calculating",
"posthog_cohort"."last_calculation",
"posthog_cohort"."errors_calculating",
"posthog_cohort"."last_error_at",
"posthog_cohort"."is_static",
"posthog_cohort"."groups"
FROM "posthog_cohort"
WHERE (NOT "posthog_cohort"."deleted"
AND "posthog_cohort"."team_id" = 99999)
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_regular_cohorts.37
'''
SELECT (("posthog_person"."properties" -> '$some_prop_1') = '"something_1"'::jsonb
AND "posthog_person"."properties" ? '$some_prop_1'
AND NOT (("posthog_person"."properties" -> '$some_prop_1') = 'null'::jsonb)) AS "flag_X_condition_0"
FROM "posthog_person"
INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id")
WHERE ("posthog_persondistinctid"."distinct_id" = 'another_id'
AND "posthog_persondistinctid"."team_id" = 99999
AND "posthog_person"."team_id" = 99999)
'''
# ---
# name: TestDecideRemoteConfig.test_flag_with_regular_cohorts.4
'''
SELECT COUNT(*) AS "__count"
Expand Down
Loading

0 comments on commit 8c5a64d

Please sign in to comment.