(event: string, distinctId: string, properties: TelemetryProperties)
| 171 | } |
| 172 | |
| 173 | async function postEvent(event: string, distinctId: string, properties: TelemetryProperties) { |
| 174 | const controller = new AbortController() |
| 175 | const timeout = setTimeout(() => { |
| 176 | controller.abort() |
| 177 | }, TELEMETRY_TIMEOUT_MS) |
| 178 | |
| 179 | try { |
| 180 | await fetch(TELEMETRY_TRANSPORT_ENDPOINT, { |
| 181 | method: 'POST', |
| 182 | headers: { |
| 183 | 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', |
| 184 | }, |
| 185 | body: createTelemetryRequestBody(event, distinctId, properties), |
| 186 | signal: controller.signal, |
| 187 | }) |
| 188 | } catch { |
| 189 | // Telemetry must never affect CLI behavior. |
| 190 | } finally { |
| 191 | clearTimeout(timeout) |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | export class TelemetryClient { |
| 196 | private commandProperties: TelemetryProperties = {} |
no test coverage detected