Documentation
¶
Overview ¶
Package telemetry provides anonymous usage tracking for the mb CLI. Telemetry is opt-out via --disable-telemetry flag, config, or automatic CI environment detection.
Index ¶
- Variables
- func IsCI() bool
- func WithContext(ctx context.Context, c *PosthogClient) context.Context
- type PosthogClient
- func (p *PosthogClient) CaptureCommandRun(command string)
- func (p *PosthogClient) CaptureDown(success bool)
- func (p *PosthogClient) CaptureError(command string, errType string)
- func (p *PosthogClient) CaptureInstall()
- func (p *PosthogClient) CapturePull(mixtape string, success bool)
- func (p *PosthogClient) CaptureSSH()
- func (p *PosthogClient) CaptureUp(mixtape string, success bool)
- func (p *PosthogClient) Done()
- type State
Constants ¶
This section is empty.
Variables ¶
var ( // PostHogAPIKey is the PostHog write-only project API key. // Injected at build time via ldflags; defaults to empty (telemetry disabled). PostHogAPIKey = "" // PostHogEndpoint is the PostHog ingestion endpoint. // Injected at build time via ldflags; defaults to the US region. PostHogEndpoint = "https://us.i.posthog.com" )
Functions ¶
func IsCI ¶
func IsCI() bool
IsCI returns true if the process appears to be running in a CI environment.
func WithContext ¶
func WithContext(ctx context.Context, c *PosthogClient) context.Context
WithContext returns a copy of ctx with the telemetry client attached.
Types ¶
type PosthogClient ¶
type PosthogClient struct {
// contains filtered or unexported fields
}
PosthogClient wraps the PostHog SDK for anonymous CLI telemetry. All capture methods are nil-safe: calling them on a nil *PosthogClient is a no-op.
func FromContext ¶
func FromContext(ctx context.Context) *PosthogClient
FromContext retrieves the PosthogClient from a context. Returns nil if absent.
func NewPosthogClient ¶
func NewPosthogClient(activated bool, version string) *PosthogClient
NewPosthogClient creates a new telemetry client. Returns nil when activated is false or PostHogAPIKey is empty, skipping the PostHog connection and UUID file creation entirely. Nil-safe methods make this transparent to callers.
func (*PosthogClient) CaptureCommandRun ¶
func (p *PosthogClient) CaptureCommandRun(command string)
CaptureCommandRun tracks command usage for DAU calculation.
func (*PosthogClient) CaptureDown ¶
func (p *PosthogClient) CaptureDown(success bool)
CaptureDown tracks sandbox shutdown.
func (*PosthogClient) CaptureError ¶
func (p *PosthogClient) CaptureError(command string, errType string)
CaptureError tracks errors anonymously.
func (*PosthogClient) CaptureInstall ¶
func (p *PosthogClient) CaptureInstall()
CaptureInstall tracks first-time installs.
func (*PosthogClient) CapturePull ¶
func (p *PosthogClient) CapturePull(mixtape string, success bool)
CapturePull tracks mixtape pulls.
func (*PosthogClient) CaptureSSH ¶
func (p *PosthogClient) CaptureSSH()
CaptureSSH tracks SSH connections.
func (*PosthogClient) CaptureUp ¶
func (p *PosthogClient) CaptureUp(mixtape string, success bool)
CaptureUp tracks sandbox creation.
func (*PosthogClient) Done ¶
func (p *PosthogClient) Done()
Done flushes pending events and closes the client.