Skip to content

: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.

chore(tasks): remove the fully rolled out wizard pr-ready email flag (#115598)

posthog[bot]4606d6d054cb
diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.py
index 294e22595b42..ac04ffb47348 100644
--- a/products/tasks/backend/facade/api.py
+++ b/products/tasks/backend/facade/api.py
@@ -211,8 +211,6 @@ TaskRuntime = Task.Runtime
SandboxNetworkAccessLevel = SandboxEnvironment.NetworkAccessLevel
SandboxSnapshotStatus = SandboxSnapshot.Status
-WIZARD_PR_READY_EMAIL_FEATURE_FLAG = "wizard-cloud-run-pr-ready-email-enabled"
-
# Runtime posture for a setup-wizard cloud run, applied in create_wizard_cloud_run. The model is
# pinned because these runs route to the unbilled `onboarding` gateway product, which allowlists a
# narrow model set; the string form avoids pulling the temporal RuntimeAdapter enum onto this path.
@@ -3306,28 +3304,6 @@ def _post_slack_update_for_pr(run: TaskRun) -> None:
logger.exception("task_run_slack_update_for_pr_failed for run %s", run.id)
-def _is_wizard_pr_ready_email_enabled(run: TaskRun) -> bool:
- user = run.task.created_by
- if user is None or not user.distinct_id:
- return False
- try:
- team = Team.objects.only("id", "uuid", "organization_id").get(id=run.team_id)
- organization_id = str(team.organization_id)
- return bool(
- posthoganalytics.feature_enabled(
- WIZARD_PR_READY_EMAIL_FEATURE_FLAG,
- user.distinct_id,
- groups={"organization": organization_id},
- group_properties={"organization": {"id": organization_id}},
- only_evaluate_locally=False,
- send_feature_flag_events=False,
- )
- )
- except Exception:
- logger.exception("wizard_pr_ready_email_feature_flag_check_failed", extra={"run_id": str(run.id)})
- return False
-
-
def _is_github_pull_request_url_for_repository(pr_url: str, repository: str | None) -> bool:
if not repository:
return False
@@ -3366,8 +3342,6 @@ def _send_wizard_pr_ready_email_for_pr(run: TaskRun) -> None:
extra={"run_id": str(run.id), "task_id": str(run.task_id), "repository": run.task.repository},
)
return
- if not _is_wizard_pr_ready_email_enabled(run):
- return
if not run.task.mark_pr_ready_email_queued(pr_url):
return
diff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.py
index 2363e9bf082a..75a09873e07a 100644
--- a/products/tasks/backend/tests/test_api.py
+++ b/products/tasks/backend/tests/test_api.py
@@ -7283,16 +7283,6 @@ class TestTaskRunAPI(BaseTaskAPITest):
)
return task, run
- def _set_wizard_pr_ready_email_flag(self, enabled: bool) -> None:
- def check_flag(flag_name, *_args, **_kwargs):
- if flag_name == "tasks":
- return True
- if flag_name == tasks_facade.WIZARD_PR_READY_EMAIL_FEATURE_FLAG:
- return enabled
- return False
-
- self.mock_feature_flag.side_effect = check_flag
-
def test_list_runs_with_malformed_task_id_returns_404(self):
# A non-UUID task id in the URL must 404, not 500 through the UUIDField filter.
response = self.client.get("/api/projects/@current/tasks/not-a-uuid/runs/")
@@ -7486,7 +7476,6 @@ class TestTaskRunAPI(BaseTaskAPITest):
_mock_emit_progress_event: MagicMock,
_mock_post_slack_update_for_pr: MagicMock,
) -> None:
- self._set_wizard_pr_ready_email_flag(True)
task, run = self._create_run_for_origin(Task.OriginProduct.ONBOARDING)
pr_url = "https://github.com/posthog/posthog-js/pull/1"
@@ -7515,34 +7504,6 @@ class TestTaskRunAPI(BaseTaskAPITest):
self.assertEqual(response.status_code, status.HTTP_200_OK)
mock_send_wizard_pr_ready_email.assert_called_once_with(str(run.id))
- @patch("products.tasks.backend.facade.api._post_slack_update_for_pr")
- @patch("products.tasks.backend.models.TaskRun.emit_progress_event")
- @patch("products.tasks.backend.models.TaskRun.publish_stream_state_event")
- @patch("posthog.tasks.email.send_wizard_pr_ready_email.delay")
- def test_onboarding_pr_url_does_not_enqueue_pr_ready_email_when_flag_disabled(
- self,
- mock_send_wizard_pr_ready_email: MagicMock,
- _mock_publish_stream_state_event: MagicMock,
- _mock_emit_progress_event: MagicMock,
- _mock_post_slack_update_for_pr: MagicMock,
- ) -> None:
- self._set_wizard_pr_ready_email_flag(False)
- task, run = self._create_run_for_origin(Task.OriginProduct.ONBOARDING)
-
- with self.captureOnCommitCallbacks(execute=True):
- response = self.client.patch(
- f"/api/projects/@current/tasks/{task.id}/runs/{run.id}/",
- {"output": {"pr_url": "https://github.com/posthog/posthog-js/pull/1"}},
- format="json",
- )
-
- self.assertEqual(response.status_code, status.HTTP_200_OK)
- mock_send_wizard_pr_ready_email.assert_not_called()
- task.refresh_from_db()
- task_state = task.state or {}
- self.assertNotIn("pr_ready_email_queued_at", task_state)
- self.assertNotIn("pr_ready_email_sent_at", task_state)
-
@parameterized.expand(
[
("wrong_host", "https://example.com/posthog/posthog-js/pull/1"),
@@ -7564,7 +7525,6 @@ class TestTaskRunAPI(BaseTaskAPITest):
_mock_emit_progress_event: MagicMock,
_mock_post_slack_update_for_pr: MagicMock,
) -> None:
- self._set_wizard_pr_ready_email_flag(True)
task, run = self._create_run_for_origin(Task.OriginProduct.ONBOARDING)
with self.captureOnCommitCallbacks(execute=True):
@@ -7619,7 +7579,6 @@ class TestTaskRunAPI(BaseTaskAPITest):
_mock_publish_stream_state_event: MagicMock,
_mock_post_slack_update_for_pr: MagicMock,
) -> None:
- self._set_wizard_pr_ready_email_flag(True)
task, run = self._create_run_for_origin(Task.OriginProduct.ONBOARDING)
pr_url = "https://github.com/posthog/posthog-js/pull/1"