MCPcopy Create free account
hub / github.com/cli/cli / recordRefreshAttempt

Method recordRefreshAttempt

internal/config/refreshable_telemetry.go:107–130  ·  view source on GitHub ↗

recordRefreshAttempt records the auth_token_refresh event for a refresh attempt against hostname. It records nothing when no recorder is set or when hostname is a GitHub Enterprise Server host, since enterprise usage is never reported. Refresh attempts are rare, at most a few per user per day, so th

(hostname string, attempt refreshAttempt)

Source from the content-addressed store, hash-verified

105// set, never their values. Processes that resolve different state directories take different refresh lock files
106// while possibly sharing one credential store, which defeats the lock.
107func (c *AuthConfig) recordRefreshAttempt(hostname string, attempt refreshAttempt) {
108 if c.telemetry == nil || ghauth.IsEnterprise(hostname) {
109 return
110 }
111
112 c.telemetry.SetSampleRate(ghtelemetry.SAMPLE_ALL)
113 c.telemetry.Record(ghtelemetry.Event{
114 Type: refreshTelemetryEventType,
115 Dimensions: ghtelemetry.Dimensions{
116 "refresh_command": c.refreshTelemetryCommand(),
117 "refresh_outcome": attempt.outcome,
118 "refresh_lock": attempt.lock,
119 "storage_type": attempt.storage,
120 "gh_config_dir_set": envSet("GH_CONFIG_DIR"),
121 "xdg_config_home_set": envSet("XDG_CONFIG_HOME"),
122 "xdg_state_home_set": envSet("XDG_STATE_HOME"),
123 },
124 Measures: ghtelemetry.Measures{
125 "lock_wait_ms": attempt.lockWait.Milliseconds(),
126 "exchange_ms": attempt.exchange.Milliseconds(),
127 "recheck_ms": attempt.recheck.Milliseconds(),
128 },
129 })
130}
131
132// refreshTelemetryCommand returns the command path set by SetTelemetryCommand, or "unknown" when a refresh happens
133// before the command is resolved.

Callers 1

Calls 4

envSetFunction · 0.85
SetSampleRateMethod · 0.65
RecordMethod · 0.65

Tested by

no test coverage detected