suppress telemetry event on ui (#9991)

This commit is contained in:
Lifei Zhou
2026-06-25 10:50:27 +10:00
committed by GitHub
parent 416aad8136
commit db26fb79c9
+9 -43
View File
@@ -1,51 +1,19 @@
/**
* Frontend Analytics Module
*
* Provides privacy-respecting analytics by routing events through the backend.
* The backend uses posthog-rs which handles the PostHog API correctly.
*
* What we track:
* - Feature usage (which features users interact with)
* - Screen/view navigation
* - Onboarding funnel completion
* - Error types (without sensitive details)
*
* What we never track:
* - Conversation content
* - Code or file contents
* - API keys or credentials
* - Tool arguments or outputs
* - Personal identifiable information
* Compatibility layer for existing UI tracking call sites. Frontend telemetry is
* disabled during the ACP migration, so events are intentionally not sent.
*/
import { sendTelemetryEvent } from '../api';
let telemetryEnabled: boolean | null = null;
export function setTelemetryEnabled(enabled: boolean): void {
telemetryEnabled = enabled;
export function setTelemetryEnabled(_enabled: boolean): void {
// Frontend telemetry is disabled.
}
function canTrack(): boolean {
return telemetryEnabled === true;
}
async function sendEvent(
eventName: string,
properties: Record<string, unknown> = {}
): Promise<void> {
if (!canTrack()) return;
try {
await sendTelemetryEvent({
body: {
event_name: eventName,
properties: properties as Record<string, unknown>,
},
});
} catch (error) {
console.debug('[Analytics] Failed to send event:', error);
}
function sendEvent(
_eventName: string,
_properties: Record<string, unknown> = {}
): void {
// Frontend telemetry is disabled.
}
// ============================================================================
@@ -338,8 +306,6 @@ export function trackTelemetryPreference(
enabled: boolean,
location: 'settings' | 'onboarding' | 'modal'
): void {
// Always send this event, even if telemetry is disabled
// This is the one exception - we need to know opt-out rates
sendEvent('telemetry_preference_set', { enabled, location });
}