analytics

package
v0.6.317 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureAnalyticsOptIn added in v0.6.317

func CaptureAnalyticsOptIn(optedIn bool)

CaptureAnalyticsOptIn sends an event recording the user's analytics consent choice. This is sent regardless of the user's choice so we can measure opt-in rates.

func CaptureCommand added in v0.6.317

func CaptureCommand(userID string, cmd *cobra.Command, args []string)

CaptureCommand captures a CLI command invocation event (success path).

func CaptureCommandError added in v0.6.317

func CaptureCommandError()

CaptureCommandError captures a CLI command failure event from main.go. Uses stored command context from PersistentPreRunE/PersistentPostRunE.

func Close added in v0.6.317

func Close()

Close flushes any pending events and closes the PostHog client.

func GetOrCreateAnalyticsID added in v0.6.317

func GetOrCreateAnalyticsID() string

GetOrCreateAnalyticsID returns a stable anonymous UUID for tracking, creating one if needed.

func IdentifyUser added in v0.6.317

func IdentifyUser(userID string)

IdentifyUser links the anonymous analytics ID to a real user ID using PostHog Alias.

func IsAnalyticsEnabled added in v0.6.317

func IsAnalyticsEnabled() (enabled bool, hasBeenAsked bool)

IsAnalyticsEnabled returns whether analytics is enabled and whether the user has been asked.

func IsAnalyticsFeatureEnabled added in v0.6.317

func IsAnalyticsFeatureEnabled() bool

IsAnalyticsFeatureEnabled checks the PostHog feature flag to determine whether to prompt the user about analytics opt-in.

func RecordCommandStart added in v0.6.317

func RecordCommandStart(cmd *cobra.Command, args []string)

RecordCommandStart should be called from PersistentPreRunE to record the start time and store the command context for potential error-path capture.

func SetAnalyticsPreference added in v0.6.317

func SetAnalyticsPreference(enabled bool) error

SetAnalyticsPreference persists the user's analytics preference.

func TrackEvent added in v0.6.237

func TrackEvent(data EventData) error

Types

type EventData added in v0.6.237

type EventData struct {
	EventName  string            `json:"eventName"`
	UserID     string            `json:"userId,omitempty"`
	Properties map[string]string `json:"properties,omitempty"`
}

Jump to

Keyboard shortcuts

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