telemetry

package
v1.260716.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultEndpoint = "https://rork.com/cf-api/asc/v1/events"
)

Variables

This section is empty.

Functions

func Emit

func Emit(commandName, version string, duration time.Duration, exitCode int)

func EmitWithContext added in v1.260628.0

func EmitWithContext(
	commandName, version string,
	duration time.Duration,
	exitCode int,
	eventContext EventContext,
)

func EnsureInstallID

func EnsureInstallID() (string, error)

func RedactedSummary

func RedactedSummary(ev Event) map[string]string

func ResetInstallID

func ResetInstallID() (string, error)

func RunMaintenanceWorkerIfRequested added in v1.260713.0

func RunMaintenanceWorkerIfRequested(args []string) bool

func SetEnabled

func SetEnabled(enabled bool) error

func StatePath

func StatePath() (string, error)

Types

type ErrorKind added in v1.260628.0

type ErrorKind string
const (
	ErrorKindUnknownFlag     ErrorKind = "unknown_flag"
	ErrorKindMissingRequired ErrorKind = "missing_required"
	ErrorKindInvalidValue    ErrorKind = "invalid_value"
	ErrorKindBareGroup       ErrorKind = "bare_group"
	ErrorKindAPIConflict     ErrorKind = "api_conflict"
	ErrorKindAPI5xx          ErrorKind = "api_5xx"
	ErrorKindOther           ErrorKind = "other"
)

type Event

type Event struct {
	EventID          string           `json:"event_id"`
	SchemaVersion    uint8            `json:"schema_version"`
	ASCVersion       string           `json:"asc_version"`
	OS               string           `json:"os"`
	Arch             string           `json:"arch"`
	CommandPath      string           `json:"command_path"`
	CommandFamily    string           `json:"command_family"`
	DurationMS       uint32           `json:"duration_ms"`
	DurationBucket   string           `json:"duration_bucket"`
	ExitCode         int              `json:"exit_code"`
	Success          bool             `json:"success"`
	RuntimeContext   RuntimeContext   `json:"runtime_context"`
	InvocationSource InvocationSource `json:"invocation_source"`
	InstallID        *string          `json:"install_id"`
	SessionID        string           `json:"session_id"`
	InvocationShape  InvocationShape  `json:"invocation_shape"`
	ErrorKind        *ErrorKind       `json:"error_kind"`
	FailureStage     *FailureStage    `json:"failure_stage"`
	FailureParameter *string          `json:"failure_parameter"`
	OutcomeKind      OutcomeKind      `json:"outcome_kind,omitempty"`
	HTTPStatus       *int             `json:"http_status,omitempty"`
}

func BuildEvent

func BuildEvent(commandName, version string, duration time.Duration, exitCode int) (Event, bool)

func BuildEventWithContext added in v1.260628.0

func BuildEventWithContext(
	commandName, version string,
	duration time.Duration,
	exitCode int,
	eventContext EventContext,
) (Event, bool)

func (Event) MarshalJSON added in v1.260713.0

func (event Event) MarshalJSON() ([]byte, error)

MarshalJSON keeps queued schema-v3 records wire-compatible while ensuring nullable schema-v4 fields are present even when their value is null.

type EventContext added in v1.260628.0

type EventContext struct {
	InvocationShape  InvocationShape
	ErrorKind        ErrorKind
	FailureStage     FailureStage
	FailureParameter string
	OutcomeKind      OutcomeKind
	HTTPStatus       int
}

type FailureStage added in v1.260628.0

type FailureStage string
const (
	FailureStageParse      FailureStage = "parse"
	FailureStageValidation FailureStage = "validation"
	FailureStageRequest    FailureStage = "request"
	FailureStageExecution  FailureStage = "execution"
)

type InvocationShape added in v1.260628.0

type InvocationShape string
const (
	InvocationShapeLeaf           InvocationShape = "leaf"
	InvocationShapeBareGroup      InvocationShape = "bare_group"
	InvocationShapeGroupWithFlags InvocationShape = "group_with_flags"
	InvocationShapeUnknownChild   InvocationShape = "unknown_child"
)

type InvocationSource

type InvocationSource string
const (
	SourceTerminal     InvocationSource = "terminal"
	SourceClaudeCode   InvocationSource = "claude_code"
	SourceCursorAgent  InvocationSource = "cursor_agent"
	SourceCodexDesktop InvocationSource = "codex_desktop"
	SourceOpenCode     InvocationSource = "opencode"
	SourcePi           InvocationSource = "pi"
	SourceRorkAgent    InvocationSource = "rork_agent"
)

func DetectInvocationSource

func DetectInvocationSource() InvocationSource

type OutcomeKind added in v1.260713.0

type OutcomeKind string
const (
	OutcomeSuccess          OutcomeKind = "success"
	OutcomeExpectedNegative OutcomeKind = "expected_negative"
	OutcomeUsageError       OutcomeKind = "usage_error"
	OutcomeAuthError        OutcomeKind = "auth_error"
	OutcomeNotFound         OutcomeKind = "not_found"
	OutcomeConflict         OutcomeKind = "conflict"
	OutcomeAPIClientError   OutcomeKind = "api_client_error"
	OutcomeAPIServerError   OutcomeKind = "api_server_error"
	OutcomeTransportError   OutcomeKind = "transport_error"
	OutcomeCancelled        OutcomeKind = "cancelled"
	OutcomeInternalError    OutcomeKind = "internal_error"
)

type RuntimeContext

type RuntimeContext string
const (
	RuntimeLocal              RuntimeContext = "local"
	RuntimeEphemeral          RuntimeContext = "ephemeral"
	RuntimeRorkSandbox        RuntimeContext = "rork_sandbox"
	RuntimeRorkGitHubWorkflow RuntimeContext = "rork_github_workflow"
	RuntimeCI                 RuntimeContext = "ci"
)

func DetectRuntimeContext

func DetectRuntimeContext() RuntimeContext

type State

type State struct {
	InstallID string `json:"install_id,omitempty"`
	Disabled  bool   `json:"disabled,omitempty"`
	UpdatedAt string `json:"updated_at,omitempty"`
}

type Status

type Status struct {
	Path      string `json:"path"`
	Enabled   bool   `json:"enabled"`
	InstallID string `json:"install_id,omitempty"`
	Reason    string `json:"reason,omitempty"`
	Endpoint  string `json:"endpoint,omitempty"`
}

func ReadStatus

func ReadStatus() (Status, error)

Jump to

Keyboard shortcuts

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