feat: Desktop first-run consent answer records setup_completed

This commit is contained in:
teknium1
2026-09-27 11:19:53 -07:00
committed by Teknium
parent 520f0e9ed5
commit fcd830ee1c
2 changed files with 17 additions and 5 deletions

View File

@@ -67,3 +67,16 @@ def test_status_is_undecided_until_a_key_is_written(tmp_path, monkeypatch):
(worker / "config.yaml").write_text(
yaml.safe_dump({"telemetry": {"shared_metrics": {"enabled": False}}}), encoding="utf-8")
assert _call("shared_metrics.status", {"profile": "code"}) == {"enabled": False, "send": False, "decided": True}
def test_only_the_first_run_answer_records_desktop_setup_completed(tmp_path, monkeypatch):
_launch, _worker = _bind_homes(monkeypatch, tmp_path)
import hermes_cli.observability.shared_metrics_events as events
calls: list[dict] = []
monkeypatch.setattr(events, "record_setup_completed", lambda **kw: calls.append(kw))
_call("shared_metrics.set", {"profile": "code", "enabled": True, "send": False, "first_run": True})
_call("shared_metrics.set", {"profile": "code", "enabled": True, "send": True})
assert calls == [{"surface": "desktop", "provider": "nous"}]

View File

@@ -36,11 +36,10 @@ def _shared_metrics_consent(cfg) -> dict:
def _shared_metrics_record_setup_completed(cfg) -> None:
"""Desktop's setup ends at this first-run answer. A no-op unless collection is on."""
try:
from hermes_cli.observability.shared_metrics_events import record_setup_completed
except ImportError: # the events module lands with the shared-metrics v3 PR
return
"""Desktop has no setup-finish RPC; this first-run answer is the one backend call made once,
right after onboarding settles. A no-op (inside the events API) unless collection is on."""
from hermes_cli.observability.shared_metrics_events import record_setup_completed
model = cfg.get("model") if isinstance(cfg, dict) else None
provider = model.get("provider") if isinstance(model, dict) else None
record_setup_completed(surface="desktop", provider=provider if isinstance(provider, str) and provider else None)