mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-08 22:21:23 +00:00
refactor: remove debug and info console logs from telemetry package
- Removed all console.info and console.log statements that were used for debugging - Kept console.error statements for actual error reporting - Fixed ESLint warnings for unused error variables - Telemetry debug logs are now completely removed to prevent console spam
This commit is contained in:
parent
1f0890919a
commit
a897849ac3
3 changed files with 6 additions and 130 deletions
|
|
@ -21,10 +21,6 @@ export class PostHogTelemetryClient extends QueuedTelemetryClient {
|
|||
// Use workspace-specific storage to avoid conflicts between multiple VS Code windows
|
||||
const storagePath = context.storageUri?.fsPath || context.globalStorageUri?.fsPath || context.extensionPath
|
||||
|
||||
if (debug) {
|
||||
console.info(`[PostHogTelemetryClient] Initializing with storage path: ${storagePath}`)
|
||||
}
|
||||
|
||||
super(
|
||||
"posthog",
|
||||
storagePath,
|
||||
|
|
@ -44,9 +40,7 @@ export class PostHogTelemetryClient extends QueuedTelemetryClient {
|
|||
|
||||
// Disable PostHog's internal error logging to reduce noise
|
||||
this.client.on("error", (error) => {
|
||||
if (this.debug) {
|
||||
console.error("[PostHogTelemetryClient] PostHog internal error:", error)
|
||||
}
|
||||
console.error("[PostHogTelemetryClient] PostHog internal error:", error)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -67,10 +61,6 @@ export class PostHogTelemetryClient extends QueuedTelemetryClient {
|
|||
* Send event to PostHog (called by the base class)
|
||||
*/
|
||||
protected async sendEvent(event: TelemetryEvent): Promise<void> {
|
||||
if (this.debug) {
|
||||
console.info(`[PostHogTelemetryClient#sendEvent] ${event.event}`)
|
||||
}
|
||||
|
||||
const properties = await this.getEventProperties(event)
|
||||
|
||||
// PostHog queues events internally and flushes them in batches
|
||||
|
|
@ -85,15 +75,7 @@ export class PostHogTelemetryClient extends QueuedTelemetryClient {
|
|||
// Force immediate flush to detect network errors
|
||||
// This will throw if there's a network issue
|
||||
await this.client.flush()
|
||||
|
||||
if (this.debug) {
|
||||
console.info(`[PostHogTelemetryClient#sendEvent] Successfully flushed event: ${event.event}`)
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.debug) {
|
||||
console.error(`[PostHogTelemetryClient#sendEvent] Failed to send event: ${event.event}`, error)
|
||||
}
|
||||
|
||||
// Differentiate between different types of errors
|
||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||
|
||||
|
|
@ -104,11 +86,6 @@ export class PostHogTelemetryClient extends QueuedTelemetryClient {
|
|||
|
||||
if (isConfigError) {
|
||||
// Don't queue config errors - they won't succeed on retry
|
||||
if (this.debug) {
|
||||
console.error(
|
||||
`[PostHogTelemetryClient#sendEvent] Configuration error, not queuing: ${errorMessage}`,
|
||||
)
|
||||
}
|
||||
// Silently fail for config errors to not break the extension
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@ export abstract class QueuedTelemetryClient extends BaseTelemetryClient {
|
|||
this.queueManager = TelemetryQueueManager.getInstance(storagePath, debug)
|
||||
this.startRetryTimer()
|
||||
} catch (error) {
|
||||
if (debug) {
|
||||
console.error(`Failed to initialize queue manager: ${error}`)
|
||||
}
|
||||
console.error(`Failed to initialize queue manager: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -40,34 +38,20 @@ export abstract class QueuedTelemetryClient extends BaseTelemetryClient {
|
|||
*/
|
||||
public async capture(event: TelemetryEvent): Promise<void> {
|
||||
if (!this.isTelemetryEnabled() || !this.isEventCapturable(event.event)) {
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}#capture] Skipping event: ${event.event}`)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// Try to send the event
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}#capture] Attempting to send: ${event.event}`)
|
||||
}
|
||||
await this.sendEvent(event)
|
||||
|
||||
// If successful and we have queued events, try to process them
|
||||
if (this.queueManager && this.isOnline) {
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}#capture] Send successful, checking for queued events`)
|
||||
}
|
||||
this.processQueuedEvents()
|
||||
}
|
||||
} catch (error) {
|
||||
// Queue the event for retry
|
||||
if (this.queueManager) {
|
||||
if (this.debug) {
|
||||
console.info(
|
||||
`[${this.clientId}#capture] Send failed, queuing event: ${event.event}, error: ${error}`,
|
||||
)
|
||||
}
|
||||
this.queueManager.enqueue(event, this.clientId)
|
||||
this.isOnline = false
|
||||
}
|
||||
|
|
@ -98,19 +82,9 @@ export abstract class QueuedTelemetryClient extends BaseTelemetryClient {
|
|||
return
|
||||
}
|
||||
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}] Processing ${eventsToRetry.length} queued events`)
|
||||
}
|
||||
|
||||
await this.queueManager.processQueue(this.clientId, async (event) => {
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}] Retrying queued event: ${event.event}`)
|
||||
}
|
||||
await this.sendEvent(event)
|
||||
this.isOnline = true
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}] Successfully sent queued event, marking online`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -118,13 +92,7 @@ export abstract class QueuedTelemetryClient extends BaseTelemetryClient {
|
|||
* Start the retry timer
|
||||
*/
|
||||
private startRetryTimer(): void {
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}] Starting retry timer, checking every ${this.retryCheckInterval}ms`)
|
||||
}
|
||||
this.retryTimer = setInterval(() => {
|
||||
if (this.debug) {
|
||||
console.info(`[${this.clientId}] Retry timer triggered, checking for events to retry`)
|
||||
}
|
||||
this.processQueuedEvents()
|
||||
}, this.retryCheckInterval)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,9 +37,6 @@ export class TelemetryQueueManager {
|
|||
private constructor(storagePath: string, debug = false) {
|
||||
this.debug = debug || process.env.DEBUG_TELEMETRY === "true"
|
||||
this.persistPath = path.join(storagePath, "telemetry-queue.json")
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Initializing with path: ${this.persistPath}`)
|
||||
}
|
||||
this.loadQueue()
|
||||
this.startPeriodicFlush()
|
||||
this.startPeriodicCleanup()
|
||||
|
|
@ -69,19 +66,10 @@ export class TelemetryQueueManager {
|
|||
* Add an event to the queue
|
||||
*/
|
||||
public enqueue(event: TelemetryEvent, clientId: string): void {
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Enqueueing event: ${event.event} for client: ${clientId}`)
|
||||
}
|
||||
|
||||
// Don't queue if we've reached the maximum size
|
||||
if (this.queue.length >= this.maxQueueSize) {
|
||||
// Remove oldest events to make room (FIFO)
|
||||
const removed = this.queue.shift()
|
||||
if (this.debug) {
|
||||
console.log(
|
||||
`[TelemetryQueue] Queue full (${this.maxQueueSize}), removed oldest event: ${removed?.event.event}`,
|
||||
)
|
||||
}
|
||||
this.queue.shift()
|
||||
}
|
||||
|
||||
const queuedEvent: QueuedEvent = {
|
||||
|
|
@ -92,9 +80,6 @@ export class TelemetryQueueManager {
|
|||
}
|
||||
|
||||
this.queue.push(queuedEvent)
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Queue size after enqueue: ${this.queue.length}`)
|
||||
}
|
||||
this.schedulePersist()
|
||||
}
|
||||
|
||||
|
|
@ -111,32 +96,14 @@ export class TelemetryQueueManager {
|
|||
try {
|
||||
const clientEvents = this.queue.filter((e) => e.clientId === clientId)
|
||||
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Processing ${clientEvents.length} events for client: ${clientId}`)
|
||||
}
|
||||
|
||||
for (const queuedEvent of clientEvents) {
|
||||
try {
|
||||
if (this.debug) {
|
||||
console.log(
|
||||
`[TelemetryQueue] Attempting to send event: ${queuedEvent.event.event}, retry count: ${queuedEvent.retryCount}`,
|
||||
)
|
||||
}
|
||||
await sendFunction(queuedEvent.event)
|
||||
// Remove successfully sent event
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Successfully sent event: ${queuedEvent.event.event}`)
|
||||
}
|
||||
this.removeEvent(queuedEvent)
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
// Increment retry count
|
||||
queuedEvent.retryCount++
|
||||
if (this.debug) {
|
||||
console.log(
|
||||
`[TelemetryQueue] Failed to send event: ${queuedEvent.event.event}, retry count now: ${queuedEvent.retryCount}, error: ${error}`,
|
||||
)
|
||||
}
|
||||
|
||||
// Don't remove based on retry count - let it keep trying until 24 hours
|
||||
}
|
||||
}
|
||||
|
|
@ -198,22 +165,13 @@ export class TelemetryQueueManager {
|
|||
const originalCount = state.events.length
|
||||
this.queue = state.events.filter((e) => e.timestamp > cutoffTime)
|
||||
|
||||
if (this.debug) {
|
||||
console.log(
|
||||
`[TelemetryQueue] Loaded ${this.queue.length} events from disk (filtered ${originalCount - this.queue.length} old events)`,
|
||||
)
|
||||
}
|
||||
|
||||
// If we filtered out any events, persist the cleaned queue
|
||||
if (this.queue.length < originalCount) {
|
||||
this.schedulePersist()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
// File doesn't exist or is corrupted, start with empty queue
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] No existing queue file found or error loading: ${error}`)
|
||||
}
|
||||
this.queue = []
|
||||
}
|
||||
}
|
||||
|
|
@ -270,10 +228,6 @@ export class TelemetryQueueManager {
|
|||
version: this.QUEUE_VERSION,
|
||||
}
|
||||
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Persisting ${this.queue.length} events to disk`)
|
||||
}
|
||||
|
||||
// Ensure directory exists
|
||||
const dir = path.dirname(this.persistPath)
|
||||
await fs.mkdir(dir, { recursive: true })
|
||||
|
|
@ -282,15 +236,9 @@ export class TelemetryQueueManager {
|
|||
const tempPath = `${this.persistPath}.tmp`
|
||||
await fs.writeFile(tempPath, JSON.stringify(state, null, 2))
|
||||
await fs.rename(tempPath, this.persistPath)
|
||||
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Successfully persisted queue to: ${this.persistPath}`)
|
||||
}
|
||||
} catch (error) {
|
||||
// Log error but don't throw - telemetry should not break the app
|
||||
if (this.debug) {
|
||||
console.error("[TelemetryQueue] Failed to persist telemetry queue:", error)
|
||||
}
|
||||
console.error("[TelemetryQueue] Failed to persist telemetry queue:", error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -325,18 +273,10 @@ export class TelemetryQueueManager {
|
|||
*/
|
||||
private performAggressiveCleanup(): void {
|
||||
const originalSize = this.queue.length
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Running aggressive cleanup, current queue size: ${originalSize}`)
|
||||
}
|
||||
|
||||
// Remove old events
|
||||
const cutoffTime = Date.now() - this.MAX_EVENT_AGE
|
||||
const beforeOldFilter = this.queue.length
|
||||
this.queue = this.queue.filter((e) => e.timestamp > cutoffTime)
|
||||
const removedOld = beforeOldFilter - this.queue.length
|
||||
if (removedOld > 0 && this.debug) {
|
||||
console.log(`[TelemetryQueue] Removed ${removedOld} events older than 24 hours`)
|
||||
}
|
||||
|
||||
// No longer removing events based on retry count - they'll expire after 24 hours
|
||||
|
||||
|
|
@ -344,20 +284,11 @@ export class TelemetryQueueManager {
|
|||
if (this.queue.length > this.maxQueueSize) {
|
||||
// Sort by timestamp and keep only the newest events
|
||||
this.queue.sort((a, b) => b.timestamp - a.timestamp)
|
||||
const beforeTrim = this.queue.length
|
||||
this.queue = this.queue.slice(0, this.maxQueueSize)
|
||||
if (this.debug) {
|
||||
console.log(`[TelemetryQueue] Trimmed queue from ${beforeTrim} to ${this.maxQueueSize} events`)
|
||||
}
|
||||
}
|
||||
|
||||
// Persist if we made changes
|
||||
if (this.queue.length !== originalSize) {
|
||||
if (this.debug) {
|
||||
console.log(
|
||||
`[TelemetryQueue] Cleanup complete, queue size changed from ${originalSize} to ${this.queue.length}`,
|
||||
)
|
||||
}
|
||||
this.schedulePersist()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue