Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 9 additions & 43 deletions ui/desktop/src/utils/analytics.ts
Original file line number Diff line number Diff line change
@@ -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.
}

// ============================================================================
Expand Down Expand Up @@ -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 });
}

Expand Down
Loading