diff --git a/posthog/api/organization_feature_flag.py b/posthog/api/organization_feature_flag.py index a1d7533a7eb28..484b817a72de1 100644 --- a/posthog/api/organization_feature_flag.py +++ b/posthog/api/organization_feature_flag.py @@ -1,11 +1,15 @@ from posthog.api.routing import StructuredViewSetMixin -from posthog.models import FeatureFlag +from posthog.api.feature_flag import FeatureFlagSerializer +from posthog.models import FeatureFlag, Team from posthog.permissions import OrganizationMemberPermissions +from django.core.exceptions import ObjectDoesNotExist from rest_framework.response import Response from rest_framework.permissions import IsAuthenticated +from rest_framework.decorators import action from rest_framework import ( mixins, viewsets, + status, ) @@ -26,7 +30,90 @@ def retrieve(self, request, *args, **kwargs): teams = self.organization.teams.all() - flags = FeatureFlag.objects.filter(key=feature_flag_key, team_id__in=[team.id for team in teams]) - flags_data = [{"team_id": flag.team_id, "active": flag.active} for flag in flags] + flags = FeatureFlag.objects.filter( + key=feature_flag_key, + team_id__in=[team.id for team in teams], + deleted=False, + ) + flags_data = [ + { + "flag_id": flag.id, + "team_id": flag.team_id, + "active": flag.active, + } + for flag in flags + ] return Response(flags_data) + + @action(detail=False, methods=["post"], url_path="copy_flags") + def copy_flags(self, request, *args, **kwargs): + body = request.data + feature_flag_key = body.get("feature_flag_key") + from_project = body.get("from_project") + target_project_ids = body.get("target_project_ids") + + if not feature_flag_key or not from_project or not target_project_ids: + return Response({"error": "Missing required fields"}, status=status.HTTP_400_BAD_REQUEST) + + try: + flag_to_copy = FeatureFlag.objects.get(key=feature_flag_key, team_id=from_project) + except FeatureFlag.DoesNotExist: + return Response({"error": "Feature flag to copy does not exist."}, status=status.HTTP_400_BAD_REQUEST) + + successful_projects = [] + failed_projects = [] + + for target_project_id in target_project_ids: + # Target project does not exist + try: + Team.objects.get(id=target_project_id) + except ObjectDoesNotExist: + failed_projects.append( + { + "project_id": target_project_id, + "errors": "Target project does not exist.", + } + ) + continue + + context = { + "request": request, + "team_id": target_project_id, + } + flag_data = { + "key": flag_to_copy.key, + "name": flag_to_copy.name, + "filters": flag_to_copy.filters, + "active": flag_to_copy.active, + "rollout_percentage": flag_to_copy.rollout_percentage, + "ensure_experience_continuity": flag_to_copy.ensure_experience_continuity, + "deleted": False, + } + + existing_flag = FeatureFlag.objects.filter(key=feature_flag_key, team_id=target_project_id).first() + # Update existing flag + if existing_flag: + feature_flag_serializer = FeatureFlagSerializer( + existing_flag, data=flag_data, partial=True, context=context + ) + # Create new flag + else: + feature_flag_serializer = FeatureFlagSerializer(data=flag_data, context=context) + + try: + feature_flag_serializer.is_valid(raise_exception=True) + feature_flag_serializer.save(team_id=target_project_id) + successful_projects.append(feature_flag_serializer.data) + except Exception as e: + failed_projects.append( + { + "project_id": target_project_id, + "errors": str(e) if not feature_flag_serializer.errors else feature_flag_serializer.errors, + } + ) + + return Response( + {"success": successful_projects, "failed": failed_projects}, + status=status.HTTP_200_OK, + ) diff --git a/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr b/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr index dd49697a74c5e..d1e736d1af3f4 100644 --- a/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr +++ b/posthog/api/test/__snapshots__/test_organization_feature_flag.ambr @@ -1,4 +1,4 @@ -# name: OrganizationFeatureFlagViewTests.test_get_feature_flag_success +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new ' SELECT "posthog_user"."id", "posthog_user"."password", @@ -27,7 +27,1555 @@ LIMIT 21 /**/ ' --- -# name: OrganizationFeatureFlagViewTests.test_get_feature_flag_success.1 +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.1 + ' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "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"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist", + "posthog_organization"."available_features" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.10 + ' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "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"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist", + "posthog_organization"."available_features" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.11 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."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" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.12 + ' + SELECT "posthog_dashboardtile"."id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 2) /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.13 + ' + SELECT "posthog_organization"."id", + "posthog_organization"."name", + "posthog_organization"."slug", + "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"."customer_id", + "posthog_organization"."available_product_features", + "posthog_organization"."usage", + "posthog_organization"."never_drop_data", + "posthog_organization"."setup_section_2_completed", + "posthog_organization"."personalization", + "posthog_organization"."domain_whitelist", + "posthog_organization"."available_features" + FROM "posthog_organization" + WHERE "posthog_organization"."id" = '00000000-0000-0000-0000-000000000000'::uuid + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.14 + ' + SELECT "posthog_dashboardtile"."id" + FROM "posthog_dashboardtile" + INNER JOIN "posthog_dashboard" ON ("posthog_dashboardtile"."dashboard_id" = "posthog_dashboard"."id") + WHERE (NOT ("posthog_dashboardtile"."deleted" + AND "posthog_dashboardtile"."deleted" IS NOT NULL) + AND NOT ("posthog_dashboard"."deleted") + AND "posthog_dashboardtile"."dashboard_id" = 2) /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.15 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.16 + ' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.17 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."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" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.18 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.19 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.2 + ' + SELECT (1) AS "a" + FROM "posthog_organizationmembership" + WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid + AND "posthog_organizationmembership"."user_id" = 2) + LIMIT 1 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.20 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.21 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.22 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.23 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.24 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.25 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.26 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.27 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.28 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.29 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.3 + ' + SELECT "posthog_instancesetting"."id", + "posthog_instancesetting"."key", + "posthog_instancesetting"."raw_value" + FROM "posthog_instancesetting" + WHERE "posthog_instancesetting"."key" = 'constance:posthog:RATE_LIMIT_ENABLED' + ORDER BY "posthog_instancesetting"."id" ASC + LIMIT 1 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.30 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.31 + ' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + WHERE "posthog_dashboardtile"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.32 + ' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.33 + ' + 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"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE "posthog_dashboard"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.34 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."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" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.35 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.36 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.37 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.38 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.39 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.4 + ' + SELECT "posthog_featureflag"."id", + "posthog_featureflag"."key", + "posthog_featureflag"."name", + "posthog_featureflag"."filters", + "posthog_featureflag"."rollout_percentage", + "posthog_featureflag"."team_id", + "posthog_featureflag"."created_by_id", + "posthog_featureflag"."created_at", + "posthog_featureflag"."deleted", + "posthog_featureflag"."active", + "posthog_featureflag"."rollback_conditions", + "posthog_featureflag"."performed_rollback", + "posthog_featureflag"."ensure_experience_continuity", + "posthog_featureflag"."usage_dashboard_id", + "posthog_featureflag"."has_enriched_analytics" + FROM "posthog_featureflag" + WHERE ("posthog_featureflag"."key" = 'copied-flag-key' + AND "posthog_featureflag"."team_id" = 2) + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.40 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.41 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.42 + ' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.43 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."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" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.44 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.45 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.46 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.47 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.48 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.49 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.5 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.50 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.51 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.52 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# 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_ENABLED' + ORDER BY "posthog_instancesetting"."id" ASC + LIMIT 1 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# 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_V2_ENABLED' + ORDER BY "posthog_instancesetting"."id" ASC + LIMIT 1 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.55 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.56 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."correlation_config", + "posthog_team"."session_recording_retention_period_days", + "posthog_team"."external_data_workspace_id" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.57 + ' + SELECT "posthog_dashboardtile"."id", + "posthog_dashboardtile"."dashboard_id", + "posthog_dashboardtile"."insight_id", + "posthog_dashboardtile"."text_id", + "posthog_dashboardtile"."layouts", + "posthog_dashboardtile"."color", + "posthog_dashboardtile"."filters_hash", + "posthog_dashboardtile"."last_refresh", + "posthog_dashboardtile"."refreshing", + "posthog_dashboardtile"."refresh_attempt", + "posthog_dashboardtile"."deleted" + FROM "posthog_dashboardtile" + WHERE "posthog_dashboardtile"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.58 + ' + SELECT "posthog_dashboarditem"."id", + "posthog_dashboarditem"."name", + "posthog_dashboarditem"."derived_name", + "posthog_dashboarditem"."description", + "posthog_dashboarditem"."team_id", + "posthog_dashboarditem"."filters", + "posthog_dashboarditem"."filters_hash", + "posthog_dashboarditem"."query", + "posthog_dashboarditem"."order", + "posthog_dashboarditem"."deleted", + "posthog_dashboarditem"."saved", + "posthog_dashboarditem"."created_at", + "posthog_dashboarditem"."last_refresh", + "posthog_dashboarditem"."refreshing", + "posthog_dashboarditem"."created_by_id", + "posthog_dashboarditem"."is_sample", + "posthog_dashboarditem"."short_id", + "posthog_dashboarditem"."favorited", + "posthog_dashboarditem"."refresh_attempt", + "posthog_dashboarditem"."last_modified_at", + "posthog_dashboarditem"."last_modified_by_id", + "posthog_dashboarditem"."dashboard_id", + "posthog_dashboarditem"."layouts", + "posthog_dashboarditem"."color", + "posthog_dashboarditem"."dive_dashboard_id", + "posthog_dashboarditem"."updated_at", + "posthog_dashboarditem"."deprecated_tags", + "posthog_dashboarditem"."tags" + FROM "posthog_dashboarditem" + WHERE "posthog_dashboarditem"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.59 + ' + 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"."creation_mode", + "posthog_dashboard"."restriction_level", + "posthog_dashboard"."deprecated_tags", + "posthog_dashboard"."tags", + "posthog_dashboard"."share_token", + "posthog_dashboard"."is_shared" + FROM "posthog_dashboard" + WHERE "posthog_dashboard"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.6 + ' + SELECT "posthog_featureflag"."id", + "posthog_featureflag"."key", + "posthog_featureflag"."name", + "posthog_featureflag"."filters", + "posthog_featureflag"."rollout_percentage", + "posthog_featureflag"."team_id", + "posthog_featureflag"."created_by_id", + "posthog_featureflag"."created_at", + "posthog_featureflag"."deleted", + "posthog_featureflag"."active", + "posthog_featureflag"."rollback_conditions", + "posthog_featureflag"."performed_rollback", + "posthog_featureflag"."ensure_experience_continuity", + "posthog_featureflag"."usage_dashboard_id", + "posthog_featureflag"."has_enriched_analytics" + FROM "posthog_featureflag" + WHERE ("posthog_featureflag"."key" = 'copied-flag-key' + AND "posthog_featureflag"."team_id" = 2) + ORDER BY "posthog_featureflag"."id" ASC + LIMIT 1 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.60 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."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" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.61 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.62 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.63 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.64 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.65 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.66 + ' + 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 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.67 + ' + SELECT "posthog_featureflag"."id", + "posthog_featureflag"."key", + "posthog_featureflag"."name", + "posthog_featureflag"."filters", + "posthog_featureflag"."rollout_percentage", + "posthog_featureflag"."team_id", + "posthog_featureflag"."created_by_id", + "posthog_featureflag"."created_at", + "posthog_featureflag"."deleted", + "posthog_featureflag"."active", + "posthog_featureflag"."rollback_conditions", + "posthog_featureflag"."performed_rollback", + "posthog_featureflag"."ensure_experience_continuity", + "posthog_featureflag"."usage_dashboard_id", + "posthog_featureflag"."has_enriched_analytics" + FROM "posthog_featureflag" + WHERE ("posthog_featureflag"."active" + AND NOT "posthog_featureflag"."deleted" + AND "posthog_featureflag"."team_id" = 2) /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.68 + ' + SELECT "posthog_team"."id", + "posthog_team"."uuid", + "posthog_team"."organization_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_exceptions_opt_in", + "posthog_team"."autocapture_exceptions_errors_to_ignore", + "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"."capture_console_log_opt_in", + "posthog_team"."capture_performance_opt_in", + "posthog_team"."surveys_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"."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" + FROM "posthog_team" + WHERE "posthog_team"."id" = 2 + LIMIT 21 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.69 + ' + SELECT "posthog_experiment"."id", + "posthog_experiment"."name", + "posthog_experiment"."description", + "posthog_experiment"."team_id", + "posthog_experiment"."filters", + "posthog_experiment"."parameters", + "posthog_experiment"."secondary_metrics", + "posthog_experiment"."feature_flag_id", + "posthog_experiment"."created_by_id", + "posthog_experiment"."start_date", + "posthog_experiment"."end_date", + "posthog_experiment"."created_at", + "posthog_experiment"."updated_at", + "posthog_experiment"."archived" + FROM "posthog_experiment" + WHERE "posthog_experiment"."feature_flag_id" = 2 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.7 + ' + SELECT (1) AS "a" + FROM "posthog_featureflag" + WHERE (NOT "posthog_featureflag"."deleted" + AND "posthog_featureflag"."key" = 'copied-flag-key' + AND "posthog_featureflag"."team_id" = 2) + LIMIT 1 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.70 + ' + SELECT "posthog_survey"."id", + "posthog_survey"."team_id", + "posthog_survey"."name", + "posthog_survey"."description", + "posthog_survey"."linked_flag_id", + "posthog_survey"."targeting_flag_id", + "posthog_survey"."type", + "posthog_survey"."conditions", + "posthog_survey"."questions", + "posthog_survey"."appearance", + "posthog_survey"."created_at", + "posthog_survey"."created_by_id", + "posthog_survey"."start_date", + "posthog_survey"."end_date", + "posthog_survey"."updated_at", + "posthog_survey"."archived" + FROM "posthog_survey" + WHERE "posthog_survey"."linked_flag_id" = 2 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.71 + ' + SELECT "posthog_earlyaccessfeature"."id", + "posthog_earlyaccessfeature"."team_id", + "posthog_earlyaccessfeature"."feature_flag_id", + "posthog_earlyaccessfeature"."name", + "posthog_earlyaccessfeature"."description", + "posthog_earlyaccessfeature"."stage", + "posthog_earlyaccessfeature"."documentation_url", + "posthog_earlyaccessfeature"."created_at" + FROM "posthog_earlyaccessfeature" + WHERE "posthog_earlyaccessfeature"."feature_flag_id" = 2 /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.72 + ' + 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"."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" = 2) /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.8 + ' + SELECT "posthog_featureflag"."id", + "posthog_featureflag"."key", + "posthog_featureflag"."name", + "posthog_featureflag"."filters", + "posthog_featureflag"."rollout_percentage", + "posthog_featureflag"."team_id", + "posthog_featureflag"."created_by_id", + "posthog_featureflag"."created_at", + "posthog_featureflag"."deleted", + "posthog_featureflag"."active", + "posthog_featureflag"."rollback_conditions", + "posthog_featureflag"."performed_rollback", + "posthog_featureflag"."ensure_experience_continuity", + "posthog_featureflag"."usage_dashboard_id", + "posthog_featureflag"."has_enriched_analytics" + FROM "posthog_featureflag" + WHERE ("posthog_featureflag"."deleted" + AND "posthog_featureflag"."key" = 'copied-flag-key' + AND "posthog_featureflag"."team_id" = 2) /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagCopy.test_copy_feature_flag_create_new.9 + ' + SELECT "posthog_featureflag"."id", + "posthog_featureflag"."key", + "posthog_featureflag"."name", + "posthog_featureflag"."filters", + "posthog_featureflag"."rollout_percentage", + "posthog_featureflag"."team_id", + "posthog_featureflag"."created_by_id", + "posthog_featureflag"."created_at", + "posthog_featureflag"."deleted", + "posthog_featureflag"."active", + "posthog_featureflag"."rollback_conditions", + "posthog_featureflag"."performed_rollback", + "posthog_featureflag"."ensure_experience_continuity", + "posthog_featureflag"."usage_dashboard_id", + "posthog_featureflag"."has_enriched_analytics" + FROM "posthog_featureflag" + WHERE ("posthog_featureflag"."active" + AND NOT "posthog_featureflag"."deleted" + AND "posthog_featureflag"."team_id" = 2) /*controller='organization_feature_flags-copy-flags',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/copy_flags/%3F%24'*/ + ' +--- +# name: TestOrganizationFeatureFlagGet.test_get_feature_flag_success + ' + SELECT "posthog_user"."id", + "posthog_user"."password", + "posthog_user"."last_login", + "posthog_user"."first_name", + "posthog_user"."last_name", + "posthog_user"."is_staff", + "posthog_user"."is_active", + "posthog_user"."date_joined", + "posthog_user"."uuid", + "posthog_user"."current_organization_id", + "posthog_user"."current_team_id", + "posthog_user"."email", + "posthog_user"."pending_email", + "posthog_user"."temporary_token", + "posthog_user"."distinct_id", + "posthog_user"."is_email_verified", + "posthog_user"."has_seen_product_intro_for", + "posthog_user"."email_opt_in", + "posthog_user"."partial_notification_settings", + "posthog_user"."anonymize_data", + "posthog_user"."toolbar_mode", + "posthog_user"."events_column_config" + FROM "posthog_user" + WHERE "posthog_user"."id" = 2 + LIMIT 21 /**/ + ' +--- +# name: TestOrganizationFeatureFlagGet.test_get_feature_flag_success.1 ' SELECT "posthog_organization"."id", "posthog_organization"."name", @@ -51,7 +1599,7 @@ LIMIT 21 /*controller='organization_feature_flags-detail',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/%28%3FP%3Cfeature_flag_key%3E%5B%5E/.%5D%2B%29/%3F%24'*/ ' --- -# name: OrganizationFeatureFlagViewTests.test_get_feature_flag_success.2 +# name: TestOrganizationFeatureFlagGet.test_get_feature_flag_success.2 ' SELECT (1) AS "a" FROM "posthog_organizationmembership" @@ -60,7 +1608,7 @@ LIMIT 1 /*controller='organization_feature_flags-detail',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/%28%3FP%3Cfeature_flag_key%3E%5B%5E/.%5D%2B%29/%3F%24'*/ ' --- -# name: OrganizationFeatureFlagViewTests.test_get_feature_flag_success.3 +# name: TestOrganizationFeatureFlagGet.test_get_feature_flag_success.3 ' SELECT "posthog_instancesetting"."id", "posthog_instancesetting"."key", @@ -71,7 +1619,7 @@ LIMIT 1 /*controller='organization_feature_flags-detail',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/%28%3FP%3Cfeature_flag_key%3E%5B%5E/.%5D%2B%29/%3F%24'*/ ' --- -# name: OrganizationFeatureFlagViewTests.test_get_feature_flag_success.4 +# name: TestOrganizationFeatureFlagGet.test_get_feature_flag_success.4 ' SELECT "posthog_team"."id", "posthog_team"."uuid", @@ -119,7 +1667,7 @@ WHERE "posthog_team"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid /*controller='organization_feature_flags-detail',route='api/organizations/%28%3FP%3Cparent_lookup_organization_id%3E%5B%5E/.%5D%2B%29/feature_flags/%28%3FP%3Cfeature_flag_key%3E%5B%5E/.%5D%2B%29/%3F%24'*/ ' --- -# name: OrganizationFeatureFlagViewTests.test_get_feature_flag_success.5 +# name: TestOrganizationFeatureFlagGet.test_get_feature_flag_success.5 ' SELECT "posthog_featureflag"."id", "posthog_featureflag"."key", @@ -137,7 +1685,8 @@ "posthog_featureflag"."usage_dashboard_id", "posthog_featureflag"."has_enriched_analytics" FROM "posthog_featureflag" - WHERE ("posthog_featureflag"."key" = 'key-1' + WHERE (NOT "posthog_featureflag"."deleted" + AND "posthog_featureflag"."key" = 'key-1' AND "posthog_featureflag"."team_id" IN (1, 2, 3, diff --git a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr index f40bb246f4ce1..275c555c7e7da 100644 --- a/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr +++ b/posthog/api/test/dashboards/__snapshots__/test_dashboard.ambr @@ -2619,6 +2619,24 @@ 5 /* ... */) /*controller='project_dashboards-list',route='api/projects/%28%3FP%3Cparent_lookup_team_id%3E%5B%5E/.%5D%2B%29/dashboards/%3F%24'*/ ' --- +# name: TestDashboard.test_listing_dashboards_is_not_nplus1.57 + ' + SELECT "posthog_sharingconfiguration"."id", + "posthog_sharingconfiguration"."team_id", + "posthog_sharingconfiguration"."dashboard_id", + "posthog_sharingconfiguration"."insight_id", + "posthog_sharingconfiguration"."recording_id", + "posthog_sharingconfiguration"."created_at", + "posthog_sharingconfiguration"."enabled", + "posthog_sharingconfiguration"."access_token" + FROM "posthog_sharingconfiguration" + WHERE "posthog_sharingconfiguration"."dashboard_id" IN (1, + 2, + 3, + 4, + 5 /* ... */) /*controller='project_dashboards-list',route='api/projects/%28%3FP%3Cparent_lookup_team_id%3E%5B%5E/.%5D%2B%29/dashboards/%3F%24'*/ + ' +--- # name: TestDashboard.test_listing_dashboards_is_not_nplus1.6 ' SELECT "posthog_team"."id", diff --git a/posthog/api/test/test_organization_feature_flag.py b/posthog/api/test/test_organization_feature_flag.py index de57dfb91bd0b..f1cd080acbc61 100644 --- a/posthog/api/test/test_organization_feature_flag.py +++ b/posthog/api/test/test_organization_feature_flag.py @@ -2,21 +2,26 @@ from posthog.models.team.team import Team from posthog.models import FeatureFlag from posthog.test.base import APIBaseTest, QueryMatchingTest, snapshot_postgres_queries +from typing import Any, Dict -class OrganizationFeatureFlagViewTests(APIBaseTest, QueryMatchingTest): +class TestOrganizationFeatureFlagGet(APIBaseTest, QueryMatchingTest): def setUp(self): self.team_1 = self.team self.team_2 = Team.objects.create(organization=self.organization) + self.team_3 = Team.objects.create(organization=self.organization) self.feature_flag_key = "key-1" self.feature_flag_1 = FeatureFlag.objects.create( team=self.team_1, created_by=self.user, key=self.feature_flag_key ) - self.feature_flag_1 = FeatureFlag.objects.create( + self.feature_flag_2 = FeatureFlag.objects.create( team=self.team_2, created_by=self.user, key=self.feature_flag_key ) + self.feature_flag_deleted = FeatureFlag.objects.create( + team=self.team_3, created_by=self.user, key=self.feature_flag_key, deleted=True + ) super().setUp() @@ -27,7 +32,10 @@ def test_get_feature_flag_success(self): self.assertEqual(response.status_code, status.HTTP_200_OK) - expected_data = [{"team_id": self.team_1.id, "active": True}, {"team_id": self.team_2.id, "active": True}] + expected_data = [ + {"flag_id": self.feature_flag_1.id, "team_id": self.team_1.id, "active": True}, + {"flag_id": self.feature_flag_2.id, "team_id": self.team_2.id, "active": True}, + ] self.assertCountEqual(response.json(), expected_data) def test_get_feature_flag_not_found(self): @@ -44,3 +52,190 @@ def test_get_feature_flag_unauthorized(self): response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + + +class TestOrganizationFeatureFlagCopy(APIBaseTest, QueryMatchingTest): + def setUp(self): + self.team_1 = self.team + self.team_2 = Team.objects.create(organization=self.organization) + + self.feature_flag_key = "copied-flag-key" + self.rollout_percentage_to_copy = 65 + self.feature_flag_to_copy = FeatureFlag.objects.create( + team=self.team_1, + created_by=self.user, + key=self.feature_flag_key, + filters={"groups": [{"rollout_percentage": self.rollout_percentage_to_copy}]}, + rollout_percentage=self.rollout_percentage_to_copy, + ) + + super().setUp() + + @snapshot_postgres_queries + def test_copy_feature_flag_create_new(self): + url = f"/api/organizations/{self.organization.id}/feature_flags/copy_flags" + target_project = self.team_2 + + data = { + "feature_flag_key": self.feature_flag_to_copy.key, + "from_project": self.feature_flag_to_copy.team_id, + "target_project_ids": [target_project.id], + } + response = self.client.post(url, data) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertIn("success", response.json()) + self.assertIn("failed", response.json()) + + # Check copied flag in the response + expected_flag_response = { + "key": self.feature_flag_to_copy.key, + "name": self.feature_flag_to_copy.name, + "filters": self.feature_flag_to_copy.filters, + "active": self.feature_flag_to_copy.active, + "ensure_experience_continuity": self.feature_flag_to_copy.ensure_experience_continuity, + "rollout_percentage": self.rollout_percentage_to_copy, + "deleted": False, + "created_by": self.user.id, + "id": "__ignore__", + "created_at": "__ignore__", + "usage_dashboard": "__ignore__", + "is_simple_flag": True, + "experiment_set": [], + "surveys": [], + "features": [], + "rollback_conditions": None, + "performed_rollback": False, + "can_edit": True, + "analytics_dashboards": [], + "has_enriched_analytics": False, + "tags": [], + } + + flag_response = response.json()["success"][0] + + for key, expected_value in expected_flag_response.items(): + self.assertIn(key, flag_response) + if expected_value != "__ignore__": + if key == "created_by": + self.assertEqual(flag_response[key]["id"], expected_value) + else: + self.assertEqual(flag_response[key], expected_value) + + self.assertSetEqual( + set(expected_flag_response.keys()), + set(flag_response.keys()), + ) + + def test_copy_feature_flag_update_existing(self): + target_project = self.team_2 + rollout_percentage_existing = 99 + self.feature_flag_existing = FeatureFlag.objects.create( + team=target_project, + created_by=self.user, + key=self.feature_flag_key, + name="Existing flag", + filters={"groups": [{"rollout_percentage": rollout_percentage_existing}]}, + rollout_percentage=rollout_percentage_existing, + ensure_experience_continuity=False, + ) + + url = f"/api/organizations/{self.organization.id}/feature_flags/copy_flags" + + data = { + "feature_flag_key": self.feature_flag_to_copy.key, + "from_project": self.feature_flag_to_copy.team_id, + "target_project_ids": [target_project.id], + } + response = self.client.post(url, data) + + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertIn("success", response.json()) + self.assertIn("failed", response.json()) + + # Check copied flag in the response + expected_flag_response = { + "key": self.feature_flag_to_copy.key, + "name": self.feature_flag_to_copy.name, + "filters": self.feature_flag_to_copy.filters, + "active": self.feature_flag_to_copy.active, + "ensure_experience_continuity": self.feature_flag_to_copy.ensure_experience_continuity, + "rollout_percentage": self.rollout_percentage_to_copy, + "deleted": False, + "created_by": self.user.id, + "id": "__ignore__", + "created_at": "__ignore__", + "usage_dashboard": "__ignore__", + "is_simple_flag": True, + "experiment_set": [], + "surveys": [], + "features": [], + "rollback_conditions": None, + "performed_rollback": False, + "can_edit": True, + "analytics_dashboards": [], + "has_enriched_analytics": False, + "tags": [], + } + + flag_response = response.json()["success"][0] + + for key, expected_value in expected_flag_response.items(): + self.assertIn(key, flag_response) + if expected_value != "__ignore__": + if key == "created_by": + self.assertEqual(flag_response[key]["id"], expected_value) + else: + self.assertEqual(flag_response[key], expected_value) + + self.assertSetEqual( + set(expected_flag_response.keys()), + set(flag_response.keys()), + ) + + def test_copy_feature_flag_missing_fields(self): + url = f"/api/organizations/{self.organization.id}/feature_flags/copy_flags" + data: Dict[str, Any] = {} + response = self.client.post(url, data) + + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + self.assertIn("error", response.json()) + + def test_copy_feature_flag_nonexistent_key(self): + url = f"/api/organizations/{self.organization.id}/feature_flags/copy_flags" + data = { + "feature_flag_key": "nonexistent-key", + "from_project": self.team_1.id, + "target_project_ids": [self.team_2.id], + } + response = self.client.post(url, data) + + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) + self.assertIn("error", response.json()) + + def test_copy_feature_flag_to_nonexistent_target(self): + url = f"/api/organizations/{self.organization.id}/feature_flags/copy_flags" + nonexistent_project_id = 999 + data = { + "feature_flag_key": self.feature_flag_key, + "from_project": self.team_1.id, + "target_project_ids": [nonexistent_project_id], + } + + response = self.client.post(url, data) + self.assertEqual(response.status_code, status.HTTP_200_OK) + self.assertEqual(len(response.json()["success"]), 0) + self.assertEqual(len(response.json()["failed"]), 1) + self.assertEqual(nonexistent_project_id, response.json()["failed"][0]["project_id"]) + + def test_copy_feature_flag_unauthorized(self): + self.client.logout() + url = f"/api/organizations/{self.organization.id}/feature_flags/copy_flags" + data = { + "feature_flag_key": self.feature_flag_key, + "from_project": self.team_1.id, + "target_project_ids": [self.team_2.id], + } + response = self.client.post(url, data) + + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) diff --git a/posthog/models/feature_flag/feature_flag.py b/posthog/models/feature_flag/feature_flag.py index b45271bb16845..97d5d3e1aace8 100644 --- a/posthog/models/feature_flag/feature_flag.py +++ b/posthog/models/feature_flag/feature_flag.py @@ -27,6 +27,7 @@ class FeatureFlag(models.Model): class Meta: constraints = [models.UniqueConstraint(fields=["team", "key"], name="unique key for team")] + # When adding new fields, make sure to update organization_feature_flags.py::copy_flags key: models.CharField = models.CharField(max_length=400) name: models.TextField = models.TextField( blank=True