Documentation
¶
Overview ¶
Package telemetry reports that a version of Kivgraph ran on a machine for the first time, once, and nothing else.
What it measures and why it is not called *installations* is in `docs/adr/0083-a-download-is-not-a-person.md`; the fields it sends are documented in `docs/development/analytics.md` and published on https://kivgraph.dev/telemetry/. The endpoint that receives it is `landing/src/install-report.mjs`.
Three properties hold everywhere in this package, and each of them is a failure that would be invisible without a test:
- **nothing reaches stdout.** `kivgraph serve` runs the MCP surface over stdio, where one stray byte corrupts the session. The daemon serves the same surface over HTTP, where it does not, and this code is shared: it obeys the stricter of the two everywhere. The notice goes to the writer the caller passes, which is stderr;
- **the marker is a create, not a read.** stdio starts bursts -- ADR 0069 measured `69` starts of `serve` with `8` alive at once -- so a read-then-write would let a whole burst find the marker absent and report before any of them had created it. One install would become as many pings as the client happened to spawn;
- **nothing here can fail a command.** Every error is dropped. A machine with no network runs Kivgraph exactly as one with it.
Index ¶
Constants ¶
const DisableEnv = "KIVGRAPH_TELEMETRY"
DisableEnv turns the whole package off when it is set to "0".
One variable, on the reader's side, and it is checked before anything is written: a machine that has opted out leaves no marker either, so opting back in reports the version it is running rather than nothing.
const Endpoint = "https://kivgraph.dev/api/telemetry/first-run"
Endpoint is where a ping goes.
Variables ¶
This section is empty.
Functions ¶
func Announce ¶
Announce reports the first run of this version, or does nothing.
It returns whether a ping was sent, which is for tests and for a caller that wants to log it; every caller in this repository ignores it. It is synchronous: a caller that must not wait runs it in a goroutine, and the timeout above is what bounds that goroutine.
Types ¶
type Options ¶
type Options struct {
// StateDirectory is where the marker lives. It is the state directory and
// not the bundle root because an update replaces the bundle: a marker
// there would fire again on every update, and the number would stop being
// "the first run of a version".
StateDirectory string
// Version is the compiled version.Value.
Version string
// Transport is "stdio" or "daemon": which arrangement is about to serve.
Transport string
// Executable is os.Executable(); the channel is read from its layout.
Executable string
// Notice receives the one-time line telling the reader what was sent.
// Never os.Stdout.
Notice io.Writer
// The seams, all optional. They exist so a test can drive the whole
// function without a network, a home directory or a real clock.
Endpoint string
Client *http.Client
Getenv func(string) string
}
Options is what a caller has to know to report a first run.