telemetry

package
v0.9.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package telemetry reports first-run and supervisor-registration facts for a version of Kivgraph, once where the fact has a local marker, 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

View Source
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.

View Source
const Endpoint = "https://kivgraph.dev/api/telemetry/first-run"

Endpoint is where a ping goes.

Variables

This section is empty.

Functions

func Announce

func Announce(ctx context.Context, options Options) bool

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.

func AnnounceSupervisorInstall added in v0.9.4

func AnnounceSupervisorInstall(ctx context.Context, options Options) bool

AnnounceSupervisorInstall reports that `daemon install` registered this machine's supervisor entry for this version, or does nothing.

It is a third fact, next to the installer's and the binary's, and a narrower one where it applies: a systemd, launchd or Task Scheduler entry is not something a process acquires as a side effect of running once. A row here means someone asked the platform to keep the daemon around. The cost is scope -- it only ever fires for the shared-daemon arrangement, which is not how most real use happens, per `docs/adr/0083-a-download-is-not-a-person.md`.

The marker lives in its own namespace so that installing the daemon and running it once are independent facts: a machine can do either first, or both, and each is reported exactly once per version.

func Platform

func Platform() string

Platform names the build, in the vocabulary the release assets use.

The same string appears in `kivgraph-linux-amd64.tar.gz` and in the download series of Layer 0, so the two layers can be read side by side rather than joined by hand.

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" for a binary row. It is empty for a
	// fact that does not describe a serving arrangement, such as supervisor
	// registration.
	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 the metadata a caller supplies for a telemetry fact.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL