(event: TelemetryEvent)
| 155 | } |
| 156 | |
| 157 | public override async capture(event: TelemetryEvent) { |
| 158 | if (!this.isTelemetryEnabled() || !this.isEventCapturable(event.event)) { |
| 159 | if (this.debug) { |
| 160 | console.info(`[TelemetryClient#capture] Skipping event: ${event.event}`) |
| 161 | } |
| 162 | |
| 163 | return |
| 164 | } |
| 165 | |
| 166 | const payload = { |
| 167 | type: event.event, |
| 168 | properties: await this.getEventProperties(event), |
| 169 | } |
| 170 | |
| 171 | if (this.debug) { |
| 172 | console.info(`[TelemetryClient#capture] ${JSON.stringify(payload)}`) |
| 173 | } |
| 174 | |
| 175 | const result = rooCodeTelemetryEventSchema.safeParse(payload) |
| 176 | |
| 177 | if (!result.success) { |
| 178 | console.error( |
| 179 | `[TelemetryClient#capture] Invalid telemetry event: ${result.error.message} - ${JSON.stringify(payload)}`, |
| 180 | ) |
| 181 | |
| 182 | return |
| 183 | } |
| 184 | |
| 185 | try { |
| 186 | await this.fetch(`events`, { |
| 187 | method: "POST", |
| 188 | body: JSON.stringify(result.data), |
| 189 | }) |
| 190 | } catch (error) { |
| 191 | console.error(`[TelemetryClient#capture] Error sending telemetry event: ${error}`) |
| 192 | // Error is already queued for retry in the fetch method |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | public async backfillMessages(messages: ClineMessage[], taskId: string): Promise<void> { |
| 197 | if (!this.isTelemetryEnabled()) { |
nothing calls this directly
no test coverage detected