Documentation
¶
Overview ¶
Package telemetry provides anonymous usage tracking for the tapes CLI using PostHog. A persistent UUID is stored in ~/.tapes/telemetry.json and all events are anonymous by default. Telemetry can be disabled through the config.toml telemetry.disabled key, the --disable-telemetry flag, the TAPES_TELEMETRY_DISABLED environment variable (all handled by Viper), or by running in a detected CI environment.
Index ¶
- Constants
- Variables
- func CommonProperties() posthog.Properties
- func IsCI() bool
- func WithContext(ctx context.Context, c *Client) context.Context
- type Client
- func (c *Client) CaptureCommandRun(command string)
- func (c *Client) CaptureError(command, errType string)
- func (c *Client) CaptureInit(preset string)
- func (c *Client) CaptureInstall()
- func (c *Client) CaptureMCPTool(tool string)
- func (c *Client) CaptureSearch(resultCount int)
- func (c *Client) CaptureServerStarted(mode string)
- func (c *Client) CaptureSessionCreated(provider string)
- func (c *Client) CaptureSyncPull()
- func (c *Client) CaptureSyncPush()
- func (c *Client) Close() error
- type Manager
- type State
Constants ¶
const ( EventInstall = "tapes_cli_installed" EventCommandRun = "tapes_cli_command_run" EventInit = "tapes_cli_init" EventSessionCreated = "tapes_cli_session_created" EventSearch = "tapes_cli_search" EventServerStarted = "tapes_cli_server_started" EventMCPTool = "tapes_cli_mcp_tool" EventSyncPush = "tapes_cli_sync_push" EventSyncPull = "tapes_cli_sync_pull" EventError = "tapes_cli_error" )
Event name constants for all tracked telemetry events.
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 CommonProperties ¶
func CommonProperties() posthog.Properties
CommonProperties returns properties that are included with every event.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the PostHog SDK client for capturing telemetry events. All capture methods are nil-safe: calling them on a nil *Client is a no-op.
func FromContext ¶
FromContext returns the telemetry Client from ctx, or nil if none is set.
func NewClient ¶
NewClient creates a new telemetry Client that sends events to PostHog. The distinctID should be the persistent UUID from the telemetry Manager. Returns nil (not an error) when PostHogAPIKey is empty so callers can treat a nil *Client as "telemetry disabled" without extra checks.
func (*Client) CaptureCommandRun ¶
CaptureCommandRun records a CLI command execution.
func (*Client) CaptureError ¶
CaptureError records an error event.
func (*Client) CaptureInit ¶
CaptureInit records a tapes init event.
func (*Client) CaptureInstall ¶
func (c *Client) CaptureInstall()
CaptureInstall records a first-run install event.
func (*Client) CaptureMCPTool ¶
CaptureMCPTool records an MCP tool invocation.
func (*Client) CaptureSearch ¶
CaptureSearch records a search operation.
func (*Client) CaptureServerStarted ¶
CaptureServerStarted records a server startup event.
func (*Client) CaptureSessionCreated ¶
CaptureSessionCreated records a new recording session.
func (*Client) CaptureSyncPull ¶
func (c *Client) CaptureSyncPull()
CaptureSyncPull records a sync pull event.
func (*Client) CaptureSyncPush ¶
func (c *Client) CaptureSyncPush()
CaptureSyncPush records a sync push event.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages the persistent telemetry identity stored in the .tapes/ directory.
func NewManager ¶
NewManager creates a new telemetry Manager. If configDir is non-empty it is used as the .tapes/ directory; otherwise standard dotdir resolution applies. When no .tapes/ directory is found, one is created at ~/.tapes/.
func (*Manager) LoadOrCreate ¶
LoadOrCreate reads the existing telemetry state or creates a new one with a fresh UUID and the current time as first_run. Returns the state and a bool indicating whether this was a first run (i.e. the file was just created).