Documentation
¶
Overview ¶
Package telemetry sends anonymous, opt-in usage pings — G8.6 (F4.9).
Off by default. A project turns it on with `telemetry.enabled: true` in its own config.yaml; the standard DO_NOT_TRACK environment variable (https://consoledonottrack.com) always wins over that, on or off — see DoNotTrack. What one event carries, in full:
- the binary's own version
- the OS and architecture it's running on
- which subcommand was invoked (e.g. "status", "dashboard token rotate")
- how long that invocation took
- whether it succeeded
- a random per-installation id (~/.orch/install_id, see InstallID) that ties events together without identifying a person or a project
Plus, at most once per project, three onboarding milestones (#378) — see Milestone.
Never a file path, a prompt, a task id, or a project id/name — none of that reaches this package in the first place; Reporter has no field for any of it. See docs/TELEMETRY.md for this same list as shipped documentation, kept in step with the Event struct below.
Index ¶
Constants ¶
const ( MilestoneProjectInit = "project_init" MilestoneFirstDispatch = "first_dispatch" MilestoneFirstTaskDone = "first_task_done" )
The onboarding milestones (#378), each sent at most once per project: the project exists, its first task went to an agent, an agent first finished a task. Together they say how many installs reach a working agent.
const DefaultTimeout = 2 * time.Second
DefaultTimeout bounds how long a report may hold up the process exiting. Best-effort: a slow or unreachable collector must never make `orch` itself feel slow.
Variables ¶
This section is empty.
Functions ¶
func DoNotTrack ¶
func DoNotTrack() bool
DoNotTrack reports whether the standard DO_NOT_TRACK environment variable opts this invocation out, regardless of what config.yaml says. Its mere presence is enough to opt out; "0" is the one value that does NOT, matching every other tool that honours this variable (see https://consoledonottrack.com).
func InstallID ¶
InstallID returns this machine/user's random per-installation id, generating and persisting one at ~/.orch/install_id on first use.
It identifies an orch installation, never a project or a person: no project id, path, or hostname is derived from it or stored alongside it, and it is the same value across every project this user runs orch against on this machine.
Types ¶
type Event ¶
type Event struct {
InstallID string `json:"install_id"`
Version string `json:"version"`
OS string `json:"os"`
Arch string `json:"arch"`
Command string `json:"command"`
DurationMS int64 `json:"duration_ms"`
Success bool `json:"success"`
}
Event is exactly what one report sends — see the package doc comment for the "why only this" list. Every field here is safe to publish; if a field wouldn't be, it does not belong on this struct.
type Milestone ¶
type Milestone struct {
InstallID string `json:"install_id"`
Version string `json:"version"`
OS string `json:"os"`
Arch string `json:"arch"`
Event string `json:"event"`
Backend string `json:"backend,omitempty"`
Template string `json:"template,omitempty"`
}
Milestone is exactly what one milestone report sends: Event's identity fields, which milestone, and for first_dispatch the backend it went to (claude, codex…), for project_init the template (or "blank"). Like Event, nothing about the project itself.
type Reporter ¶
type Reporter struct {
// Enabled is the already-resolved decision — the caller ANDs
// config.yaml's telemetry.enabled with !DoNotTrack() before setting
// this, so Report itself has exactly one policy question to ask
// ("am I on"), which keeps it simple to test both ways.
Enabled bool
// Endpoint overrides defaultEndpoint. An empty value here still means
// "no endpoint configured" and Report no-ops the same as when
// disabled — see defaultEndpoint's own TODO for why that's the
// current default everywhere.
Endpoint string
InstallID string
Version string
// Transport lets a caller (production code and tests alike) control
// exactly how the HTTP request is sent, or capture it without a real
// server. nil uses http.DefaultTransport.
Transport http.RoundTripper
// Timeout defaults to DefaultTimeout when zero or negative.
Timeout time.Duration
// Logger defaults to slog.Default(). Used only at Debug level — a
// failed report is never surfaced to the operator as an error; the
// command that triggered it already ran to completion by the time
// Report is called.
Logger *slog.Logger
}
Reporter sends one Event per orch invocation, when enabled.
func (Reporter) Report ¶
Report sends one event, best-effort. It never returns an error and is safe to call unconditionally on every invocation: a disabled Reporter, an unset endpoint, or a network failure all just mean nothing was sent.
func (Reporter) ReportMilestone ¶
ReportMilestone sends one milestone and reports whether the collector accepted it (a 2xx), so the caller marks it sent only then: a milestone reached while telemetry was off or unreachable goes out the next time it can.