telemetry

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package telemetry — anonymous, opt-in PostHog event emission for clawtool (ADR-014 F5, gemini's R4 pick).

Strict guarantee: never emits prompts, paths, file contents, secrets, or env values. The CLI dispatcher strips arg slices before passing to Track; we additionally allow-list the keys that can ride on a payload.

Per ADR-007 we wrap github.com/posthog/posthog-go. The client is nil-safe; passing nil to Track is a no-op so call sites don't need to gate every call.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobal

func SetGlobal(c *Client)

SetGlobal registers the process-wide client. Idempotent.

func SilentDisabled

func SilentDisabled() bool

SilentDisabled tells callers whether the env var explicitly disables telemetry regardless of config (for the "kill switch" use case operators want before talking on conference Wi-Fi).

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps a PostHog client + the per-host anonymous distinct ID. Nil-safe: `(*Client)(nil).Track(...)` is a clean no-op.

func Get

func Get() *Client

Get returns the process-wide client (or nil when none set).

func New

func New(cfg config.TelemetryConfig) *Client

New initialises the client when telemetry is enabled. Disabled config returns a nil-friendly client (Track is a no-op). Init failures degrade silently — telemetry is never load-bearing.

func (*Client) Close

func (c *Client) Close() error

Close flushes pending events. Idempotent.

func (*Client) Enabled

func (c *Client) Enabled() bool

Enabled reports whether the client will actually emit. Useful for hot-path skips on expensive payload construction.

func (*Client) Track

func (c *Client) Track(event string, properties map[string]any)

Track emits one event. Properties outside the allow-list are silently dropped. Safe to call on a nil receiver.

Jump to

Keyboard shortcuts

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