analytics

package
v0.6.324 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 CaptureFeedback added in v0.6.320

func CaptureFeedback(userID, message string)

CaptureFeedback sends a brev-cli-feedback event to PostHog. This is sent regardless of analytics opt-in since the user explicitly chose to send feedback.

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 the user's distinct ID for tracking. It prefers the real user ID from the store if available, falling back to a stable anonymous UUID.

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() bool

IsAnalyticsEnabled defaults to true; DO_NOT_TRACK and BREV_NO_ANALYTICS override.

func IsAnalyticsFeatureEnabled added in v0.6.317

func IsAnalyticsFeatureEnabled() bool

IsAnalyticsFeatureEnabled is the remote kill switch for PostHog telemetry only — gating PostHog capture lets us turn it off without a release. It does NOT gate analytics.TrackEvent (the brev-internal endpoint), which has its own channel.

func IsDisabledByEnv added in v0.6.323

func IsDisabledByEnv() (disabled bool, varName string)

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 SetUserStore added in v0.6.323

func SetUserStore(s UserStore)

SetUserStore configures the store used to resolve the current user ID.

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"`
}

type UserStore added in v0.6.323

type UserStore interface {
	GetCurrentUserID() (string, error)
}

UserStore provides the current user ID for analytics tracking.

Jump to

Keyboard shortcuts

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