{"modulePath":"github.com/brevdev/brev-cli","version":"v0.6.337","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package analytics\n\n## Functions\n\n```go\nfunc CaptureCommand(userID string, cmd *cobra.Command, args []string)\n```\nCaptureCommand captures a CLI command invocation event (success path).\n\n```go\nfunc CaptureCommandError()\n```\nCaptureCommandError captures a CLI command failure event from main.go. Uses stored command context from PersistentPreRunE/PersistentPostRunE.\n\n```go\nfunc CaptureFeedback(userID, message string)\n```\nCaptureFeedback sends a brev-cli-feedback event to PostHog. This is sent regardless of analytics opt-in since the user explicitly chose to send feedback.\n\n```go\nfunc Close()\n```\nClose flushes any pending events and closes the PostHog client.\n\n```go\nfunc GetOrCreateAnalyticsID() string\n```\nGetOrCreateAnalyticsID 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.\n\n```go\nfunc IdentifyUser(userID string)\n```\nIdentifyUser links the anonymous analytics ID to a real user ID using PostHog Alias.\n\n```go\nfunc IsAnalyticsEnabled() bool\n```\nIsAnalyticsEnabled defaults to true; DO\\_NOT\\_TRACK and BREV\\_NO\\_ANALYTICS override.\n\n```go\nfunc IsAnalyticsFeatureEnabled() bool\n```\nIsAnalyticsFeatureEnabled 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.\n\n```go\nfunc IsDisabledByEnv() (disabled bool, varName string)\n```\n\n```go\nfunc IsSSHCertRequired() bool\n```\n\n```go\nfunc MarkFlagSensitive(flags *pflag.FlagSet, name string)\n```\nMarkFlagSensitive annotates a flag so analytics redacts its value.\n\n```go\nfunc RecordCommandStart(cmd *cobra.Command, args []string)\n```\nRecordCommandStart should be called from PersistentPreRunE to record the start time and store the command context for potential error-path capture.\n\n```go\nfunc SetAnalyticsPreference(enabled bool) error\n```\nSetAnalyticsPreference persists the user's analytics preference.\n\n```go\nfunc SetUserStore(s UserStore)\n```\nSetUserStore configures the store used to resolve the current user ID.\n\n```go\nfunc TrackEvent(data EventData) error\n```\n\n## Types\n\n```go\ntype EventData struct {\n\tEventName  string            `json:\"eventName\"`\n\tUserID     string            `json:\"userId,omitempty\"`\n\tProperties map[string]string `json:\"properties,omitempty\"`\n}\n```\n\n```go\ntype UserStore interface {\n\tGetCurrentUserID() (string, error)\n}\n```\nUserStore provides the current user ID for analytics tracking.\n\n","path":"github.com/brevdev/brev-cli/pkg/analytics","name":"analytics","synopsis":"","isRedistributable":true}
