Documentation
¶
Overview ¶
Package telemetry reports a runtime's own events to a PostHog-compatible batch endpoint: queued, sent a minute after the first of them (or at once when a batch is full), never more than a batch per request. Only a released runtime reports; a checkout stays quiet. Events carry technical properties only, never a prompt, a title or a path.
Index ¶
Constants ¶
const MaxEvents = 40
MaxEvents is the most events one request carries.
const MessageMax = 300
MessageMax is the most runes a reported message keeps.
Variables ¶
var DefaultURL, DefaultKey string
Built in at release build time (-ldflags -X ...telemetry.DefaultURL=... -X ...telemetry.DefaultKey=...): where a released runtime sends its anonymous reports unless told otherwise. A checkout carries neither and sends nothing.
Functions ¶
func Body ¶
Body is what the batch endpoint takes: the person and the common properties go into every event.
func EnvOff ¶
EnvOff says whether the environment turns telemetry off, and by which variable: RUNTIME_TELEMETRY or HARNESSLY_TELEMETRY set to off (also 0, false, no, none, disabled), or DO_NOT_TRACK set to anything but 0 or false (https://consoledonottrack.com).
func Fingerprint ¶
Fingerprint groups one error: where it was seen, its kind and its scrubbed text.
Types ¶
type Config ¶
type Config struct {
// URL is the batch endpoint ("" sends nothing); Key the project key it takes.
URL, Key string
// Common are the properties every event carries first, in their order.
Common *jsvalue.Object
// DistinctID names who the events are about, read at each send.
DistinctID func() string
// Allow, when set, is asked at every push and every send: false drops the events (the person turned it off).
Allow func() bool
Delay time.Duration
Client *http.Client
Log func(level, msg string, kv ...any)
}
Config says where events go and what each of them carries.
type Consent ¶
type Consent struct {
Path string
Getenv func(string) string
// contains filtered or unexported fields
}
Consent is the machine's choice about telemetry, kept in a file of the data directory, with the random id its reports carry in place of a person (never an e-mail, a host name or a path). The environment's off wins over the file: an operator turns it off for every machine they set up, a person turns it off in Settings.
func (*Consent) Allowed ¶
Allowed says whether reports may leave the machine now; it is read at every push and every send, so a change takes effect at once.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue batches events.
type Reporter ¶
type Reporter struct {
Queue *Queue
PerHour int
Now func() time.Time
// contains filtered or unexported fields
}
Reporter sends errors as PostHog error tracking takes them ($exception): scrubbed, each distinct error once an hour, at most PerHour distinct errors an hour, so a loop on one machine costs nothing and floods nobody.