Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Updated remote config to include domain restrictions #26875

Merged
merged 21 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions posthog/api/remote_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def check_token(self, token: str):
class RemoteConfigAPIView(BaseRemoteConfigAPIView):
def get(self, request, token: str, *args, **kwargs):
try:
resource = RemoteConfig.get_config_via_token(self.check_token(token))
resource = RemoteConfig.get_config_via_token(self.check_token(token), domain=self.request.GET.get("domain"))
benjackwhite marked this conversation as resolved.
Show resolved Hide resolved
except RemoteConfig.DoesNotExist:
raise Http404()

Expand All @@ -33,7 +33,9 @@ def get(self, request, token: str, *args, **kwargs):
class RemoteConfigJSAPIView(BaseRemoteConfigAPIView):
def get(self, request, token: str, *args, **kwargs):
try:
script_content = RemoteConfig.get_config_js_via_token(self.check_token(token))
script_content = RemoteConfig.get_config_js_via_token(
self.check_token(token), domain=self.request.GET.get("domain")
)
except RemoteConfig.DoesNotExist:
raise Http404()

Expand All @@ -43,7 +45,9 @@ def get(self, request, token: str, *args, **kwargs):
class RemoteConfigArrayJSAPIView(BaseRemoteConfigAPIView):
def get(self, request, token: str, *args, **kwargs):
try:
script_content = RemoteConfig.get_array_js_via_token(self.check_token(token))
script_content = RemoteConfig.get_array_js_via_token(
self.check_token(token), domain=self.request.GET.get("domain")
)
except RemoteConfig.DoesNotExist:
raise Http404()

Expand Down
1,737 changes: 1,646 additions & 91 deletions posthog/api/test/__snapshots__/test_decide.ambr

Large diffs are not rendered by default.

423 changes: 419 additions & 4 deletions posthog/api/test/__snapshots__/test_early_access_feature.ambr

Large diffs are not rendered by default.

197 changes: 181 additions & 16 deletions posthog/api/test/__snapshots__/test_organization_feature_flag.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,72 @@
"posthog_hogfunction"."filters",
"posthog_hogfunction"."mappings",
"posthog_hogfunction"."masking",
"posthog_hogfunction"."template_id"
"posthog_hogfunction"."template_id",
"posthog_team"."id",
"posthog_team"."uuid",
"posthog_team"."organization_id",
"posthog_team"."project_id",
"posthog_team"."api_token",
"posthog_team"."app_urls",
"posthog_team"."name",
"posthog_team"."slack_incoming_webhook",
"posthog_team"."created_at",
"posthog_team"."updated_at",
"posthog_team"."anonymize_ips",
"posthog_team"."completed_snippet_onboarding",
"posthog_team"."has_completed_onboarding_for",
"posthog_team"."ingested_event",
"posthog_team"."autocapture_opt_out",
"posthog_team"."autocapture_web_vitals_opt_in",
"posthog_team"."autocapture_web_vitals_allowed_metrics",
"posthog_team"."autocapture_exceptions_opt_in",
"posthog_team"."autocapture_exceptions_errors_to_ignore",
"posthog_team"."person_processing_opt_out",
"posthog_team"."session_recording_opt_in",
"posthog_team"."session_recording_sample_rate",
"posthog_team"."session_recording_minimum_duration_milliseconds",
"posthog_team"."session_recording_linked_flag",
"posthog_team"."session_recording_network_payload_capture_config",
"posthog_team"."session_recording_url_trigger_config",
"posthog_team"."session_recording_url_blocklist_config",
"posthog_team"."session_recording_event_trigger_config",
"posthog_team"."session_replay_config",
"posthog_team"."survey_config",
"posthog_team"."capture_console_log_opt_in",
"posthog_team"."capture_performance_opt_in",
"posthog_team"."capture_dead_clicks",
"posthog_team"."surveys_opt_in",
"posthog_team"."heatmaps_opt_in",
"posthog_team"."session_recording_version",
"posthog_team"."signup_token",
"posthog_team"."is_demo",
"posthog_team"."access_control",
"posthog_team"."week_start_day",
"posthog_team"."inject_web_apps",
"posthog_team"."test_account_filters",
"posthog_team"."test_account_filters_default_checked",
"posthog_team"."path_cleaning_filters",
"posthog_team"."timezone",
"posthog_team"."data_attributes",
"posthog_team"."person_display_name_properties",
"posthog_team"."live_events_columns",
"posthog_team"."recording_domains",
"posthog_team"."primary_dashboard_id",
"posthog_team"."extra_settings",
"posthog_team"."modifiers",
"posthog_team"."correlation_config",
"posthog_team"."session_recording_retention_period_days",
"posthog_team"."plugins_opt_in",
"posthog_team"."opt_out_capture",
"posthog_team"."event_names",
"posthog_team"."event_names_with_usage",
"posthog_team"."event_properties",
"posthog_team"."event_properties_with_usage",
"posthog_team"."event_properties_numerical",
"posthog_team"."external_data_workspace_id",
"posthog_team"."external_data_workspace_last_synced_at"
FROM "posthog_hogfunction"
INNER JOIN "posthog_team" ON ("posthog_hogfunction"."team_id" = "posthog_team"."id")
WHERE ("posthog_hogfunction"."enabled"
AND "posthog_hogfunction"."team_id" = 99999
AND "posthog_hogfunction"."type" IN ('site_destination',
Expand Down Expand Up @@ -1596,8 +1660,72 @@
"posthog_hogfunction"."filters",
"posthog_hogfunction"."mappings",
"posthog_hogfunction"."masking",
"posthog_hogfunction"."template_id"
"posthog_hogfunction"."template_id",
"posthog_team"."id",
"posthog_team"."uuid",
"posthog_team"."organization_id",
"posthog_team"."project_id",
"posthog_team"."api_token",
"posthog_team"."app_urls",
"posthog_team"."name",
"posthog_team"."slack_incoming_webhook",
"posthog_team"."created_at",
"posthog_team"."updated_at",
"posthog_team"."anonymize_ips",
"posthog_team"."completed_snippet_onboarding",
"posthog_team"."has_completed_onboarding_for",
"posthog_team"."ingested_event",
"posthog_team"."autocapture_opt_out",
"posthog_team"."autocapture_web_vitals_opt_in",
"posthog_team"."autocapture_web_vitals_allowed_metrics",
"posthog_team"."autocapture_exceptions_opt_in",
"posthog_team"."autocapture_exceptions_errors_to_ignore",
"posthog_team"."person_processing_opt_out",
"posthog_team"."session_recording_opt_in",
"posthog_team"."session_recording_sample_rate",
"posthog_team"."session_recording_minimum_duration_milliseconds",
"posthog_team"."session_recording_linked_flag",
"posthog_team"."session_recording_network_payload_capture_config",
"posthog_team"."session_recording_url_trigger_config",
"posthog_team"."session_recording_url_blocklist_config",
"posthog_team"."session_recording_event_trigger_config",
"posthog_team"."session_replay_config",
"posthog_team"."survey_config",
"posthog_team"."capture_console_log_opt_in",
"posthog_team"."capture_performance_opt_in",
"posthog_team"."capture_dead_clicks",
"posthog_team"."surveys_opt_in",
"posthog_team"."heatmaps_opt_in",
"posthog_team"."session_recording_version",
"posthog_team"."signup_token",
"posthog_team"."is_demo",
"posthog_team"."access_control",
"posthog_team"."week_start_day",
"posthog_team"."inject_web_apps",
"posthog_team"."test_account_filters",
"posthog_team"."test_account_filters_default_checked",
"posthog_team"."path_cleaning_filters",
"posthog_team"."timezone",
"posthog_team"."data_attributes",
"posthog_team"."person_display_name_properties",
"posthog_team"."live_events_columns",
"posthog_team"."recording_domains",
"posthog_team"."primary_dashboard_id",
"posthog_team"."extra_settings",
"posthog_team"."modifiers",
"posthog_team"."correlation_config",
"posthog_team"."session_recording_retention_period_days",
"posthog_team"."plugins_opt_in",
"posthog_team"."opt_out_capture",
"posthog_team"."event_names",
"posthog_team"."event_names_with_usage",
"posthog_team"."event_properties",
"posthog_team"."event_properties_with_usage",
"posthog_team"."event_properties_numerical",
"posthog_team"."external_data_workspace_id",
"posthog_team"."external_data_workspace_last_synced_at"
FROM "posthog_hogfunction"
INNER JOIN "posthog_team" ON ("posthog_hogfunction"."team_id" = "posthog_team"."id")
WHERE ("posthog_hogfunction"."enabled"
AND "posthog_hogfunction"."team_id" = 99999
AND "posthog_hogfunction"."type" IN ('site_destination',
Expand Down Expand Up @@ -1908,24 +2036,61 @@
# ---
# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.53
'''
SELECT "posthog_instancesetting"."id",
"posthog_instancesetting"."key",
"posthog_instancesetting"."raw_value"
FROM "posthog_instancesetting"
WHERE "posthog_instancesetting"."key" = 'constance:posthog:PERSON_ON_EVENTS_V2_ENABLED'
ORDER BY "posthog_instancesetting"."id" ASC
LIMIT 1
SELECT "posthog_dashboard"."id",
"posthog_dashboard"."name",
"posthog_dashboard"."description",
"posthog_dashboard"."team_id",
"posthog_dashboard"."pinned",
"posthog_dashboard"."created_at",
"posthog_dashboard"."created_by_id",
"posthog_dashboard"."deleted",
"posthog_dashboard"."last_accessed_at",
"posthog_dashboard"."filters",
"posthog_dashboard"."variables",
"posthog_dashboard"."creation_mode",
"posthog_dashboard"."restriction_level",
"posthog_dashboard"."deprecated_tags",
"posthog_dashboard"."tags",
"posthog_dashboard"."share_token",
"posthog_dashboard"."is_shared"
FROM "posthog_dashboard"
INNER JOIN "posthog_featureflagdashboards" ON ("posthog_dashboard"."id" = "posthog_featureflagdashboards"."dashboard_id")
WHERE (NOT ("posthog_dashboard"."deleted")
AND "posthog_featureflagdashboards"."feature_flag_id" = 99999)
'''
# ---
# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.54
'''
SELECT "posthog_instancesetting"."id",
"posthog_instancesetting"."key",
"posthog_instancesetting"."raw_value"
FROM "posthog_instancesetting"
WHERE "posthog_instancesetting"."key" = 'constance:posthog:PERSON_ON_EVENTS_ENABLED'
ORDER BY "posthog_instancesetting"."id" ASC
LIMIT 1
SELECT "posthog_organizationmembership"."id",
"posthog_organizationmembership"."organization_id",
"posthog_organizationmembership"."user_id",
"posthog_organizationmembership"."level",
"posthog_organizationmembership"."joined_at",
"posthog_organizationmembership"."updated_at",
"posthog_organization"."id",
"posthog_organization"."name",
"posthog_organization"."slug",
"posthog_organization"."logo_media_id",
"posthog_organization"."created_at",
"posthog_organization"."updated_at",
"posthog_organization"."plugins_access_level",
"posthog_organization"."for_internal_metrics",
"posthog_organization"."is_member_join_email_enabled",
"posthog_organization"."enforce_2fa",
"posthog_organization"."is_hipaa",
"posthog_organization"."customer_id",
"posthog_organization"."available_product_features",
"posthog_organization"."usage",
"posthog_organization"."never_drop_data",
"posthog_organization"."customer_trust_scores",
"posthog_organization"."setup_section_2_completed",
"posthog_organization"."personalization",
"posthog_organization"."domain_whitelist"
FROM "posthog_organizationmembership"
INNER JOIN "posthog_organization" ON ("posthog_organizationmembership"."organization_id" = "posthog_organization"."id")
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 99999)
LIMIT 21
'''
# ---
# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.55
Expand Down
Loading
Loading