telemetry

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TelemetryEndpoint = "https://api.tokman.dev/v1/telemetry"
	ConsentFile       = "telemetry_consent"
)

Variables

This section is empty.

Functions

func CollectDaily added in v0.28.0

func CollectDaily(tracker interface{}) error

CollectDaily collects and sends daily telemetry

func FlushBatcher added in v0.28.0

func FlushBatcher() error

FlushBatcher flushes all pending telemetry events

func ForgetConsent added in v0.28.0

func ForgetConsent() error

ForgetConsent removes consent and all local telemetry data

func IsEnabled added in v0.28.0

func IsEnabled() bool

IsEnabled returns true if telemetry is enabled

func Send added in v0.28.0

func Send(data *TelemetryData) error

Send sends telemetry data (if enabled)

func SetConsent added in v0.28.0

func SetConsent(enabled bool) error

SetConsent sets the telemetry consent status

func ShowConsentPrompt added in v0.28.0

func ShowConsentPrompt()

ShowConsentPrompt displays the interactive consent prompt

func TrackFeatureUsage added in v0.28.0

func TrackFeatureUsage(featureName string, details map[string]interface{}) error

TrackFeatureUsage tracks usage of specific features (test-runner, quota, etc.)

func TrackQuotaUsage added in v0.28.0

func TrackQuotaUsage(tier string, usagePct float64)

TrackQuotaUsage tracks gain --quota usage

func TrackRewrite added in v0.28.0

func TrackRewrite(originalCmd, rewrittenCmd string, testRunner bool)

TrackRewrite tracks command rewrite events

func TrackTestRunnerUsage added in v0.28.0

func TrackTestRunnerUsage(runnerType string, autoDetected bool)

TrackTestRunnerUsage tracks test-runner command usage

Types

type ConsentStatus added in v0.28.0

type ConsentStatus int

ConsentStatus represents the user's telemetry consent

const (
	ConsentUnknown ConsentStatus = iota
	ConsentEnabled
	ConsentDisabled
)

func GetConsent added in v0.28.0

func GetConsent() ConsentStatus

GetConsent returns the current consent status

type EventBatcher added in v0.28.0

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

EventBatcher batches telemetry events for efficient sending

func GetBatcher added in v0.28.0

func GetBatcher() *EventBatcher

GetBatcher returns the global event batcher

func (*EventBatcher) AddEvent added in v0.28.0

func (b *EventBatcher) AddEvent(event map[string]interface{})

AddEvent adds an event to the batch

func (*EventBatcher) Flush added in v0.28.0

func (b *EventBatcher) Flush() error

Flush sends all batched events

type TelemetryData added in v0.28.0

type TelemetryData struct {
	// Identity (anonymized)
	DeviceHash string `json:"device_hash"`

	// Environment
	Version       string `json:"version"`
	OS            string `json:"os"`
	Arch          string `json:"arch"`
	InstallMethod string `json:"install_method,omitempty"`

	// Usage volume (24h)
	CommandCount     int `json:"command_count_24h"`
	TotalCommands    int `json:"total_commands"`
	TokensSaved24h   int `json:"tokens_saved_24h"`
	TokensSaved30d   int `json:"tokens_saved_30d"`
	TokensSavedTotal int `json:"tokens_saved_total"`

	// Quality
	ParseFailures   int      `json:"parse_failures"`
	PassthroughCmds []string `json:"passthrough_cmds,omitempty"` // Top 5, no args

	// Ecosystem
	CommandCategories map[string]int `json:"command_categories,omitempty"`

	// Retention
	DaysSinceFirstUse int `json:"days_since_first_use"`
	ActiveDays30d     int `json:"active_days_30d"`

	// Adoption
	AgentHookType     string `json:"agent_hook_type,omitempty"`
	CustomFilterCount int    `json:"custom_filter_count"`

	// Features
	MetaCommandsUsed []string `json:"meta_commands_used,omitempty"`

	// Economics
	EstimatedUSDSaved float64 `json:"estimated_usd_saved"`

	Timestamp time.Time `json:"timestamp"`
}

TelemetryData represents the data sent to telemetry server

Jump to

Keyboard shortcuts

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