4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
"""Bridge investigation terminal outcomes to PostHog lifecycle analytics."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from platform.analytics.cli import (
|
|
capture_investigation_cancelled,
|
|
capture_investigation_outcome,
|
|
)
|
|
from surfaces.interactive_shell.ui.investigation_outcome import InvestigationOutcome
|
|
|
|
|
|
def _root_cause_excerpt(final_state: dict[str, Any] | None) -> str:
|
|
if not final_state:
|
|
return ""
|
|
root = final_state.get("root_cause")
|
|
if isinstance(root, str) and root.strip():
|
|
return root.strip()
|
|
return ""
|
|
|
|
|
|
def publish_investigation_outcome_analytics(outcome: InvestigationOutcome) -> None:
|
|
"""Emit structured investigation analytics for one terminal run."""
|
|
if outcome.status == "cancelled":
|
|
capture_investigation_cancelled(
|
|
investigation_id=outcome.investigation_id,
|
|
investigation_target=outcome.target,
|
|
state=outcome.final_state,
|
|
)
|
|
# Completed runs must not carry placeholder failure properties; consumers
|
|
# would otherwise have to special-case failure_category == "unknown".
|
|
not_completed = outcome.status != "completed"
|
|
capture_investigation_outcome(
|
|
investigation_id=outcome.investigation_id,
|
|
status=outcome.status,
|
|
investigation_target=outcome.target,
|
|
root_cause_excerpt=_root_cause_excerpt(outcome.final_state),
|
|
error_excerpt=outcome.error_message if not_completed else "",
|
|
failure_category=(outcome.failure_category or None) if not_completed else None,
|
|
integration_involved=(outcome.integration_involved or None) if not_completed else None,
|
|
integration_failure_message=(
|
|
(outcome.integration_failure_message or None) if not_completed else None
|
|
),
|
|
failure_detail=(outcome.error_detail or None) if not_completed else None,
|
|
state=outcome.final_state,
|
|
)
|
|
|
|
|
|
__all__ = ["publish_investigation_outcome_analytics"]
|