:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(experiments): delete dead requires_flag_implementation endpoint (#69523)
Andy Zhao3e1e167dd659
diff --git a/ee/clickhouse/queries/experiments/__init__.py b/ee/clickhouse/queries/experiments/__init__.pydeleted file mode 100644index 89f00352014b..000000000000--- a/ee/clickhouse/queries/experiments/__init__.py+++ /dev/null@@ -1,15 +0,0 @@-# The FF variant name for control-CONTROL_VARIANT_KEY = "control"--# controls minimum number of people to be exposed to a variant-# before the results are deemed significant-FF_DISTRIBUTION_THRESHOLD = 100--# If probability of a variant is below this threshold, it will be considered-# insignificant-MIN_PROBABILITY_FOR_SIGNIFICANCE = 0.9--# Trends only: If p-value is below this threshold, the results are considered significant-P_VALUE_SIGNIFICANCE_LEVEL = 0.05--CONTROL_VARIANT_KEY = "control"diff --git a/ee/clickhouse/queries/experiments/test_utils.py b/ee/clickhouse/queries/experiments/test_utils.pydeleted file mode 100644index 32681822adef..000000000000--- a/ee/clickhouse/queries/experiments/test_utils.py+++ /dev/null@@ -1,163 +0,0 @@-from posthog.test.base import APIBaseTest, ClickhouseTestMixin--from posthog.constants import INSIGHT_FUNNELS-from posthog.models.filters.filter import Filter-from posthog.test.test_journeys import journeys_for--from products.actions.backend.models.action import Action--from ee.clickhouse.queries.experiments.utils import requires_flag_warning---class TestUtils(ClickhouseTestMixin, APIBaseTest):- def test_with_no_feature_flag_properties_on_events(self):- journeys_for(- team=self.team,- events_by_person={- "person1": [- {"event": "user signed up", "properties": {"$os": "Windows"}},- ],- "person2": [- {"event": "user signed up", "properties": {"$os": "Windows"}},- ],- },- )-- filter = Filter(- data={- "events": [{"id": "user signed up", "type": "events", "order": 0}],- "insight": INSIGHT_FUNNELS,- }- )-- self.assertTrue(requires_flag_warning(filter, self.team))-- def test_with_feature_flag_properties_on_events(self):- journeys_for(- team=self.team,- events_by_person={- "person1": [- {- "event": "user signed up",- "properties": {"$os": "Windows", "$feature/aloha": "control"},- },- ],- "person2": [- {- "event": "user signed up",- "properties": {"$os": "Windows", "$feature/aloha": "test"},- },- ],- },- )-- filter = Filter(- data={- "events": [{"id": "user signed up", "type": "events", "order": 0}],- "insight": INSIGHT_FUNNELS,- }- )-- self.assertFalse(requires_flag_warning(filter, self.team))-- def test_with_no_feature_flag_properties_on_actions(self):- action_credit_card = Action.objects.create(- team=self.team,- name="paid",- steps_json=[- {- "event": "paid",- "properties": [- {- "key": "$os",- "type": "event",- "value": ["Windows"],- "operator": "exact",- }- ],- },- {- "event": "$autocapture",- "tag_name": "button",- "text": "Pay $10",- },- ],- )-- filter = Filter(- data={- "events": [{"id": "user signed up", "type": "events", "order": 0}],- "actions": [- {"id": action_credit_card.pk, "type": "actions", "order": 1},- ],- "insight": INSIGHT_FUNNELS,- }- )-- journeys_for(- team=self.team,- events_by_person={- "person1": [- {"event": "user signed up", "properties": {"$os": "Windows"}},- {"event": "paid", "properties": {"$os": "Windows"}},- ],- "person2": [- {"event": "paid", "properties": {"$os": "Windows"}},- ],- "person3": [- {"event": "user signed up", "properties": {"$os": "Windows"}},- ],- },- )-- self.assertTrue(requires_flag_warning(filter, self.team))-- def test_with_feature_flag_properties_on_actions(self):- action_credit_card = Action.objects.create(- team=self.team,- name="paid",- steps_json=[- {- "event": "paid",- "properties": [- {- "key": "$os",- "type": "event",- "value": ["Windows"],- "operator": "exact",- }- ],- }- ],- )-- filter = Filter(- data={- "events": [{"id": "user signed up", "type": "events", "order": 0}],- "actions": [- {"id": action_credit_card.pk, "type": "actions", "order": 1},- ],- "insight": INSIGHT_FUNNELS,- }- )-- journeys_for(- team=self.team,- events_by_person={- "person1": [- {"event": "user signed up", "properties": {"$os": "Windows"}},- {"event": "paid", "properties": {"$os": "Windows"}},- ],- "person2": [- {- "event": "paid",- "properties": {"$os": "Windows", "$feature/aloha": "test"},- },- ],- "person3": [- {"event": "user signed up", "properties": {"$os": "Windows"}},- ],- },- )-- self.assertFalse(requires_flag_warning(filter, self.team))diff --git a/ee/clickhouse/queries/experiments/utils.py b/ee/clickhouse/queries/experiments/utils.pydeleted file mode 100644index 357da30fbd76..000000000000--- a/ee/clickhouse/queries/experiments/utils.py+++ /dev/null@@ -1,48 +0,0 @@-from typing import Union--from posthog.hogql import ast-from posthog.hogql.parser import parse_select-from posthog.hogql.query import execute_hogql_query--from posthog.constants import TREND_FILTER_TYPE_ACTIONS-from posthog.models.filters.filter import Filter-from posthog.models.team.team import Team---def requires_flag_warning(filter: Filter, team: Team) -> bool:- events: set[Union[int, str]] = set()-- for entity in filter.entities:- if entity.type == TREND_FILTER_TYPE_ACTIONS:- action = entity.get_action(team.pk)- for step_event in action.get_step_events():- if step_event:- # TODO: Fix this to detect if "all events" (i.e. None) is in the list and change the entity query to e.g. AND 1=1- events.add(step_event)- elif entity.id is not None:- events.add(entity.id)-- query = parse_select(- """- SELECT event, groupArraySample({limit})(properties)- FROM events- WHERE event IN {events}- AND timestamp >= {date_from}- AND timestamp <= {date_to}- GROUP BY event- """,- placeholders={- "limit": ast.Constant(value=filter.limit or 20),- "events": ast.Constant(value=sorted(events)),- "date_from": ast.Constant(value=filter.date_from),- "date_to": ast.Constant(value=filter.date_to),- },- )- response = execute_hogql_query(query, team=team)-- for _event, property_group_list in response.results:- for property_group in property_group_list:- if "$feature/" in property_group:- return False-- return Truediff --git a/products/experiments/backend/presentation/views.py b/products/experiments/backend/presentation/views.pyindex 4f6e2834da4c..d34d8491847b 100644--- a/products/experiments/backend/presentation/views.py+++ b/products/experiments/backend/presentation/views.py@@ -29,7 +29,6 @@ from posthog.api.mixins import ValidatedRequest, validated_requestfrom posthog.api.routing import TeamAndOrgViewSetMixinfrom posthog.api.utils import actionfrom posthog.auth import IDJagAccessTokenAuthentication, OAuthAccessTokenAuthentication, PersonalAPIKeyAuthentication-from posthog.models.filters.filter import Filterfrom posthog.models.organization import OrganizationMembershipfrom posthog.models.team.team import Teamfrom posthog.models.user import User@@ -91,8 +90,6 @@ from products.product_tours.backend.models import ProductTourfrom products.surveys.backend.models import Surveyfrom products.tasks.backend.facade.access import has_tasks_access-from ee.clickhouse.queries.experiments.utils import requires_flag_warning-tracer = trace.get_tracer(__name__)# Heavy JSON columns the list view never renders. Deferred for the list action so large@@ -404,21 +401,6 @@ class EnterpriseExperimentsViewSet(return Truereturn "*" in scopes or "feature_flag:write" in scopes- # ******************************************- # /projects/:id/experiments/requires_flag_implementation- #- # Returns current results of an experiment, and graphs- # 1. Probability of success- # 2. Funnel breakdown graph to display- # ******************************************- @action(methods=["GET"], detail=False, required_scopes=["experiment:read"])- def requires_flag_implementation(self, request: Request, *args: Any, **kwargs: Any) -> Response:- filter = Filter(request=request, team=self.team).shallow_clone({"date_from": "-7d", "date_to": ""})-- warning = requires_flag_warning(filter, self.team)-- return Response({"result": warning})-@extend_schema(request=None,responses=ExperimentSerializer,diff --git a/products/experiments/frontend/generated/api.ts b/products/experiments/frontend/generated/api.tsindex 58d0d3c82ff5..6ca9417ded0a 100644--- a/products/experiments/frontend/generated/api.ts+++ b/products/experiments/frontend/generated/api.ts@@ -997,27 +997,6 @@ export const experimentsPromptTemplatesRetrieve = async ()}-export const getExperimentsRequiresFlagImplementationRetrieveUrl = (projectId: string) => {- return `/api/projects/${projectId}/experiments/requires_flag_implementation/`-}--/**- * Mixin for ViewSets to handle approval-gate exceptions raised from decorated serializers.- *- * Intercepts ApprovalRequired (409) and PolicyConflict (400) raised by the @approval_gate- * decorator on serializer methods and converts them into the same responses the viewset path- * produces (see decorators._result_to_response), so both paths share one contract.- */-export const experimentsRequiresFlagImplementationRetrieve = async (- projectId: string,- options?: RequestInit-): Promise<void> => {- return apiMutator<void>(getExperimentsRequiresFlagImplementationRetrieveUrl(projectId), {- ...options,- method: 'GET',- })-}-export const getExperimentsStatsRetrieveUrl = (projectId: string) => {return `/api/projects/${projectId}/experiments/stats/`}diff --git a/products/experiments/mcp/tools.yaml b/products/experiments/mcp/tools.yamlindex 8c4c4f5b5b6a..760d6a059d75 100644--- a/products/experiments/mcp/tools.yaml+++ b/products/experiments/mcp/tools.yaml@@ -1052,9 +1052,6 @@ tools:experiments-recalculate-timeseries:operation: experiments_recalculate_timeseries_createenabled: false- experiments-requires-flag-implementation:- operation: experiments_requires_flag_implementation_retrieve- enabled: falseexperiments-unfreeze-exposure-create:operation: experiments_unfreeze_exposure_createenabled: false