Skip to content

The agent that grows with you

fix(telemetry): switching Desktop collection off drops the backend onboarding latches

teknium14bb58d3d606c
diff --git a/hermes_cli/observability/shared_metrics_desktop.py b/hermes_cli/observability/shared_metrics_desktop.py
index a0afeaa1dd7..a5ab6d32ca8 100644
--- a/hermes_cli/observability/shared_metrics_desktop.py
+++ b/hermes_cli/observability/shared_metrics_desktop.py
@@ -17,6 +17,7 @@ import logging
import os
import platform
import re
+import shutil
import threading
from datetime import date, datetime, timedelta, timezone
from typing import Any
@@ -119,6 +120,13 @@ def _claim_onboarding(step: str, event: str) -> bool:
return True
+def purge_onboarding_latches() -> None:
+ """Collection turned off: drop the per-profile onboarding latches like the renderer drops its copy."""
+ from hermes_constants import get_hermes_home
+
+ shutil.rmtree(get_hermes_home() / "telemetry" / "shared_metrics" / ONBOARDING_LATCH_DIRNAME, ignore_errors=True)
+
+
def _onboarding_fields(*, step: Any, event: Any) -> dict[str, str] | None:
step_word, event_word = _word(step), _word(event)
if step_word not in contract.DESKTOP_ONBOARDING_STEPS or event_word not in contract.DESKTOP_ONBOARDING_EVENTS:
diff --git a/tests/hermes_cli/test_shared_metrics_desktop.py b/tests/hermes_cli/test_shared_metrics_desktop.py
index b6effbd3aec..1aaeacb7281 100644
--- a/tests/hermes_cli/test_shared_metrics_desktop.py
+++ b/tests/hermes_cli/test_shared_metrics_desktop.py
@@ -95,6 +95,15 @@ def test_onboarding_is_once_per_step_event_across_processes(marks, monkeypatch):
_assert_valid(marks.rows)
+def test_turning_collection_off_drops_the_onboarding_latches(marks):
+ _rpc("shared_metrics.desktop_onboarding", step="intro", event="reached")
+ latches = marks.home / "telemetry" / "shared_metrics" / desktop.ONBOARDING_LATCH_DIRNAME
+ assert (latches / "intro.reached").exists()
+
+ assert _rpc("shared_metrics.set", enabled=False)["result"]["enabled"] is False
+ assert not latches.exists()
+
+
def test_disabled_profile_records_nothing_and_leaves_no_latch(marks):
marks.policy["on"] = False
_rpc("shared_metrics.desktop_feature_use", area="projects")
diff --git a/tui_gateway/methods_shared_metrics.py b/tui_gateway/methods_shared_metrics.py
index bdff73670e1..a15c4defcf1 100644
--- a/tui_gateway/methods_shared_metrics.py
+++ b/tui_gateway/methods_shared_metrics.py
@@ -80,6 +80,10 @@ def _(rid, params: dict) -> dict:
from hermes_cli.setup import _record_send_consent_change
# Unconditional, like the wizard: a send key already false may still have an open window.
_record_send_consent_change(enabled=send)
+ if not enabled:
+ from hermes_cli.observability.shared_metrics_desktop import purge_onboarding_latches
+
+ purge_onboarding_latches()
if params.get("first_run") is True:
_shared_metrics_record_setup_completed(cfg)
return _ok(rid, _shared_metrics_consent(cfg))
diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.md
index bc6f15fe112..a03a455b898 100644
--- a/website/docs/developer-guide/relay-shared-metrics.md
+++ b/website/docs/developer-guide/relay-shared-metrics.md
@@ -342,7 +342,7 @@ session/bot/profile names, paths and setting values never leave.
| `hermes.desktop.mode_use` | mode (`sessions`/`bots`), active-minutes bucket, messages-sent bucket, bot-count bucket | How Desktop time splits between Bot Mode and regular Sessions. One row per mode used that day, in that day's period (same once-per-profile-per-day latch as `action_use`); active time sums gaps between interactions of up to 5 minutes. |
| `hermes.desktop.friction` | kind (`notice_dismissed`, `error_toast`, `renderer_crash`, `backend_disconnect`, `slow_frame`), detail (notice id, error category, crash reason, drop reason, frame-duration bucket) | What gets in the way. Error toasts carry only their code-defined category; renderer crashes are recorded by the app shell and reported after the window comes back; slow frames are long frames while the window is visible, capped per day. |
| `hermes.desktop.dislike` | signal (`quick_close`, `cancelled`, `setting_off_default`, `rage_click`, `undo`, `feature_disabled`), target, setting, direction | Signals that a feature is unwanted: a pane closed within 5s of opening, a dialog/flow backed out of, a setting moved to or away from its default (the key only; the backend compares the saved value to the default itself), three clicks on one control within a second, an undo, a shipped feature switched off. Capped per signal per day. |
-| `hermes.desktop.onboarding` | step (first-run steps: provider picker, sign-in, API key, local endpoint, model pick, choose later, free-tier screen, guided setup cards, consent, first message), event (`reached`/`completed`/`abandoned`) | Where first run stops. Each step event once per install; `abandoned` is a step still open when the app next starts. |
+| `hermes.desktop.onboarding` | step (first-run steps: provider picker, sign-in, API key, local endpoint, model pick, choose later, free-tier screen, guided setup cards, consent, first message), event (`reached`/`completed`/`abandoned`) | Where first run stops. Each step event once per profile (latched in a small per-profile file); `abandoned` is a step still open when the app next starts. Switching collection off in the Desktop deletes those latches with the app's own copy. |
Sessions are summarized when they close (finalize, reset or process exit);
delegated child sessions are not counted separately. Milestones latch in the