analytics

package
v0.1.43 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTypeConnectionTimeout = "connection_timeout"
	ErrorTypeAuthFailed        = "auth_failed"
	ErrorTypeConfigInvalid     = "config_invalid"
	ErrorTypeFileNotFound      = "file_not_found"
	ErrorTypeServiceError      = "service_error"
	ErrorTypeUserCancelled     = "user_cancelled"
	ErrorTypeUnknown           = "unknown"
)

Error categories - never log raw error messages (may contain PII)

View Source
const NoticeText = `` /* 239-byte string literal not displayed */

Variables

This section is empty.

Functions

func CategorizeError added in v0.1.23

func CategorizeError(err error) string

CategorizeError returns a safe category string for an error Never returns the actual error message to avoid leaking PII

func ShowFirstRunNotice added in v0.1.23

func ShowFirstRunNotice(cmd *cobra.Command) bool

ShowFirstRunNotice displays the analytics notice on first run Returns true if the notice was shown (and we should track first_run)

Types

type Client added in v0.1.23

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

Client wraps the PostHog client for analytics

func NewClient added in v0.1.23

func NewClient() *Client

NewClient creates a new analytics client. Returns nil if analytics is disabled.

func (*Client) Alias added in v0.1.23

func (c *Client) Alias(userID string)

Alias connects the anonymous ID to a user ID (call after login)

func (*Client) Close added in v0.1.23

func (c *Client) Close() error

Close flushes pending events and closes the client

func (*Client) Track added in v0.1.23

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

Track sends an event to PostHog with the provided properties.

type Tracker added in v0.1.23

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

Tracker handles analytics for a single command execution

func NewTracker added in v0.1.23

func NewTracker(cmd *cobra.Command) *Tracker

NewTracker creates a tracker for the given command Returns nil if analytics is disabled

func (*Tracker) Alias added in v0.1.23

func (t *Tracker) Alias(userID string)

Alias connects anonymous ID to user ID (call after login)

func (*Tracker) Close added in v0.1.23

func (t *Tracker) Close()

Close flushes and closes the analytics client

func (*Tracker) Track added in v0.1.23

func (t *Tracker) Track(event string, props map[string]any)

Track sends a custom event (delegates to client)

func (*Tracker) TrackResult added in v0.1.23

func (t *Tracker) TrackResult(err error)

TrackResult records the command result (call after Execute returns)

Jump to

Keyboard shortcuts

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