: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
feat(tasks): run analysis fully in the background (#95972)
Shy Alter798776d122f9
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskAnalysisButton.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskAnalysisButton.tsxindex bf342c00b19b..75d610c17918 100644--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskAnalysisButton.tsx+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskAnalysisButton.tsx@@ -6,10 +6,8 @@ import {} from "@posthog/shared";import type { Task } from "@posthog/shared/domain-types";import { toastError } from "@posthog/ui/features/notifications/errorDetails";-import { toast } from "@posthog/ui/primitives/toast";import type { ReactElement } from "react";import { useAuthenticatedMutation } from "../../../hooks/useAuthenticatedMutation";-import { navigateToTaskDetail } from "../../../router/navigationBridge";import { track } from "../../../shell/analytics";import { useFeatureFlag } from "../../feature-flags/useFeatureFlag";@@ -39,12 +37,6 @@ export function useTaskAnalysis(task: Task): TaskAnalysisControls {run_id: runId ?? "",created: result.created,});- toast.success(- result.created- ? "Analyzing this run. The report will appear on the analysis task."- : "An analysis for this run already exists. Opening it.",- );- navigateToTaskDetail(result.analysis_task_id);},onError: (error) => {toastError("Could not analyze this run", error);diff --git a/products/tasks/backend/logic/services/task_analysis.py b/products/tasks/backend/logic/services/task_analysis.pyindex 0448de6397ab..e60684cd992f 100644--- a/products/tasks/backend/logic/services/task_analysis.py+++ b/products/tasks/backend/logic/services/task_analysis.py@@ -268,6 +268,7 @@ def create_task_analysis(*, team: Team, user_id: int, target_task: Task, target_pending_user_message=prompt,extra_run_state=extra_run_state,inactivity_timeout_seconds=TASK_ANALYSIS_INACTIVITY_TIMEOUT_SECONDS,+ internal=True,)except IntegrityError:claimed = find_existing_analysis_task(team_id=team.id, target_run_id=str(target_run.id))diff --git a/products/tasks/backend/tests/test_api.py b/products/tasks/backend/tests/test_api.pyindex e1937170cca6..c9980a1b9960 100644--- a/products/tasks/backend/tests/test_api.py+++ b/products/tasks/backend/tests/test_api.py@@ -14160,6 +14160,7 @@ class TestTaskRunAnalyzeAPI(BaseTaskAPITest):self.assertTrue(body["created"])analysis_task = Task.objects.get(id=body["analysis_task_id"])self.assertEqual(analysis_task.origin_product, Task.OriginProduct.TASK_ANALYSIS)+ self.assertTrue(analysis_task.internal)self.assertIn("analyzing-task-runs", analysis_task.description)run = analysis_task.latest_runassert run is not None