Documentation
¶
Overview ¶
Package telemetry sends fire-and-forget product analytics events to PostHog.
Design notes:
- All HTTP I/O is non-blocking via goroutines tracked by a sync.WaitGroup; callers must invoke Flush() at process exit (root.go does this) so events have a chance to land before the binary returns.
- The anonymous distinct_id is generated on first run and persisted to ~/.config/airskills/telemetry.json so events from a single machine link together even before login.
- On login, Identify() emits a PostHog $identify event with $anon_distinct_id so prior anonymous events get aliased to the real user.
- Failures are swallowed: telemetry must never break a user-facing command.
- Users can opt out with AIRSKILLS_NO_TELEMETRY=1.
Index ¶
Constants ¶
const APIKey = "phc_tJ5pdZxz6wrM4JcTAXH86PnSKWbCS5YjwZ6MeMD2GX8R"
PostHog project ingest key for the Airskills project (151269). This is the same kind of public key that PostHog embeds in client-side JS snippets — it only allows writing events, never reading data, so it's safe to ship in the binary.
Variables ¶
var ( // CLIVersion is set by root.go from the linker-injected version string so // every event carries the binary version as a super property. Assigned // once before Init() on the main goroutine, never mutated after. CLIVersion string )
Functions ¶
func AnonymousID ¶
func AnonymousID() string
AnonymousID returns the stable anonymous ID for this machine. Safe to call on the HTTP hot path — reads a cached copy without taking the mutex. Set once by Init() and never mutated, so a plain read is race-free.
func Capture ¶
Capture queues an event for delivery. Non-blocking; the actual HTTP request runs in a goroutine and is awaited by Flush(). wg.Add happens under the mutex to guarantee it's ordered-before any subsequent Flush().
func Flush ¶
Flush waits up to the given timeout for all in-flight captures to finish. Called from root.Execute() before the binary exits.
func Identify ¶
func Identify(userID, username string)
Identify links the current anonymous ID to a real user. Should be called once after a successful login. Persists the user ID so subsequent runs continue using it as the distinct ID.
Types ¶
This section is empty.