telemetry

package
v0.1.34770 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Overwrite this function for tests
	CreateActiveTelemetry = newSegmentClient

	SegmentEndpoint = "http://localhost:33457"
)

Functions

func InvocationIDFromContext added in v0.1.34770

func InvocationIDFromContext(ctx context.Context) (string, bool)

InvocationIDFromContext retrieves the invocation ID set by the command middleware. Returns ("", false) if no ID is present.

func NewContext

func NewContext(ctx context.Context, client Client) context.Context

func SendTelemetryApproval

func SendTelemetryApproval(user User, approval Approval) error

Sends the user's approval event

func TrackWorkflowStep added in v0.1.34770

func TrackWorkflowStep(client Client, workflow, step, invocationID string, extra map[string]interface{})

TrackWorkflowStep emits a cli_workflow_step event for a named step within a multi-step command workflow. It lives in the telemetry package so that all subpackages (cmd/project, cmd/pipeline, cmd/trigger, etc.) can call it without creating import cycles back to the cmd package.

func UsedFlagValues added in v0.1.34770

func UsedFlagValues(cmd *cobra.Command) map[string]string

UsedFlagValues returns a map of flag names to values for flags explicitly set by the user. Sensitive flags (tokens, secrets) have their values redacted.

func WithInvocationID added in v0.1.34770

func WithInvocationID(ctx context.Context, invocationID string) context.Context

WithInvocationID stores the invocation ID in the context so that funnel step events in subpackages can correlate with the wrapper start/finish events.

Types

type Approval

type Approval string
const (
	Enabled  Approval = "enabled"
	Disabled Approval = "disabled"
	NoStdin  Approval = "disabled_default"
)

type Client

type Client interface {
	io.Closer
	// Send a telemetry event. This method is not to be called directly. Use config.Track instead
	Track(event Event) error
	Enabled() bool
}

func CreateClient

func CreateClient(user User, enabled bool) Client

Create a telemetry client to be used to send telemetry events

func CreateFileTelemetry

func CreateFileTelemetry(filePath string) Client

func CreateNullClient

func CreateNullClient() Client

func FromContext

func FromContext(ctx context.Context) (Client, bool)

type CommandInfo

type CommandInfo struct {
	Name      string
	LocalArgs map[string]string
}

func GetCommandInformation

func GetCommandInformation(cmd *cobra.Command, getParent bool) CommandInfo

GetCommandInformation takes a cobra Command and creates a telemetry.CommandInfo. Only flags explicitly set by the user are included (via pflag.Visit, not VisitAll). Values are sent for all flags except those in sensitiveFlags, which are redacted. If getParent is true, explicitly-set flags from the parent command are also included (child flags take precedence over parent flags with the same name).

type Event

type Event struct {
	Object     string                 `json:"object"`
	Action     string                 `json:"action"`
	Properties map[string]interface{} `json:"properties"`
}

A segment event to be sent to the telemetry Important: this is not meant to be constructed directly apart in tests If you want to create a new event, add its constructor in ./events.go

func CreateChangeTelemetryStatusEvent

func CreateChangeTelemetryStatusEvent(action string, origin string, err error) Event

func CreateCompletionCommand

func CreateCompletionCommand(cmdInfo CommandInfo) Event

func CreateConfigEvent

func CreateConfigEvent(cmdInfo CommandInfo, err error) Event

func CreateDiagnosticEvent

func CreateDiagnosticEvent(err error) Event

func CreateFollowEvent

func CreateFollowEvent(err error) Event

func CreateInfoEvent

func CreateInfoEvent(cmdInfo CommandInfo, err error) Event

func CreateLocalExecuteEvent

func CreateLocalExecuteEvent(cmdInfo CommandInfo) Event

func CreateNamespaceEvent

func CreateNamespaceEvent(cmdInfo CommandInfo) Event

func CreateOpenEvent

func CreateOpenEvent(err error) Event

func CreateOrbEvent

func CreateOrbEvent(cmdInfo CommandInfo) Event

func CreatePolicyEvent

func CreatePolicyEvent(cmdInfo CommandInfo) Event

func CreateRunnerInstanceEvent

func CreateRunnerInstanceEvent(cmdInfo CommandInfo, err error) Event

func CreateRunnerResourceClassEvent

func CreateRunnerResourceClassEvent(cmdInfo CommandInfo) Event

func CreateRunnerTokenEvent added in v0.1.29041

func CreateRunnerTokenEvent(cmdInfo CommandInfo) Event

func CreateSetupEvent

func CreateSetupEvent(isServerCustomer bool) Event

func CreateUpdateEvent

func CreateUpdateEvent(cmdInfo CommandInfo) Event

func CreateVersionEvent

func CreateVersionEvent(version string) Event

type User

type User struct {
	UniqueID     string
	UserID       string
	IsSelfHosted bool
	OS           string
	Version      string
	TeamName     string
}

Jump to

Keyboard shortcuts

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