MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / capture

Method capture

packages/cloud/src/TelemetryClient.ts:157–194  ·  view source on GitHub ↗
(event: TelemetryEvent)

Source from the content-addressed store, hash-verified

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()) {

Callers

nothing calls this directly

Calls 5

isTelemetryEnabledMethod · 0.95
isEventCapturableMethod · 0.95
fetchMethod · 0.95
infoMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected