telemetry

package
v1.261201.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ClassifyAttemptedChild

func ClassifyAttemptedChild(token string) string

ClassifyAttemptedChild maps an unknown subcommand token to an allowlisted verb or "other". It never returns the raw token.

func EmitWithContext added in v1.260628.0

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

func ProcessOptedOut

func ProcessOptedOut() bool

ProcessOptedOut reports whether SetProcessOptOut turned telemetry off.

func ResetInstallID

func ResetInstallID() (string, error)

ResetInstallID replaces the install ID when the user opted in to it, and otherwise deletes any stored ID and returns "".

func RunMaintenanceWorkerIfRequested added in v1.260713.0

func RunMaintenanceWorkerIfRequested(args []string) bool

func SetEnabled

func SetEnabled(enabled bool) error

func SetInstallIDEnabled

func SetInstallIDEnabled(enabled bool) (string, error)

SetInstallIDEnabled records whether events may carry the install ID. Opting in creates the ID; opting out deletes it. It returns the ID after opt-in.

func SetProcessOptOut

func SetProcessOptOut(optOut bool)

SetProcessOptOut turns telemetry off for the rest of this process, as the root --no-telemetry flag does. It does not change stored state.

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"`
	DiagnosticCode   *string          `json:"diagnostic_code,omitempty"`
	OutcomeKind      OutcomeKind      `json:"outcome_kind,omitempty"`
	HTTPStatus       *int             `json:"http_status,omitempty"`
	// AttemptedChild is an allowlisted verb or "other", never the raw token.
	AttemptedChild *string `json:"attempted_child,omitempty"`
	// APIMethod, APIPathTemplate and APIQueryParams are set from schema v6 on,
	// for `asc api` only: the HTTP method, the request path reduced to an
	// embedded schema template or "other", and the schema names of the query
	// parameters sent. Never an identifier or a value.
	APIMethod       *string   `json:"api_method,omitempty"`
	APIPathTemplate *string   `json:"api_path_template,omitempty"`
	APIQueryParams  *[]string `json:"api_query_params,omitempty"`
	// UploadPhase and UploadSizeBucket are schema v7 fields asc does not
	// compute yet; schema v8 sends them as null.
	UploadPhase      *string `json:"upload_phase,omitempty"`
	UploadSizeBucket *string `json:"upload_size_bucket,omitempty"`
	// FirstRun is set from schema v8 on: true only on the first event of a
	// new local installation, so new installs can be counted without an ID.
	FirstRun *bool `json:"first_run,omitempty"`
	// FirstTodayOnVersion, FirstOnVersion and FirstTodayForOutcome are set from
	// schema v9 on, for local runtimes only: true on the first event of the UTC
	// day on this version, the first event ever on this version after an
	// upgrade, and the first event of the UTC day with this command path and
	// outcome. They let active installs be counted without an identifier.
	FirstTodayOnVersion  *bool `json:"first_today_on_version,omitempty"`
	FirstOnVersion       *bool `json:"first_on_version,omitempty"`
	FirstTodayForOutcome *bool `json:"first_today_for_outcome,omitempty"`
}

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 records of older schemas wire-compatible while ensuring each schema's nullable fields are present even when null.

type EventContext added in v1.260628.0

type EventContext struct {
	InvocationShape  InvocationShape
	ErrorKind        ErrorKind
	FailureStage     FailureStage
	FailureParameter string
	// DiagnosticCode is populated from structured CLI errors and is sanitized
	// against the shared low-cardinality taxonomy before it reaches the wire.
	DiagnosticCode   string
	OutcomeKind      OutcomeKind
	HTTPStatus       int
	PublicStorefront bool
	// AttemptedChild is the raw unknown subcommand token. BuildEventWithContext
	// classifies it; the wire value is never this raw token.
	AttemptedChild string
	// APIMethod, APIPath and APIQueryNames are what `asc api` parsed.
	// BuildEventWithContext reduces them to schema templates and names; they
	// are never sent as given. APIQueryNames is nil when not known.
	APIMethod     string
	APIPath       string
	APIQueryNames []string
}

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"`
	InstallIDOptIn bool   `json:"install_id_opt_in,omitempty"`
	Disabled       bool   `json:"disabled,omitempty"`
	NoticeShown    bool   `json:"notice_shown,omitempty"`
	UpdatedAt      string `json:"updated_at,omitempty"`
}

type Status

type Status struct {
	Path             string `json:"path"`
	Enabled          bool   `json:"enabled"`
	InstallIDEnabled bool   `json:"install_id_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