(options: TelemetryBootstrapOptions)
| 33 | } |
| 34 | |
| 35 | export function initializeTelemetry(options: TelemetryBootstrapOptions): void { |
| 36 | const client = getDefaultTelemetryClient(); |
| 37 | if (!shouldEnableTelemetry({ enabled: options.enabled })) { |
| 38 | client.disable(); |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | client.enable(); |
| 43 | client.setContext({ |
| 44 | deviceId: options.deviceId, |
| 45 | sessionId: options.sessionId, |
| 46 | }); |
| 47 | |
| 48 | const transport = new AsyncTransport({ |
| 49 | homeDir: options.homeDir, |
| 50 | deviceId: options.deviceId, |
| 51 | getAccessToken: options.getAccessToken, |
| 52 | }); |
| 53 | const sink = new EventSink({ |
| 54 | transport, |
| 55 | context: { |
| 56 | appName: options.appName, |
| 57 | version: options.version, |
| 58 | uiMode: options.uiMode, |
| 59 | model: options.model, |
| 60 | buildSha: options.buildSha, |
| 61 | terminal: options.terminal, |
| 62 | locale: options.locale, |
| 63 | }, |
| 64 | }); |
| 65 | |
| 66 | client.attachSink(sink); |
| 67 | sink.startPeriodicFlush(); |
| 68 | void sink.retryDiskEvents().catch(() => {}); |
| 69 | } |
no test coverage detected