Help us shape the future of Go! Take the 2026 Go Developer Survey

telemetry

package
v1.56.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventCommandExecuted = "cli_command_executed"
	EventDoctorRun       = "doctor_diagnostics_run"
	EventTestConnection  = "telemetry_connection_tested"
)

Event names

Variables

This section is empty.

Functions

func BuildCommandProperties

func BuildCommandProperties(cmd *cobra.Command, args []string, duration time.Duration, execErr error) map[string]any

BuildCommandProperties constructs a standardized, sanitized properties map for command execution.

func CategorizeError

func CategorizeError(err error) string

CategorizeError categorizes an error without revealing private paths, tokens, or messages.

func DetectShell

func DetectShell() string

DetectShell attempts to identify the current shell from the environment.

func Drain

func Drain(timeout time.Duration)

Drain flushes pending telemetry events with the specified timeout.

func ExtractCommandPath

func ExtractCommandPath(cmd *cobra.Command) (string, string, string)

ExtractCommandPath returns the sanitized command path (e.g. "git sync").

func ExtractSanitizedFlags

func ExtractSanitizedFlags(cmd *cobra.Command) []string

ExtractSanitizedFlags extracts ONLY the names of flags that were explicitly changed/passed, deliberately omitting flag values to prevent accidental leakage of sensitive tokens or paths.

func FormatEndpoint

func FormatEndpoint(baseURL string) string

FormatEndpoint constructs the full URL for the OpenPanel track endpoint.

func Identify

func Identify(properties map[string]any)

Identify sends an identify call for the current profile.

func Init

func Init(cfg config.TelemetryConfig, verbose bool)

Init initializes the global telemetry client.

func IsCI

func IsCI() bool

IsCI returns true if the current environment is detected as a Continuous Integration runner.

func IsInteractive

func IsInteractive() bool

IsInteractive checks if standard output is connected to an interactive terminal TTY.

func SetClient

func SetClient(c *Client)

SetClient replaces the global telemetry client (primarily used in tests).

func TestConnection

func TestConnection(cfg config.TelemetryConfig) (int, error)

TestConnection sends a synchronous test event to verify endpoint and credentials.

func Track

func Track(name string, properties map[string]any)

Track sends a custom named event asynchronously.

func TrackCommand

func TrackCommand(cmd *cobra.Command, args []string, duration time.Duration, execErr error)

TrackCommand sends a command execution event asynchronously.

Types

type Client

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

Client is a client for sending events to an OpenPanel instance.

func GetClient

func GetClient() *Client

GetClient returns the active global telemetry client.

func NewClient

func NewClient(cfg config.TelemetryConfig, verbose bool) *Client

NewClient initializes a new OpenPanel telemetry client.

func (*Client) Drain

func (c *Client) Drain(timeout time.Duration)

Drain flushes pending events and waits for the worker to finish up to the given timeout.

func (*Client) Send

func (c *Client) Send(payload Payload)

Send queues a payload for asynchronous dispatch.

func (*Client) SendSync

func (c *Client) SendSync(ctx context.Context, payload Payload) (int, error)

SendSync sends a payload synchronously, returning any HTTP response status or error.

type EventData

type EventData struct {
	Name       string         `json:"name,omitempty"`
	ProfileID  string         `json:"profileId,omitempty"`
	Properties map[string]any `json:"properties,omitempty"`
}

EventData holds the inner payload fields expected by OpenPanel track API.

type Payload

type Payload struct {
	Type    string    `json:"type"`
	Payload EventData `json:"payload"`
}

Payload represents an OpenPanel event or identify request.

Jump to

Keyboard shortcuts

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