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)
| 130 | // set, never their values. Processes that resolve different state directories take different refresh lock files |
| 131 | // while possibly sharing one credential store, which defeats the lock. |
| 132 | func (c *AuthConfig) recordRefreshAttempt(hostname string, attempt refreshAttempt) { |
| 133 | if c.telemetry == nil || ghauth.IsEnterprise(hostname) { |
| 134 | return |
| 135 | } |
| 136 | |
| 137 | c.telemetry.SetSampleRate(ghtelemetry.SAMPLE_ALL) |
| 138 | c.telemetry.Record(ghtelemetry.Event{ |
| 139 | Type: refreshTelemetryEventType, |
| 140 | Dimensions: ghtelemetry.Dimensions{ |
| 141 | "refresh_command": c.refreshTelemetryCommand(), |
| 142 | "refresh_outcome": attempt.outcome, |
| 143 | "refresh_lock": attempt.lock, |
| 144 | "storage_type": attempt.storage, |
| 145 | "storage_error": attempt.storageError, |
| 146 | "gh_config_dir_set": envSet("GH_CONFIG_DIR"), |
| 147 | "xdg_config_home_set": envSet("XDG_CONFIG_HOME"), |
| 148 | "xdg_state_home_set": envSet("XDG_STATE_HOME"), |
| 149 | }, |
| 150 | Measures: ghtelemetry.Measures{ |
| 151 | "lock_wait_ms": attempt.lockWait.Milliseconds(), |
| 152 | "exchange_ms": attempt.exchange.Milliseconds(), |
| 153 | "recheck_ms": attempt.recheck.Milliseconds(), |
| 154 | }, |
| 155 | }) |
| 156 | } |
| 157 | |
| 158 | // refreshTelemetryCommand returns the command path set by SetTelemetryCommand, or "unknown" when a refresh happens |
| 159 | // before the command is resolved. |
no test coverage detected