telemetry

package
v0.0.0-...-ec9e501 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT, MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultReportInterval is the default interval for sending telemetry reports
	DefaultReportInterval = 24 * time.Hour

	// MinReportInterval is the minimum allowed interval for sending telemetry reports
	MinReportInterval = 1 * time.Hour
)
View Source
const (
	// TelemetryConfigFile is the name of the telemetry configuration file
	TelemetryConfigFile = "telemetry.json"

	// DefaultTelemetryEnabled is the default telemetry setting
	DefaultTelemetryEnabled = true
)

Variables

View Source
var TelemetryFilePath = "${HOME}/.nessi/telemetry/data.json"

Default telemetry file path

Functions

func Disable

func Disable(dataDir string) error

Disable disables telemetry collection

func Enable

func Enable(dataDir string) error

Enable enables telemetry collection

func GenerateBadge

func GenerateBadge(repoURL string) (string, error)

GenerateBadge generates a GitHub usage badge for the repository

func GetStatus

func GetStatus(dataDir string) (bool, error)

GetStatus returns the current telemetry status

func RecordCommand

func RecordCommand(dataDir string, command string) error

RecordCommand records a command execution for telemetry

func RecordError

func RecordError(dataDir string, errorType string) error

RecordError records an error for telemetry

func RecordFeatureUsage

func RecordFeatureUsage(dataDir string, feature string) error

RecordFeatureUsage records feature usage for telemetry

func SendTelemetryData

func SendTelemetryData(dataDir string, data *TelemetryData) error

SendTelemetryData writes telemetry data to a file

Types

type Reporter

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

Reporter is responsible for collecting and sending telemetry data

func NewReporter

func NewReporter(dataDir string, reportInterval time.Duration) *Reporter

NewReporter creates a new telemetry reporter

func (*Reporter) Start

func (r *Reporter) Start() error

Start starts the telemetry reporter

func (*Reporter) Stop

func (r *Reporter) Stop()

Stop stops the telemetry reporter

type TelemetryCollector

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

TelemetryCollector collects telemetry data for CLI commands

func NewTelemetryCollector

func NewTelemetryCollector(dataDir string) *TelemetryCollector

NewTelemetryCollector creates a new TelemetryCollector

func (*TelemetryCollector) Flush

func (tc *TelemetryCollector) Flush() error

Flush writes telemetry data to disk

func (*TelemetryCollector) GetEvents

func (tc *TelemetryCollector) GetEvents(eventType string, limit int) ([]map[string]interface{}, error)

GetEvents returns the events of a specific type

func (*TelemetryCollector) GetStats

func (tc *TelemetryCollector) GetStats() (map[string]int, error)

GetStats returns the current telemetry stats

func (*TelemetryCollector) RecordEvent

func (tc *TelemetryCollector) RecordEvent(eventType string, data map[string]interface{})

RecordEvent records a telemetry event

func (*TelemetryCollector) Stop

func (tc *TelemetryCollector) Stop() error

Stop stops the telemetry collector

type TelemetryConfig

type TelemetryConfig struct {
	Enabled       bool      `json:"enabled"`
	InstallID     string    `json:"install_id"`
	FirstRun      time.Time `json:"first_run"`
	LastRun       time.Time `json:"last_run"`
	LastSubmitted time.Time `json:"last_submitted"`
	Version       string    `json:"version"`
}

TelemetryConfig represents the telemetry configuration

type TelemetryData

type TelemetryData struct {
	InstallID     string                 `json:"install_id"`
	Timestamp     time.Time              `json:"timestamp"`
	Version       string                 `json:"version"`
	OS            string                 `json:"os"`
	Arch          string                 `json:"arch"`
	CPUCores      int                    `json:"cpu_cores"`
	MemoryTotal   uint64                 `json:"memory_total"`
	Uptime        uint64                 `json:"uptime"`
	CommandStats  map[string]int         `json:"command_stats"`
	FeatureUsage  map[string]int         `json:"feature_usage"`
	ErrorCounts   map[string]int         `json:"error_counts"`
	CustomMetrics map[string]interface{} `json:"custom_metrics"`
}

TelemetryData represents the telemetry data sent to the server

func CollectTelemetryData

func CollectTelemetryData(dataDir string, commandStats map[string]int, featureUsage map[string]int, errorCounts map[string]int, customMetrics map[string]interface{}) (*TelemetryData, error)

CollectTelemetryData collects telemetry data

Jump to

Keyboard shortcuts

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