telemetry

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

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

type State

type State struct {
	ID           string `json:"id"`
	FirstRunDate string `json:"first_run_date,omitempty"`
}

State is the persistent telemetry state stored in ~/.mb/telemetry.json.

Jump to

Keyboard shortcuts

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