telemetry

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package telemetry provides privacy-respecting analytics for gsh. It follows the Homebrew analytics model - opt-out with notification, strictly anonymous, and silent failures.

Index

Constants

View Source
const (
	EventSessionStart = "session_start"
	EventSessionEnd   = "session_end"

	// Feature adoption events (counts only)
	EventScriptExecution = "script_execution"

	// Error categories (no content)
	EventError = "error"
)

Event names - what we track

View Source
const (
	ErrorCategoryParse         = "parse_error"
	ErrorCategoryRuntime       = "runtime_error"
	ErrorCategoryMCPConnection = "mcp_connection_failed"
	ErrorCategoryAgent         = "agent_error"
	ErrorCategoryScript        = "script_error"
)

Error categories for tracking

Variables

This section is empty.

Functions

func GetFirstRunNotification

func GetFirstRunNotification() string

GetFirstRunNotification returns the notification message to show on first run

func GetTelemetryStatus

func GetTelemetryStatus() string

GetTelemetryStatus returns the current telemetry status as a string

func HandleTelemetryCommand

func HandleTelemetryCommand(args []string) (handled bool, err error)

HandleTelemetryCommand processes the "gsh telemetry" CLI command Returns true if the command was handled, false if it should be passed through

func IsFirstRun

func IsFirstRun() bool

IsFirstRun checks if this is the first time gsh is being run

func MarkFirstRunComplete

func MarkFirstRunComplete() error

MarkFirstRunComplete marks that the first run notification has been shown

func SetTelemetryEnabled

func SetTelemetryEnabled(enabled bool) error

SetTelemetryEnabled enables or disables telemetry

Types

type Client

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

Client manages telemetry for gsh

func NewClient

func NewClient(cfg Config) (*Client, error)

NewClient creates a new telemetry client

func (*Client) Close

func (c *Client) Close() error

Close flushes pending events and closes the client

func (*Client) IsEnabled

func (c *Client) IsEnabled() bool

IsEnabled returns whether analytics is currently enabled

func (*Client) TrackError

func (c *Client) TrackError(category string)

TrackError records an error by category (no error content)

func (*Client) TrackScriptExecution

func (c *Client) TrackScriptExecution()

TrackScriptExecution records a .gsh script execution (count only)

func (*Client) TrackSessionEnd

func (c *Client) TrackSessionEnd()

TrackSessionEnd records the end of a gsh session with duration

func (*Client) TrackSessionStart

func (c *Client) TrackSessionStart(mode string)

TrackSessionStart records the start of a gsh session

func (*Client) TrackStartupTime

func (c *Client) TrackStartupTime(durationMs int64)

TrackStartupTime records the startup time in milliseconds

type Config

type Config struct {
	Version string
	Enabled bool // Override enabled state (for testing)
}

Config holds configuration for the telemetry client

Jump to

Keyboard shortcuts

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