Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
feat(telemetry): completely remove the telemetry solution from switchdash (#8)
Louis Amaudruz9998f47157bd
diff --git a/dash/AGENTS.md b/dash/AGENTS.mdindex 65c8329c1..3229c2247 100644--- a/dash/AGENTS.md+++ b/dash/AGENTS.md@@ -228,7 +228,7 @@ domain types live under `src/shared/`.Major main-process domains live under `src/main/core/`: agent hooks, agents, app,conversations, dependencies, execution context, fs, projects, prompt library, PTY,resource monitor, runtime, search, secrets, sessions, settings, switch agents,-telemetry, terminal shell, terminals, updates, view state, and workspaces. Stateful+terminal shell, terminals, updates, view state, and workspaces. Statefulmain-process concerns use singleton services; expected failures should use the`Result<T, E>` pattern from `src/main/lib/result.ts`.@@ -270,10 +270,9 @@ pnpm run lintor generated dependency folders.- Application secrets are stored through encrypted app secret services and Electronsafe storage.-- Telemetry must remain optional; users can disable it with `TELEMETRY_ENABLED=false`- or in the app settings.+- The app ships no telemetry or analytics; do not add tracking or phone-home behavior.- File logging redacts common secret patterns; preserve this behavior when touching- logging, telemetry, or error-reporting code.+ logging or error-reporting code.- PTY environment passthrough must use the allowlist in `src/main/core/pty/pty-env.ts`.- Treat shell escaping and PTY spawning as security-sensitive.- Do not bypass path-safety, shell escaping, or validation helpers.@@ -336,7 +335,7 @@ pnpm run test- Project settings such as `tmux` and `workspaceProvider` are DB-backed, not`.switchdash.json`.- Optional environment variables:- `TELEMETRY_ENABLED`, `SWITCHDASH_DB_FILE`, `SWITCHDASH_DISABLE_NATIVE_DB`,+ `SWITCHDASH_DB_FILE`, `SWITCHDASH_DISABLE_NATIVE_DB`,`SWITCHDASH_DISABLE_PTY`, `SWITCHDASH_REGISTER_DEEPLINK`, `CODEX_SANDBOX_MODE`,and `CODEX_APPROVAL_POLICY`.- Deeplinks in dev: `pnpm run dev` does **not** claim the `switchdash://` OS URL@@ -346,9 +345,6 @@ pnpm run testinstalled app. To test deeplinks against the dev build, run with`SWITCHDASH_REGISTER_DEEPLINK=1 pnpm run dev`; afterwards run`pnpm run deeplink:reset` (macOS) to hand the scheme back to the installed app.-- Build-time telemetry configuration may use `VITE_POSTHOG_KEY` and- `VITE_POSTHOG_HOST`.-- Runtime feature flags are read through telemetry-backed feature flag helpers.- Path aliases are defined in `tsconfig.json` and mirrored in `electron.vite.config.ts`:`@/*`, `@renderer/*`, `@main/*`, `@shared/*`, and `@root/*`.- Versioned JSON column schemas are defined in `src/shared/` usingdiff --git a/dash/agents/architecture/main-process.md b/dash/agents/architecture/main-process.mdindex d99626752..4c3e32769 100644--- a/dash/agents/architecture/main-process.md+++ b/dash/agents/architecture/main-process.md@@ -24,7 +24,6 @@ The main process is organized into domain modules under `src/main/core/`. Each d- **settings** — App settings service and schema, provider settings (separate controller)- **shared** — Shared main-process utilities- **switch-agents** — Switch agent integration-- **telemetry** — Telemetry service- **terminal-shell** — Terminal shell availability and detection- **terminals** — Terminal lifecycle with provider pattern (`impl/local-terminal-provider.ts`), lifecycle scripts- **updates** — Auto-update service@@ -35,7 +34,7 @@ The main process is organized into domain modules under `src/main/core/`. Each d## Other Main Process Areas- `src/main/app/` — Menu, protocol handler, window creation-- `src/main/lib/` — Logger, telemetry, events, result type, updater error+- `src/main/lib/` — Logger, events, result type, updater error- `src/main/db/` — Database schema and initialization- `src/main/utils/` — Shell environment, shell escaping, child process env, external links- `src/main/core/agent-hooks/` — Hook server, event enrichment, OS notifications, hook/plugin config writerdiff --git a/dash/agents/risky-areas/updater.md b/dash/agents/risky-areas/updater.mdindex 6b8e85134..43ad791f3 100644--- a/dash/agents/risky-areas/updater.md+++ b/dash/agents/risky-areas/updater.md@@ -47,7 +47,7 @@ The `UPDATE_CHANNEL` / `v1-stable` / `v1-canary` naming applies **only** to the### R2 decommission path-R2 uploads continue until telemetry confirms all clients have migrated to the GitHub-backed feed. At that point:+R2 uploads continue until all clients are confirmed to have migrated to the GitHub-backed feed. At that point:1. Remove the `provider: generic` block from `electron-builder.config.ts` and `electron-builder.canary.config.ts`.2. Remove the `upload-r2.ts` call and `duplicateChannelManifests` call from `build.ts`.diff --git a/dash/apps/switchdash-desktop/src/main/app/menu.ts b/dash/apps/switchdash-desktop/src/main/app/menu.tsindex 00e525c82..ff878761a 100644--- a/dash/apps/switchdash-desktop/src/main/app/menu.ts+++ b/dash/apps/switchdash-desktop/src/main/app/menu.ts@@ -1,6 +1,5 @@import { app, clipboard, Menu, shell } from 'electron';import { events } from '@main/lib/events';-import { telemetryService } from '@main/lib/telemetry';import {menuCheckForUpdatesChannel,menuCloseTabChannel,@@ -17,11 +16,9 @@ import {} from '@shared/urls';import { getMainWindow } from './window';-function copyInstallationId(): void {- const instanceId = telemetryService.getInstanceId() ?? 'unavailable';+function copyVersionInfo(): void {const lines = [`Switchdash ${app.getVersion()}`,- `Installation ID: ${instanceId}`,`Platform: ${process.platform} ${process.arch}`,`Electron: ${process.versions.electron}`,];@@ -186,8 +183,8 @@ export function setupApplicationMenu(): void {},},{- label: 'Copy Installation ID',- click: copyInstallationId,+ label: 'Copy Version Info',+ click: copyVersionInfo,},],},diff --git a/dash/apps/switchdash-desktop/src/main/app/window.ts b/dash/apps/switchdash-desktop/src/main/app/window.tsindex 1a5e428d5..f5f7d3008 100644--- a/dash/apps/switchdash-desktop/src/main/app/window.ts+++ b/dash/apps/switchdash-desktop/src/main/app/window.ts@@ -1,7 +1,6 @@import { join } from 'node:path';import { BrowserWindow } from 'electron';import appIcon from '@/assets/images/switchdash/switchdash_logo.png?asset';-import { telemetryService } from '@main/lib/telemetry';import { registerExternalLinkHandlers } from '@main/utils/externalLinks';import { PRODUCT_NAME } from '@shared/app-identity';import { APP_ORIGIN } from './protocol';@@ -49,17 +48,10 @@ export function createMainWindow(): BrowserWindow {mainWindow?.show();});- // Track window focus for telemetrymainWindow.on('focus', () => {- telemetryService.capture('app_window_focused');if (typeof mainWindow?.setWindowButtonVisibility === 'function') {mainWindow.setWindowButtonVisibility(true);}- void telemetryService.checkAndReportDailyActiveUser();- });-- mainWindow.on('blur', () => {- telemetryService.capture('app_window_unfocused');});// Cleanup reference on closediff --git a/dash/apps/switchdash-desktop/src/main/core/agent-hooks/agent-hook-service.ts b/dash/apps/switchdash-desktop/src/main/core/agent-hooks/agent-hook-service.tsindex 787bfe239..28693f78a 100644--- a/dash/apps/switchdash-desktop/src/main/core/agent-hooks/agent-hook-service.ts+++ b/dash/apps/switchdash-desktop/src/main/core/agent-hooks/agent-hook-service.ts@@ -13,7 +13,6 @@ import { sessions } from '@main/db/schema';import { events } from '@main/lib/events';import { HookCore, type Hookable } from '@main/lib/hookable';import { log } from '@main/lib/logger';-import { telemetryService } from '@main/lib/telemetry';import {conversationAgentStatusChangedChannel,conversationChangedChannel,@@ -158,13 +157,6 @@ class AgentHookService implements IInitializable, IDisposable, Hookable<AgentHoothis.emitAgentEvent(agentEvent, isAppFocused());}- telemetryService.capture('agent_run_started', {- provider: providerId,- project_id: projectId,- session_id: sessionId,- conversation_id: conversationId,- });-const now = new Date().toISOString();void touchConversation(conversationId, now).then(() => {events.emit(conversationChangedChannel, {diff --git a/dash/apps/switchdash-desktop/src/main/core/app/controller.ts b/dash/apps/switchdash-desktop/src/main/core/app/controller.tsindex 83067a4eb..14e119606 100644--- a/dash/apps/switchdash-desktop/src/main/core/app/controller.ts+++ b/dash/apps/switchdash-desktop/src/main/core/app/controller.ts@@ -1,5 +1,4 @@import { getDiagnosticLogAttachment } from '@main/lib/file-logger';-import { telemetryService } from '@main/lib/telemetry';import { createRPCController } from '@shared/lib/ipc/rpc';import type { OpenInAppId } from '@shared/openInApps';import { appService } from './service';@@ -8,7 +7,6 @@ export const appController = createRPCController({openExternal: async (url: string) => {try {await appService.openExternal(url);- telemetryService.capture('open_in_external', { app: 'browser' });return { success: true };} catch (error) {return { success: false, error: error instanceof Error ? error.message : String(error) };@@ -57,7 +55,6 @@ export const appController = createRPCController({}) => {try {await appService.openIn(args);- telemetryService.capture('open_in_external', { app: args.app });return { success: true };} catch (error) {return { success: false, error: error instanceof Error ? error.message : String(error) };diff --git a/dash/apps/switchdash-desktop/src/main/core/conversations/createConversation.ts b/dash/apps/switchdash-desktop/src/main/core/conversations/createConversation.tsindex fcc902d94..3e43fc5bc 100644--- a/dash/apps/switchdash-desktop/src/main/core/conversations/createConversation.ts+++ b/dash/apps/switchdash-desktop/src/main/core/conversations/createConversation.ts@@ -5,7 +5,6 @@ import { db } from '@main/db/client';import { agents, sessions } from '@main/db/schema';import { events } from '@main/lib/events';import { log } from '@main/lib/logger';-import { telemetryService } from '@main/lib/telemetry';import { conversationCreatedChannel } from '@shared/core/conversations/conversationEvents';import {type Conversation,@@ -114,13 +113,6 @@ export async function createConversation(conversationEvents._emit('conversation:created', conversation);events.emit(conversationCreatedChannel, { conversation });emitInitialPromptStarted(conversation, params);- telemetryService.capture('conversation_created', {- provider: params.provider,- is_first_in_session: true,- project_id: params.projectId,- session_id: params.sessionId,- conversation_id: id,- });return conversation;}diff --git a/dash/apps/switchdash-desktop/src/main/core/conversations/deleteConversation.ts b/dash/apps/switchdash-desktop/src/main/core/conversations/deleteConversation.tsindex 0a0b561f3..088202776 100644--- a/dash/apps/switchdash-desktop/src/main/core/conversations/deleteConversation.ts+++ b/dash/apps/switchdash-desktop/src/main/core/conversations/deleteConversation.ts@@ -4,7 +4,6 @@ import { projectManager } from '@main/core/projects/project-manager';import { killTmuxSession, makeAgentTmuxSessionName } from '@main/core/pty/tmux-session-name';import { db } from '@main/db/client';import { sessions } from '@main/db/schema';-import { telemetryService } from '@main/lib/telemetry';import { resolveSession } from '../projects/utils';import { conversationEvents } from './conversation-events';@@ -30,9 +29,4 @@ export async function deleteConversation(await killTmuxSession(project.ctx, makeAgentTmuxSessionName(conversationId));}}- telemetryService.capture('conversation_deleted', {- project_id: projectId,- session_id: sessionId,- conversation_id: conversationId,- });}diff --git a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/conversation-provider-respawn.test.ts b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/conversation-provider-respawn.test.tsindex 1256b36b0..6501deeb0 100644--- a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/conversation-provider-respawn.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/conversation-provider-respawn.test.ts@@ -110,12 +110,6 @@ vi.mock('@main/lib/events', () => ({},}));-vi.mock('@main/lib/telemetry', () => ({- telemetryService: {- capture: vi.fn(),- },-}));-vi.mock('@main/core/settings/provider-settings-service', () => ({providerOverrideSettings: {getItem: vi.fn(async () => undefined),diff --git a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/local-conversation.ts b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/local-conversation.tsindex e302e8db2..9b8ab3a2a 100644--- a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/local-conversation.ts+++ b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/local-conversation.ts@@ -24,7 +24,6 @@ import { switchRoomService } from '@main/core/switch-rooms/switch-room-service';import type { ResolvedShellProfile } from '@main/core/terminal-shell/types';import { events } from '@main/lib/events';import { log } from '@main/lib/logger';-import { telemetryService } from '@main/lib/telemetry';import type { Conversation } from '@shared/core/conversations/conversations';import { agentSessionExitedChannel } from '@shared/core/providers/agentEvents';import { makePtyId } from '@shared/core/pty/ptyId';@@ -289,12 +288,6 @@ export class LocalConversationProvider implements ConversationProvider {error: String(error),});});- telemetryService.capture('agent_run_started', {- provider: conversation.providerId,- project_id: conversation.projectId,- session_id: conversation.sessionId,- conversation_id: conversation.id,- });} catch (error) {this.supervisor.failSpawn(sessionId, spawnToken);throw error;diff --git a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.test.ts b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.test.tsindex 1fe07e2c0..e7274407c 100644--- a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.test.ts@@ -75,10 +75,6 @@ vi.mock('@main/lib/events', () => ({events: { emit: vi.fn(), on: vi.fn(() => () => {}) },}));-vi.mock('@main/lib/telemetry', () => ({- telemetryService: { capture: vi.fn() },-}));-vi.mock('@main/core/settings/provider-settings-service', () => ({providerOverrideSettings: { getItem: vi.fn(async () => undefined) },}));diff --git a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.ts b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.tsindex fe0544742..b6e3e28a7 100644--- a/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.ts+++ b/dash/apps/switchdash-desktop/src/main/core/conversations/impl/ssh-conversation.ts@@ -21,7 +21,6 @@ import type { SshClientProxy } from '@main/core/ssh/lifecycle/ssh-client-proxy';import type { SshConnectionManagerEvent } from '@main/core/ssh/lifecycle/ssh-connection-manager';import { events } from '@main/lib/events';import { log } from '@main/lib/logger';-import { telemetryService } from '@main/lib/telemetry';import type { Conversation } from '@shared/core/conversations/conversations';import type { AgentSessionConfig } from '@shared/core/providers/agent-session';import { agentSessionExitedChannel } from '@shared/core/providers/agentEvents';@@ -503,12 +502,6 @@ export class SshConversationProvider implements ConversationProvider {initialPrompt,isResuming: agentSession.isResuming,});- telemetryService.capture('agent_run_started', {- provider: conversation.providerId,- project_id: conversation.projectId,- session_id: conversation.sessionId,- conversation_id: conversation.id,- });} catch (error) {this.supervisor.failSpawn(sessionId, spawnToken);throw error;diff --git a/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.test.ts b/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.test.tsindex 4c846514c..32ef370bd 100644--- a/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.test.ts@@ -3,7 +3,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import { deleteProject } from './deleteProject';const mocks = vi.hoisted(() => ({- captureTelemetry: vi.fn(),closeProject: vi.fn(),deleteProjectRow: vi.fn(),deleteWhere: vi.fn(),@@ -47,12 +46,6 @@ vi.mock('@main/core/view-state/view-state-service', () => ({},}));-vi.mock('@main/lib/telemetry', () => ({- telemetryService: {- capture: mocks.captureTelemetry,- },-}));-describe('deleteProject', () => {beforeEach(() => {vi.clearAllMocks();diff --git a/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.ts b/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.tsindex eecdc2891..6390b8767 100644--- a/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.ts+++ b/dash/apps/switchdash-desktop/src/main/core/projects/operations/deleteProject.ts@@ -6,7 +6,6 @@ import { sessionRuntimeManager } from '@main/core/sessions/session-runtime-managimport { viewStateService } from '@main/core/view-state/view-state-service';import { db } from '@main/db/client';import { projects } from '@main/db/schema';-import { telemetryService } from '@main/lib/telemetry';export async function deleteProject(id: string): Promise<void> {const provider = projectManager.getProject(id);@@ -22,5 +21,4 @@ export async function deleteProject(id: string): Promise<void> {await db.delete(projects).where(eq(projects.id, id));void viewStateService.del(`project:${id}`);projectEvents._emit('project:deleted', id);- telemetryService.capture('project_deleted', { project_id: id });}diff --git a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.test.ts b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.test.tsindex 65f0b8182..34c0bc532 100644--- a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.test.ts@@ -2,7 +2,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import { archiveSession } from './archiveSession';const mocks = vi.hoisted(() => ({- capture: vi.fn(),selectLimit: vi.fn(),teardownSession: vi.fn(),updateSet: vi.fn(),@@ -30,12 +29,6 @@ vi.mock('@main/core/sessions/session-runtime-manager', () => ({},}));-vi.mock('@main/lib/telemetry', () => ({- telemetryService: {- capture: mocks.capture,- },-}));-describe('archiveSession', () => {beforeEach(() => {vi.clearAllMocks();@@ -66,10 +59,6 @@ describe('archiveSession', () => {expect(updatePayload).not.toHaveProperty('statusChangedAt');expect(mocks.teardownSession).toHaveBeenCalledWith('session-1', 'detach');- expect(mocks.capture).toHaveBeenCalledWith('session_archived', {- project_id: 'project-1',- session_id: 'session-1',- });expect(mocks.selectLimit).toHaveBeenCalledTimes(1);});});diff --git a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.ts b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.tsindex 9fae985d4..7220b650a 100644--- a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.ts+++ b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/archiveSession.ts@@ -3,7 +3,6 @@ import { sessionRuntimeManager } from '@main/core/sessions/session-runtime-managimport { db } from '@main/db/client';import { sessions } from '@main/db/schema';import { log } from '@main/lib/logger';-import { telemetryService } from '@main/lib/telemetry';export async function archiveSession(projectId: string, sessionId: string): Promise<void> {const [session] = await db.select().from(sessions).where(eq(sessions.id, sessionId)).limit(1);@@ -16,7 +15,6 @@ export async function archiveSession(projectId: string, sessionId: string): PromupdatedAt: sql`CURRENT_TIMESTAMP`,}).where(eq(sessions.id, sessionId));- telemetryService.capture('session_archived', { project_id: projectId, session_id: sessionId });const teardownResult = await sessionRuntimeManager.teardownSession(sessionId, 'detach')diff --git a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.test.ts b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.test.tsindex 51f700ce7..676dda824 100644--- a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.test.ts+++ b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.test.ts@@ -2,7 +2,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import { deleteSession } from './deleteSession';const mocks = vi.hoisted(() => ({- capture: vi.fn(),deleteWhere: vi.fn(),getProject: vi.fn(),selectLimit: vi.fn(),@@ -43,12 +42,6 @@ vi.mock('@main/core/view-state/view-state-service', () => ({},}));-vi.mock('@main/lib/telemetry', () => ({- telemetryService: {- capture: mocks.capture,- },-}));-describe('deleteSession', () => {beforeEach(() => {vi.clearAllMocks();@@ -67,9 +60,5 @@ describe('deleteSession', () => {mocks.selectLimit.mockResolvedValueOnce([{ id: 'session-1', agentId: 'agent-1' }]);await deleteSession('project-1', 'session-1');expect(mocks.deleteWhere).toHaveBeenCalledTimes(1);- expect(mocks.capture).toHaveBeenCalledWith(- 'session_deleted',- expect.objectContaining({ session_id: 'session-1' })- );});});diff --git a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.ts b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.tsindex 561f0b4d4..823ba5877 100644--- a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.ts+++ b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/deleteSession.ts@@ -5,7 +5,6 @@ import { viewStateService } from '@main/core/view-state/view-state-service';import { db } from '@main/db/client';import { sessions } from '@main/db/schema';import { log } from '@main/lib/logger';-import { telemetryService } from '@main/lib/telemetry';export async function deleteSession(projectId: string, sessionId: string): Promise<void> {const [session] = await db.select().from(sessions).where(eq(sessions.id, sessionId)).limit(1);@@ -31,5 +30,4 @@ export async function deleteSession(projectId: string, sessionId: string): Promiawait db.delete(sessions).where(eq(sessions.id, sessionId));void viewStateService.del(`session:${sessionId}`);- telemetryService.capture('session_deleted', { project_id: projectId, session_id: sessionId });}diff --git a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/updateSessionStatus.ts b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/updateSessionStatus.tsindex db65bb98d..45c6fced9 100644--- a/dash/apps/switchdash-desktop/src/main/core/sessions/operations/updateSessionStatus.ts+++ b/dash/apps/switchdash-desktop/src/main/core/sessions/operations/updateSessionStatus.ts@@ -1,7 +1,6 @@import { eq, sql } from 'drizzle-orm';import { db } from '@main/db/client';import { sessions } from '@main/db/schema';-import { telemetryService } from '@main/lib/telemetry';import { type SessionLifecycleStatus } from '@shared/core/sessions/sessions';export async function updateSessionStatus(@@ -20,9 +19,4 @@ export async function updateSessionStatus(statusChangedAt: sql`CURRENT_TIMESTAMP`,}).where(eq(sessions.id, sessionId));-- telemetryService.capture('session_status_changed', {- from_status: row.status as SessionLifecycleStatus,- to_status: status,- });}diff --git a/dash/apps/switchdash-desktop/src/main/core/sessions/session-runtime-manager.ts b/dash/apps/switchdash-desktop/src/main/core/sessions/session-runtime-manager.tsindex c53aaf64d..97aacd35a 100644--- a/dash/apps/switchdash-desktop/src/main/core/sessions/session-runtime-manager.ts+++ b/dash/apps/switchdash-desktop/src/main/core/sessions/session-runtime-manager.ts@@ -106,7 +106,7 @@ class SessionRuntimeManager {/*** Registers a fully-provisioned session into the lifecycle map.* Idempotent — if the session is already registered, returns immediately.- * Fires `session:provisioned` hook for telemetry, git watchers, PR sync.+ * Fires `session:provisioned` hook for git watchers and PR sync.*/async registerSession(sessionId: string,diff --git a/dash/apps/switchdash-desktop/src/main/core/telemetry/controller.ts b/dash/apps/switchdash-desktop/src/main/core/telemetry/controller.tsdeleted file mode 100644index 64df8b8a5..000000000--- a/dash/apps/switchdash-desktop/src/main/core/telemetry/controller.ts+++ /dev/null@@ -1,16 +0,0 @@-import { telemetryService } from '@main/lib/telemetry';-import { createRPCController } from '@shared/lib/ipc/rpc';-import type { TelemetryEvent } from '@shared/telemetry';--export const telemetryController = createRPCController({- capture: (args: { event: TelemetryEvent; properties?: Record<string, unknown> }) => {- telemetryService.capture(args.event, args.properties);- },- getStatus: () => {- return { status: telemetryService.getTelemetryStatus() };- },- setEnabled: (enabled: boolean) => {- telemetryService.setTelemetryEnabledViaUser(enabled);- },- getFeatureFlags: () => telemetryService.getFeatureFlags(),-});diff --git a/dash/apps/switchdash-desktop/src/main/core/telemetry/session-telemetry.ts b/dash/apps/switchdash-desktop/src/main/core/telemetry/session-telemetry.tsdeleted file mode 100644index c31322262..000000000--- a/dash/apps/switchdash-desktop/src/main/core/telemetry/session-telemetry.ts+++ /dev/null@@ -1,16 +0,0 @@-import { telemetryService } from '@main/lib/telemetry';-import { sessionRuntimeManager } from '../sessions/session-runtime-manager';-import { sessionService } from '../sessions/session-service';--sessionService.on('session:created', (session, params) => {- telemetryService.capture('session_created', {- strategy: 'blank',- has_initial_prompt: Boolean(params.initialPrompt?.trim()),- has_issue: 'none',- provider: session.providerId,- });-});--sessionRuntimeManager.hooks.on('session:provisioned', ({ projectId, sessionId }) => {- telemetryService.capture('session_provisioned', { project_id: projectId, session_id: sessionId });-});diff --git a/dash/apps/switchdash-desktop/src/main/index.ts b/dash/apps/switchdash-desktop/src/main/index.tsindex 800202cbe..663085882 100644--- a/dash/apps/switchdash-desktop/src/main/index.ts+++ b/dash/apps/switchdash-desktop/src/main/index.ts@@ -36,7 +36,6 @@ import {registerRendererLogHandler,} from './lib/file-logger';import { log } from './lib/logger';-import { telemetryService } from './lib/telemetry';import { rpcRouter } from './rpc';import { resolveUserEnv } from './utils/userEnv';@@ -108,12 +107,6 @@ void app.whenReady().then(async () => {return;}- try {- await telemetryService.initialize({ installSource: app.isPackaged ? 'dmg' : 'dev' });- } catch (e) {- log.warn('telemetry init failed:', e);- }-projectSettingsService.initialize();appService.initialize();await appSettingsService.initialize();@@ -196,14 +189,11 @@ void app.whenReady().then(async () => {app.on('before-quit', (event) => {event.preventDefault();- telemetryService.capture('app_closed');- void telemetryService.dispose().finally(() => {- agentHookService.dispose();- stopResourceSampler();- updateService.dispose();- void projectManager.dispose().catch((e) => {- log.error('Failed to shutdown project manager:', e);- });- app.exit(0);+ agentHookService.dispose();+ stopResourceSampler();+ updateService.dispose();+ void projectManager.dispose().catch((e) => {+ log.error('Failed to shutdown project manager:', e);});+ app.exit(0);});diff --git a/dash/apps/switchdash-desktop/src/main/lib/env.ts b/dash/apps/switchdash-desktop/src/main/lib/env.tsdeleted file mode 100644index f20ed7895..000000000--- a/dash/apps/switchdash-desktop/src/main/lib/env.ts+++ /dev/null@@ -1,41 +0,0 @@-import { z } from 'zod';-import { log } from './logger';--const buildSchema = z.object({- VITE_POSTHOG_KEY: z.string().optional(),- VITE_POSTHOG_HOST: z.string().optional(),- VITE_BUILD: z.enum(['canary', 'prod']).default('prod'),-});--// Dev-only overrides: read from process.env (supports non-VITE_ prefixed vars,-// loaded from .env.local via electron-vite's envDir but never shipped in prod)-const devSchema = z.object({- POSTHOG_PROJECT_API_KEY: z.string().optional(),- POSTHOG_HOST: z.string().optional(),-});--const runtimeSchema = z.object({- TELEMETRY_ENABLED: z.string().optional(),- INSTALL_SOURCE: z.string().optional(),-});--function parseSection<T extends z.ZodRawShape>(- schema: z.ZodObject<T>,- source: Record<string, unknown>,- label: string-): z.infer<z.ZodObject<T>> {- const result = schema.safeParse(source);- if (!result.success) {- log.error(`[env:${label}] Failed to parse environment variables`, { error: result.error });- return {} as z.infer<z.ZodObject<T>>;- }- return result.data;-}--export const env = {- build: parseSection(buildSchema, import.meta.env as unknown as Record<string, unknown>, 'build'),- dev: import.meta.env.DEV- ? parseSection(devSchema, process.env, 'dev')- : ({} as z.infer<typeof devSchema>),- runtime: parseSection(runtimeSchema, process.env, 'runtime'),-};diff --git a/dash/apps/switchdash-desktop/src/main/lib/telemetry.ts b/dash/apps/switchdash-desktop/src/main/lib/telemetry.tsdeleted file mode 100644index d2c7ae685..000000000--- a/dash/apps/switchdash-desktop/src/main/lib/telemetry.ts+++ /dev/null@@ -1,486 +0,0 @@-import { randomUUID } from 'node:crypto';-import type { IDisposable, IInitializable } from '@switchdash/shared';-import { app } from 'electron';-import { KV } from '@main/db/kv';-import { env as appEnv } from '@main/lib/env';-import type { TelemetryEnvelope, TelemetryEvent, TelemetryProperties } from '@shared/telemetry';--interface InitOptions {- installSource?: string;-}--type TelemetryKVSchema = {- instanceId: string;- enabled: string;- lastActiveDate: string;- lastSessionId: string;- lastHeartbeatTs: string;-};--const LIB_NAME = 'switchdash';-const isViteDevBuild = import.meta.env.DEV;--class TelemetryService implements IInitializable, IDisposable {- private enabled = true;- private apiKey: string | undefined;- private host: string | undefined;- private instanceId: string | undefined;- private installSource: string | undefined;- private userOptOut: boolean | undefined;- private sessionId: string | undefined;- private lastActiveDate: string | undefined;- private cachedGithubUsername: string | null = null;- private cachedAccountId: string | null = null;- private cachedEmail: string | null = null;- private cachedFeatureFlags: Record<string, boolean> = {};- private heartbeatInterval: ReturnType<typeof setInterval> | undefined;- private readonly kv = new KV<TelemetryKVSchema>('telemetry');-- // ---------------------------------------------------------------------------- // Internal helpers- // ----------------------------------------------------------------------------- private isEnabled(): boolean {- return (- !isViteDevBuild &&- this.enabled === true &&- this.userOptOut !== true &&- !!this.apiKey &&- !!this.host &&- typeof this.instanceId === 'string' &&- this.instanceId.length > 0- );- }-- private getVersionSafe(): string {- try {- return app.getVersion();- } catch {- return 'unknown';- }- }-- private getBaseProps() {- return {- schema_version: 1,- app_version: this.getVersionSafe(),- build_variant: appEnv.build.VITE_BUILD,- source: 'desktop_app',- electron_version: process.versions.electron,- platform: process.platform,- arch: process.arch,- is_dev: !app.isPackaged,- install_source: this.installSource ?? (app.isPackaged ? 'dmg' : 'dev'),- $lib: LIB_NAME,- ...(this.cachedGithubUsername ? { github_username: this.cachedGithubUsername } : {}),- ...(this.cachedAccountId ? { account_id: this.cachedAccountId } : {}),- };- }-- /**- * Sanitize event properties to prevent PII leakage.- * Simple allowlist approach: only allow safe property names and primitive types.- */- private sanitizeEventAndProps(- _event: TelemetryEvent,- props: Record<string, unknown> | undefined- ) {- const sanitized: Record<string, unknown> = {};-- const allowedProps = new Set([- 'active_view',- 'active_main_panel',- 'active_right_panel',- 'focused_region',- 'view',- 'from_view',- 'to_view',- 'main_panel',- 'right_panel',- 'trigger',- 'event_ts_ms',- 'session_id',- 'project_id',- 'task_id',- 'conversation_id',- 'side',- 'region',- 'panel',- 'from_status',- 'to_status',- 'has_issue',- 'is_first_in_task',- 'is_draft',- 'exit_code',- 'setting',- 'severity',- 'component',- 'action',- 'user_action',- 'operation',- 'endpoint',- 'session_errors',- 'error_timestamp',- 'schema_version',- 'provider',- 'source',- 'has_initial_prompt',- 'state',- 'success',- 'error_type',- 'github_username',- 'account_id',- 'enabled',- 'app',- 'applied_migrations_bucket',- 'recovered',- 'date',- 'timezone',- 'scope',- 'strategy',- 'conflicts',- 'count',- 'terminal_id',- 'was_crash',- 'type',- ]);- const passthroughProps = new Set([- '$exception_message',- '$exception_type',- '$exception_stack_trace_raw',- '$exception_fingerprint',- ]);-- if (props) {- for (const [key, value] of Object.entries(props)) {- if (!allowedProps.has(key) && !passthroughProps.has(key)) continue;-- if (typeof value === 'string') {- const maxLength = passthroughProps.has(key) ? 2_000 : 100;- sanitized[key] = value.trim().slice(0, maxLength);- } else if (typeof value === 'number') {- if (key === 'event_ts_ms') {- sanitized[key] = Math.max(0, Math.min(Math.trunc(value), 9_999_999_999_999));- } else {- sanitized[key] = Math.max(-1_000_000, Math.min(value, 1_000_000));- }- } else if (typeof value === 'boolean') {- sanitized[key] = value;- } else if (value === null) {- sanitized[key] = null;- }- }- }-- return sanitized;- }-- private normalizeHost(h: string | undefined): string | undefined {- if (!h) return undefined;- let s = String(h).trim();- if (!/^https?:\/\//i.test(s)) {- s = 'https://' + s;- }- return s.replace(/\/+$/, '');- }-- // ---------------------------------------------------------------------------- // PostHog transport- // ----------------------------------------------------------------------------- private async posthogCapture(- event: TelemetryEvent,- properties?: Record<string, unknown>- ): Promise<void> {- if (!this.isEnabled()) return;- try {- const u = (this.host ?? '').replace(/\/$/, '') + '/capture/';- const body = {- api_key: this.apiKey,- event,- properties: {- distinct_id: this.instanceId,- ...this.getBaseProps(),- ...this.sanitizeEventAndProps(event, properties),- },- };- await fetch(u, {- method: 'POST',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify(body),- signal: AbortSignal.timeout(5_000),- }).catch(() => undefined);- } catch {- // swallow errors; telemetry must never crash the app- }- }-- private async posthogIdentify(username: string, email?: string): Promise<void> {- if (!this.isEnabled() || !username) return;- try {- const u = (this.host ?? '').replace(/\/$/, '') + '/capture/';- const body = {- api_key: this.apiKey,- event: '$identify',- properties: {- distinct_id: this.instanceId,- $set: {- ...(email ? { email } : {}),- ...this.getBaseProps(),- },- },- };- await fetch(u, {- method: 'POST',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify(body),- signal: AbortSignal.timeout(5_000),- }).catch(() => undefined);- } catch {- // swallow errors; telemetry must never crash the app- }- }-- private async posthogDecide(): Promise<void> {- if (!this.isEnabled() || !this.instanceId) return;- try {- const u = (this.host ?? '').replace(/\/$/, '') + '/decide/?v=3';- const body = {- api_key: this.apiKey,- distinct_id: this.instanceId,- person_properties: {- ...(this.cachedGithubUsername ? { github_username: this.cachedGithubUsername } : {}),- ...(this.cachedAccountId ? { account_id: this.cachedAccountId } : {}),- ...(this.cachedEmail ? { email: this.cachedEmail } : {}),- },- };- const response = await fetch(u, {- method: 'POST',- headers: { 'Content-Type': 'application/json' },- body: JSON.stringify(body),- });- if (response.ok) {- const data = (await response.json()) as { featureFlags?: Record<string, unknown> };- const flags = data.featureFlags ?? {};- const parsed: Record<string, boolean> = {};- for (const [key, value] of Object.entries(flags)) {- if (typeof value === 'boolean') {- parsed[key] = value;- } else if (value === 'true' || value === 'false') {- parsed[key] = value === 'true';- }- }- this.cachedFeatureFlags = parsed;- }- } catch {- // swallow errors; telemetry must never crash the app- }- }-- // ---------------------------------------------------------------------------- // Daily active user- // ----------------------------------------------------------------------------- private async checkDailyActiveUser(): Promise<void> {- if (!this.isEnabled()) return;- try {- const today = new Date().toISOString().split('T')[0]!;- if (this.lastActiveDate === today) return;-- void this.posthogCapture('daily_active_user', {- date: today,- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || 'unknown',- });-- this.lastActiveDate = today;- void this.kv.set('lastActiveDate', today);- } catch {- // Never let telemetry errors crash the app- }- }-- // ---------------------------------------------------------------------------- // Public API- // ----------------------------------------------------------------------------- async initialize(options?: InitOptions): Promise<void> {- const enabledEnv = (appEnv.runtime.TELEMETRY_ENABLED ?? 'true').toLowerCase();- this.enabled =- !isViteDevBuild && enabledEnv !== 'false' && enabledEnv !== '0' && enabledEnv !== 'no';- // build value wins (prod); dev fallback used locally without VITE_ vars set- this.apiKey = appEnv.build.VITE_POSTHOG_KEY ?? appEnv.dev.POSTHOG_PROJECT_API_KEY;- this.host = this.normalizeHost(appEnv.build.VITE_POSTHOG_HOST ?? appEnv.dev.POSTHOG_HOST);- this.installSource = options?.installSource ?? appEnv.runtime.INSTALL_SOURCE;- this.sessionId = randomUUID();-- // Load persisted state from SQLite KV (all reads are non-blocking best-effort)- let storedInstanceId: string | null = null;- let storedEnabled: string | null = null;- let storedActiveDate: string | null = null;- let storedLastSessionId: string | null = null;- let storedLastHeartbeatTs: string | null = null;- try {- [- storedInstanceId,- storedEnabled,- storedActiveDate,- storedLastSessionId,- storedLastHeartbeatTs,- ] = await Promise.all([- this.kv.get('instanceId'),- this.kv.get('enabled'),- this.kv.get('lastActiveDate'),- this.kv.get('lastSessionId'),- this.kv.get('lastHeartbeatTs'),- ]);- } catch {- // KV unavailable during startup (e.g. DB migration not yet applied) — use in-memory defaults- }-- this.instanceId = storedInstanceId ?? (randomUUID().toString() as string);- if (!storedInstanceId) {- void this.kv.set('instanceId', this.instanceId);- }-- this.userOptOut = storedEnabled === 'false' ? true : undefined;- this.lastActiveDate = storedActiveDate ?? undefined;-- // Detect unclean exit from the previous session: if we have a recorded session ID- // that was never cleared by a clean shutdown, emit a synthetic app_closed so that- // session duration queries remain accurate.- if (storedLastSessionId && storedLastHeartbeatTs) {- const lastHeartbeatMs = Date.parse(storedLastHeartbeatTs);- if (!Number.isNaN(lastHeartbeatMs)) {- void this.posthogCapture('app_closed', {- was_crash: true,- event_ts_ms: lastHeartbeatMs,- session_id: storedLastSessionId,- });- }- }- // Record the current session ID so the next startup can detect a crash.- // sessionId is guaranteed non-undefined at this point (set to randomUUID() above).- void this.kv.set('lastSessionId', this.sessionId!);-- void this.posthogCapture('app_started');- void this.checkDailyActiveUser();-- // Heartbeat: write lastHeartbeatTs to KV every 60 s so crash recovery can- // estimate session duration without firing any PostHog events.- this.heartbeatInterval = setInterval(() => {- void this.kv.set('lastHeartbeatTs', new Date().toISOString());- }, 60_000);- }-- async dispose(): Promise<void> {- if (this.heartbeatInterval !== undefined) {- clearInterval(this.heartbeatInterval);- this.heartbeatInterval = undefined;- }- // Await both deletes so the process cannot exit before they complete.- // If these are fire-and-forget, the next startup will see lastSessionId still- // in KV and incorrectly emit a synthetic app_closed with was_crash: true.- await Promise.all([this.kv.del('lastSessionId'), this.kv.del('lastHeartbeatTs')]);- }-- /**- * Associate the current anonymous session with a known identity. Called via- * the accountChanged hook when sign-in succeeds or on cold boot if a session- * is already stored. Triggers a PostHog identify and a decide call to refresh- * cached feature flags.- */- async identify(username: string, userId: string, email: string): Promise<void> {- if (!username) return;- this.cachedGithubUsername = username;- this.cachedAccountId = userId;- this.cachedEmail = email;- await this.posthogIdentify(username, email);- await this.posthogDecide();- }-- /**- * Clear the cached identity and feature flags. Called via the accountCleared- * hook when the user signs out.- */- clearIdentity(): void {- this.cachedGithubUsername = null;- this.cachedAccountId = null;- this.cachedEmail = null;- this.cachedFeatureFlags = {};- }-- capture<E extends TelemetryEvent>(- event: E,- properties?: TelemetryProperties<E> | Record<string, unknown>- ): void {- const captureSessionId = this.sessionId ?? randomUUID();- this.sessionId = captureSessionId;- const envelope: TelemetryEnvelope = {- event_ts_ms: Date.now(),- session_id: captureSessionId,- };- void this.posthogCapture(event, {- ...(properties as Record<string, unknown> | undefined),- ...envelope,- });- }-- /**- * Capture an exception for PostHog error tracking.- */- captureException(error: Error | unknown, additionalProperties?: Record<string, unknown>): void {- if (!this.isEnabled()) return;-- const errorObj = error instanceof Error ? error : new Error(String(error));-- void this.posthogCapture('$exception', {- $exception_message: errorObj.message || 'Unknown error',- $exception_type: errorObj.name || 'Error',- $exception_stack_trace_raw: errorObj.stack || '',- ...additionalProperties,- });- }-- getTelemetryStatus() {- return {- enabled: this.isEnabled(),- envDisabled: isViteDevBuild || !this.enabled,- userOptOut: this.userOptOut === true,- hasKeyAndHost: !!this.apiKey && !!this.host,- session_id: this.sessionId ?? null,- instance_id: this.instanceId ?? null,- };- }-- getInstanceId(): string | undefined {- return this.instanceId;- }-- setTelemetryEnabledViaUser(enabledFlag: boolean): void {- this.userOptOut = !enabledFlag;- void this.kv.set('enabled', String(enabledFlag));- }-- async checkAndReportDailyActiveUser(): Promise<void> {- return this.checkDailyActiveUser();- }-- /**- * Returns the current set of evaluated feature flags. In dev mode, FLAG_*- * environment variables (e.g. FLAG_my_flag=true) override any PostHog values.- */- getFeatureFlags(): Record<string, boolean> {- if (!isViteDevBuild) return this.cachedFeatureFlags;-- const overrides: Record<string, boolean> = {};- for (const [key, value] of Object.entries(process.env)) {- if (key.startsWith('FLAG_')) {- const flagName = key.slice(5).toLowerCase().replace(/_/g, '-');- overrides[flagName] = value === 'true' || value === '1';- }- }- return { ...this.cachedFeatureFlags, ...overrides };- }-}--export const telemetryService = new TelemetryService();diff --git a/dash/apps/switchdash-desktop/src/main/rpc.ts b/dash/apps/switchdash-desktop/src/main/rpc.tsindex 2cf93429c..5eccc513b 100644--- a/dash/apps/switchdash-desktop/src/main/rpc.ts+++ b/dash/apps/switchdash-desktop/src/main/rpc.ts@@ -16,7 +16,6 @@ import { subagentsController } from './core/subagents/controller';import { switchRoomsController } from './core/switch-rooms/controller';import { switchServersController } from './core/switch-servers/controller';import { switchSetupController } from './core/switch-setup/controller';-import { telemetryController } from './core/telemetry/controller';import { updateController } from './core/updates/controller';import { viewStateController } from './core/view-state/controller';import { projectSettingsController } from './core/workspaces/project-settings-controller';@@ -33,7 +32,6 @@ export const rpcRouter = createRPCRouter({promptLibrary: promptLibraryController,projects: projectController,sessions: sessionController,- telemetry: telemetryController,viewState: viewStateController,search: searchController,switchRooms: switchRoomsController,diff --git a/dash/apps/switchdash-desktop/src/renderer/App.tsx b/dash/apps/switchdash-desktop/src/renderer/App.tsxindex d71cd825b..22ff556ad 100644--- a/dash/apps/switchdash-desktop/src/renderer/App.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/App.tsx@@ -7,7 +7,6 @@ import { SessionDeeplinkListener } from './features/switch-rooms/session-deeplinimport { WorkspaceLayoutContextProvider } from './lib/layout/layout-provider';import { WorkspaceViewProvider } from './lib/layout/provider';import { ModalRenderer } from './lib/modal/modal-renderer';-import { FeatureFlagProvider } from './lib/providers/feature-flag-override-context';import { ThemeProvider } from './lib/providers/theme-provider';import { TerminalPoolProvider } from './lib/pty/pty-pool-provider';import { queryClient } from './lib/query-client';@@ -65,9 +64,7 @@ function AppContent() {export function App() {return (<QueryClientProvider client={queryClient}>- <FeatureFlagProvider>- <AppContent />- </FeatureFlagProvider>+ <AppContent /></QueryClientProvider>);}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.test.tsindex 33afe94e9..612b917bb 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.test.ts+++ b/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.test.ts@@ -40,10 +40,6 @@ vi.mock('@renderer/lib/stores/view-state-cache', () => ({},}));-vi.mock('@renderer/utils/telemetryClient', () => ({- captureTelemetry: vi.fn(),-}));-function localProject(overrides: Partial<LocalProject> = {}): LocalProject {return {type: 'local',diff --git a/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.ts b/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.tsindex 5e2bbfef8..a24f3792d 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.ts+++ b/dash/apps/switchdash-desktop/src/renderer/features/projects/stores/project-manager.ts@@ -3,7 +3,6 @@ import { makeObservable, observable, runInAction } from 'mobx';import { rpc } from '@renderer/lib/ipc';import { appState } from '@renderer/lib/stores/app-state';import { viewStateCache } from '@renderer/lib/stores/view-state-cache';-import { captureTelemetry } from '@renderer/utils/telemetryClient';import { type LocalProject } from '@shared/projects';import type { ProjectViewSnapshot } from '@shared/view-state';import {@@ -109,9 +108,6 @@ export class ProjectManagerStore {projectId: string,targetPath: string | undefined): Promise<ProjectCreationCompletion> {- const projectTelemetryType = 'local' as const;- const projectTelemetryStrategy = 'open' as const;-let result: ProjectCreationCompletion;try {const projectResult = await rpc.projects.createProject({@@ -131,20 +127,10 @@ export class ProjectManagerStore {}} catch (error) {this._markUnexpectedCreationError(projectId, error);- captureTelemetry('project_added', {- type: projectTelemetryType,- strategy: projectTelemetryStrategy,- success: false,- });throw error;}if (!result.success) this._markCreationError(projectId, result.error);- captureTelemetry('project_added', {- type: projectTelemetryType,- strategy: projectTelemetryStrategy,- success: result.success,- });return result;}diff --git a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx b/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsxindex 4a1a0ecd2..d712ae002 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/settings/components/SettingsPage.tsx@@ -18,7 +18,6 @@ import {PreserveSessionNameCapitalizationRow,} from './SessionSettingsRows';import SidebarMetadataSettingsCard from './SidebarMetadataSettingsCard';-import TelemetryCard from './TelemetryCard';import TerminalSettingsCard from './TerminalSettingsCard';import ThemeCard from './ThemeCard';import { UpdateCard } from './UpdateCard';@@ -46,7 +45,6 @@ function GeneralSettingsPage() {description="Manage your account, privacy settings, notifications, and app updates."/><UpdateCard />- <TelemetryCard /><AutoGenerateSessionNamesRow /><AutoTrustWorktreesRow /><CreateBranchAndWorktreeRow />diff --git a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/TelemetryCard.tsx b/dash/apps/switchdash-desktop/src/renderer/features/settings/components/TelemetryCard.tsxdeleted file mode 100644index 83542373e..000000000--- a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/TelemetryCard.tsx+++ /dev/null@@ -1,63 +0,0 @@-import React from 'react';-import { useTelemetryConsent } from '@renderer/lib/hooks/useTelemetryConsent';-import { rpc } from '@renderer/lib/ipc';-import { Button } from '@renderer/lib/ui/button';-import { Switch } from '@renderer/lib/ui/switch';-import { PRODUCT_NAME } from '@shared/app-identity';-import { SettingRow } from './SettingRow';--const TelemetryCard: React.FC = () => {- const { prefEnabled, envDisabled, hasKeyAndHost, loading, setTelemetryEnabled } =- useTelemetryConsent();-- return (- <SettingRow- title="Privacy & Telemetry"- description={- <div>- <p>Help improve {PRODUCT_NAME} by sending anonymous usage data.</p>- <p>- <span>See </span>- <Button- type="button"- variant="link"- size="sm"- className="group text-muted-foreground inline-flex h-auto items-center gap-1 px-0 text-sm font-normal hover:text-foreground hover:no-underline focus-visible:ring-0 focus-visible:outline-none"- onClick={() => rpc.app.openExternal('https://github.com/sandbox-quantum/switch')}- >- <span className="transition-colors group-hover:text-foreground">- Telemetry information- </span>- <span className="text-muted-foreground text-sm transition-colors group-hover:text-foreground">- ↗- </span>- </Button>- <span> for details.</span>- </p>- </div>- }- control={- <div className="flex flex-col items-end gap-1">- <Switch- checked={prefEnabled}- onCheckedChange={async (checked) => {- void import('../../../utils/telemetryClient').then(({ captureTelemetry }) => {- captureTelemetry('setting_changed', { setting: 'telemetry' });- });- void setTelemetryEnabled(checked);- }}- disabled={loading || envDisabled}- aria-label="Enable anonymous telemetry"- />- {!hasKeyAndHost && (- <span className="text-muted-foreground text-[10px]">- Inactive in this build (no PostHog keys)- </span>- )}- </div>- }- />- );-};--export default TelemetryCard;diff --git a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/ThemeCard.tsx b/dash/apps/switchdash-desktop/src/renderer/features/settings/components/ThemeCard.tsxindex 9e78bf81b..025efbc61 100644--- a/dash/apps/switchdash-desktop/src/renderer/features/settings/components/ThemeCard.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/features/settings/components/ThemeCard.tsx@@ -1,16 +1,12 @@import { Monitor, Moon, Sun } from 'lucide-react';import React from 'react';import { useTheme } from '@renderer/lib/hooks/useTheme';-import { captureTelemetry } from '@renderer/utils/telemetryClient';import type { Theme } from '@shared/core/app-settings';const ThemeCard: React.FC = () => {const { theme, setTheme } = useTheme();const handleSetTheme = (next: Theme) => {- if (theme !== next) {- captureTelemetry('setting_changed', { setting: 'theme' });- }setTheme(next);};diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/hooks/useFeatureFlag.ts b/dash/apps/switchdash-desktop/src/renderer/lib/hooks/useFeatureFlag.tsdeleted file mode 100644index 44d136ac8..000000000--- a/dash/apps/switchdash-desktop/src/renderer/lib/hooks/useFeatureFlag.ts+++ /dev/null@@ -1,15 +0,0 @@-import { useFeatureFlags } from '@renderer/lib/providers/feature-flag-override-context';--/**- * Returns true when the named feature flag is enabled for this client.- * Returns false while flags are loading or when telemetry is not configured.- *- * In dev builds, FLAG_<name> env vars (hyphens → underscores) in .env.local- * take precedence. Example: FLAG_workspace_provider=true enables "workspace-provider".- * These are read by the main process at runtime and passed over IPC — they are- * never baked into the renderer bundle.- */-export function useFeatureFlag(flag: string): boolean {- const flags = useFeatureFlags();- return flags[flag] ?? false;-}diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/hooks/useTelemetryConsent.ts b/dash/apps/switchdash-desktop/src/renderer/lib/hooks/useTelemetryConsent.tsdeleted file mode 100644index a4df62091..000000000--- a/dash/apps/switchdash-desktop/src/renderer/lib/hooks/useTelemetryConsent.ts+++ /dev/null@@ -1,80 +0,0 @@-import { useCallback, useEffect, useState } from 'react';-import { rpc } from '@renderer/lib/ipc';--type TelemetryState = {- prefEnabled: boolean;- envDisabled: boolean;- hasKeyAndHost: boolean;- loading: boolean;-};--const initialState: TelemetryState = {- prefEnabled: true,- envDisabled: false,- hasKeyAndHost: true,- loading: true,-};--export function useTelemetryConsent() {- const [state, setState] = useState<TelemetryState>(initialState);-- const applyStatus = useCallback(- (res: Awaited<ReturnType<typeof rpc.telemetry.getStatus>> | null) => {- if (res?.status) {- const { envDisabled: envOff, userOptOut, hasKeyAndHost } = res.status;- setState({- prefEnabled: !envOff && userOptOut !== true,- envDisabled: !!envOff,- hasKeyAndHost: !!hasKeyAndHost,- loading: false,- });- } else {- setState((prev) => ({ ...prev, loading: false }));- }- },- []- );-- const refresh = useCallback(async () => {- setState((prev) => ({ ...prev, loading: true }));- try {- applyStatus(await rpc.telemetry.getStatus());- } catch {- setState((prev) => ({ ...prev, loading: false }));- }- }, [applyStatus]);-- const setTelemetryEnabled = useCallback(- async (enabled: boolean) => {- setState((prev) => ({ ...prev, prefEnabled: enabled, loading: true }));- try {- await rpc.telemetry.setEnabled(enabled);- } catch {- // ignore, refresh will reconcile- }- await refresh();- },- [refresh]- );-- useEffect(() => {- let cancelled = false;- rpc.telemetry- .getStatus()- .then((res) => {- if (!cancelled) applyStatus(res);- })- .catch(() => {- if (!cancelled) setState((prev) => ({ ...prev, loading: false }));- });- return () => {- cancelled = true;- };- }, [applyStatus]);-- return {- ...state,- refresh,- setTelemetryEnabled,- };-}diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/layout/provider.tsx b/dash/apps/switchdash-desktop/src/renderer/lib/layout/provider.tsxindex 403ce943b..ed9f4f8c7 100644--- a/dash/apps/switchdash-desktop/src/renderer/lib/layout/provider.tsx+++ b/dash/apps/switchdash-desktop/src/renderer/lib/layout/provider.tsx@@ -1,39 +1,7 @@-import { reaction, runInAction } from 'mobx';+import { runInAction } from 'mobx';import { observer } from 'mobx-react-lite';import { useEffect, type ReactNode } from 'react';-import { type ViewId, type WrapParams } from '@renderer/app/view-registry';import { appState } from '@renderer/lib/stores/app-state';-import { viewEvents } from '@renderer/lib/stores/navigation-store';-import { focusTracker } from '@renderer/utils/focus-tracker';-import {- clearTelemetrySessionScope,- setTelemetrySessionScope,-} from '@renderer/utils/telemetry-scope';-import { captureTelemetry } from '@renderer/utils/telemetryClient';--type ViewParamsStore = Partial<{ [K in ViewId]: WrapParams<K> }>;--function syncTelemetryScope(currentViewId: ViewId, viewParamsStore: ViewParamsStore): void {- if (currentViewId !== 'session') {- clearTelemetrySessionScope();- return;- }-- const sessionParams = viewParamsStore.session;- if (- sessionParams &&- typeof sessionParams.projectId === 'string' &&- typeof sessionParams.sessionId === 'string'- ) {- setTelemetrySessionScope({- projectId: sessionParams.projectId,- sessionId: sessionParams.sessionId,- });- return;- }-- clearTelemetrySessionScope();-}export const WorkspaceViewProvider = observer(function WorkspaceViewProvider({children,@@ -42,25 +10,6 @@ export const WorkspaceViewProvider = observer(function WorkspaceViewProvider({}) {const currentViewId = appState.navigation.currentViewId;- useEffect(() => {- const initialViewId = appState.navigation.currentViewId;- focusTracker.initialize({ view: initialViewId });- syncTelemetryScope(initialViewId, appState.navigation.viewParamsStore as ViewParamsStore);- captureTelemetry(viewEvents[initialViewId], { from_view: null });- }, []);-- useEffect(() => {- return reaction(- () => ({- viewId: appState.navigation.currentViewId,- params: appState.navigation.viewParamsStore,- }),- ({ viewId, params }) => {- syncTelemetryScope(viewId as ViewId, params as ViewParamsStore);- }- );- }, []);-useEffect(() => {runInAction(() => {appState.navigation.isNavigating = false;diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/providers/feature-flag-override-context.tsx b/dash/apps/switchdash-desktop/src/renderer/lib/providers/feature-flag-override-context.tsxdeleted file mode 100644index d967d62a8..000000000--- a/dash/apps/switchdash-desktop/src/renderer/lib/providers/feature-flag-override-context.tsx+++ /dev/null@@ -1,22 +0,0 @@-import { useQuery } from '@tanstack/react-query';-import { createContext, useContext, type ReactNode } from 'react';-import { rpc } from '@renderer/lib/ipc';--const FeatureFlagContext = createContext<Record<string, boolean>>({});--export function FeatureFlagProvider({ children }: { children: ReactNode }) {- const { data: flags = {} } = useQuery({- queryKey: ['feature-flags'],- queryFn: () => rpc.telemetry.getFeatureFlags(),- staleTime: Infinity,- refetchInterval: (query) => {- const data = query.state.data;- return !data || Object.keys(data).length === 0 ? 2_000 : false;- },- });- return <FeatureFlagContext value={flags}>{children}</FeatureFlagContext>;-}--export function useFeatureFlags(): Record<string, boolean> {- return useContext(FeatureFlagContext);-}diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.test.ts b/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.test.tsindex e81aa2982..eef6a8e1e 100644--- a/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.test.ts+++ b/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.test.ts@@ -4,14 +4,6 @@ vi.mock('@renderer/lib/modal/modal-store', () => ({modalStore: { closeModal: vi.fn() },}));-vi.mock('@renderer/utils/focus-tracker', () => ({- focusTracker: { transition: vi.fn(() => null) },-}));--vi.mock('@renderer/utils/telemetryClient', () => ({- captureTelemetry: vi.fn(),-}));-vi.mock('./app-state', () => ({appState: {history: { push: vi.fn() },diff --git a/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.ts b/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.tsindex 47cb661de..71a5c529d 100644--- a/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.ts+++ b/dash/apps/switchdash-desktop/src/renderer/lib/stores/navigation-store.ts@@ -2,25 +2,12 @@ import { makeAutoObservable, toJS } from 'mobx';import { type GuardResult, type ViewId, type WrapParams } from '@renderer/app/view-registry';import type { NonSettingsViewId } from '@renderer/lib/layout/navigation-provider';import { modalStore } from '@renderer/lib/modal/modal-store';-import { focusTracker } from '@renderer/utils/focus-tracker';-import { captureTelemetry } from '@renderer/utils/telemetryClient';import type { NavigationSnapshot } from '@shared/view-state';import { appState } from './app-state';import type { Snapshottable } from './snapshottable';type ViewParamsStore = Partial<{ [K in ViewId]: WrapParams<K> }>;-export const viewEvents: Record<- ViewId,- 'home_viewed' | 'project_viewed' | 'session_viewed' | 'settings_viewed' | 'server_viewed'-> = {- home: 'home_viewed',- project: 'project_viewed',- session: 'session_viewed',- settings: 'settings_viewed',- server: 'server_viewed',-};-export class NavigationStore implements Snapshottable<NavigationSnapshot> {currentViewId: ViewId = 'home';viewParamsStore: ViewParamsStore = {};@@ -70,17 +57,6 @@ export class NavigationStore implements Snapshottable<NavigationSnapshot> {}if (viewId !== this.currentViewId) {- const transition = focusTracker.transition(- {- view: viewId,- mainPanel: null,- focusedRegion: null,- },- 'navigation'- );- captureTelemetry(viewEvents[viewId], {- from_view: transition?.previous.view ?? null,- });this.currentViewId = viewId;if (viewId !== 'settings') {this.lastNonSettingsView = viewId;diff --git a/dash/apps/switchdash-desktop/src/renderer/tests/focus-tracker.test.ts b/dash/apps/switchdash-desktop/src/renderer/tests/focus-tracker.test.tsdeleted file mode 100644index 04aabec9f..000000000--- a/dash/apps/switchdash-desktop/src/renderer/tests/focus-tracker.test.ts+++ /dev/null@@ -1,31 +0,0 @@-import { describe, expect, it, vi } from 'vitest';-import { FocusTracker } from '@renderer/utils/focus-tracker';--describe('FocusTracker', () => {- it('emits exited focus state on transition', () => {- const tracker = new FocusTracker();- const emit = vi.fn();- tracker.setTransitionEmitter(emit);-- tracker.initialize({ view: 'home', mainPanel: null, focusedRegion: null });- tracker.transition({ view: 'session', mainPanel: 'agents' }, 'navigation');-- expect(emit).toHaveBeenCalledTimes(1);- const payload = emit.mock.calls[0][0] as Record<string, unknown>;- expect(payload.view).toBe('home');- expect(payload.trigger).toBe('navigation');- expect(payload).not.toHaveProperty('duration_ms');- });-- it('does not emit when no tracked focus state changed', () => {- const tracker = new FocusTracker();- const emit = vi.fn();- tracker.setTransitionEmitter(emit);-- tracker.initialize({ view: 'home', mainPanel: null, focusedRegion: null });- const result = tracker.transition({}, 'navigation');-- expect(result).toBeNull();- expect(emit).not.toHaveBeenCalled();- });-});diff --git a/dash/apps/switchdash-desktop/src/renderer/utils/focus-tracker.ts b/dash/apps/switchdash-desktop/src/renderer/utils/focus-tracker.tsdeleted file mode 100644index 74ab55b81..000000000--- a/dash/apps/switchdash-desktop/src/renderer/utils/focus-tracker.ts+++ /dev/null@@ -1,89 +0,0 @@-import type {- FocusContext,- FocusedRegion,- FocusMainPanel,- FocusTrigger,- FocusView,- TelemetryEventProperties,-} from '@shared/telemetry';--interface FocusState {- view: FocusView | null;- mainPanel: FocusMainPanel | null;- focusedRegion: FocusedRegion | null;-}--export interface FocusTransitionResult {- previous: FocusState;- changed: boolean;-}--type FocusChangedPayload = TelemetryEventProperties['focus_changed'];--type TransitionEmitter = (payload: FocusChangedPayload) => void;--export class FocusTracker {- private state: FocusState = {- view: null,- mainPanel: null,- focusedRegion: null,- };-- private initialized = false;- private transitionEmitter?: TransitionEmitter;-- initialize(initial: Partial<FocusState>): void {- if (this.initialized) return;- this.state = {- ...this.state,- ...initial,- };- this.initialized = true;- }-- setTransitionEmitter(emitter: TransitionEmitter): void {- this.transitionEmitter = emitter;- }-- transition(partial: Partial<FocusState>, trigger: FocusTrigger): FocusTransitionResult | null {- if (!this.initialized) {- this.initialize(partial);- return null;- }-- const previous = { ...this.state };- const changed = (Object.keys(partial) as Array<keyof FocusState>).some((key) => {- const value = partial[key];- if (value === undefined) return false;- return this.state[key] !== value;- });- if (!changed) return null;-- this.transitionEmitter?.({- view: previous.view,- main_panel: previous.mainPanel,- focused_region: previous.focusedRegion,- trigger,- });-- this.state = {- ...this.state,- ...partial,- };-- return {- previous,- changed,- };- }-- getContext(): FocusContext {- return {- active_view: this.state.view,- active_main_panel: this.state.mainPanel,- focused_region: this.state.focusedRegion,- };- }-}--export const focusTracker = new FocusTracker();diff --git a/dash/apps/switchdash-desktop/src/renderer/utils/telemetry-scope.ts b/dash/apps/switchdash-desktop/src/renderer/utils/telemetry-scope.tsdeleted file mode 100644index 3344ed20f..000000000--- a/dash/apps/switchdash-desktop/src/renderer/utils/telemetry-scope.ts+++ /dev/null@@ -1,35 +0,0 @@-import type { TelemetryEnvelope } from '@shared/telemetry';--type TelemetryScope = Pick<TelemetryEnvelope, 'project_id' | 'session_id' | 'conversation_id'>;--const scope: TelemetryScope = {- project_id: undefined,- session_id: undefined,- conversation_id: undefined,-};--export function setTelemetrySessionScope({- projectId,- sessionId,-}: {- projectId: string;- sessionId: string;-}): void {- scope.project_id = projectId;- scope.session_id = sessionId;- scope.conversation_id = undefined;-}--export function clearTelemetrySessionScope(): void {- scope.project_id = undefined;- scope.session_id = undefined;- scope.conversation_id = undefined;-}--export function setTelemetryConversationScope(conversationId: string | null): void {- scope.conversation_id = conversationId ?? undefined;-}--export function getTelemetryScope(): TelemetryScope {- return { ...scope };-}diff --git a/dash/apps/switchdash-desktop/src/renderer/utils/telemetryClient.ts b/dash/apps/switchdash-desktop/src/renderer/utils/telemetryClient.tsdeleted file mode 100644index 3dad312cc..000000000--- a/dash/apps/switchdash-desktop/src/renderer/utils/telemetryClient.ts+++ /dev/null@@ -1,62 +0,0 @@-/**- * Simple telemetry client for renderer process.- * Captures events and sends them to the main process via IPC.- */-import type { TelemetryEvent, TelemetryProperties } from '@shared/telemetry';-import { rpc } from '../lib/ipc';-import { focusTracker } from './focus-tracker';-import { getTelemetryScope } from './telemetry-scope';--let cachedSessionId: string | null | undefined;-let pendingSessionIdPromise: Promise<string | null> | null = null;--async function getSessionId(): Promise<string | null> {- if (cachedSessionId !== undefined) return cachedSessionId;- if (pendingSessionIdPromise) return pendingSessionIdPromise;-- pendingSessionIdPromise = rpc.telemetry- .getStatus()- .then((result) => {- cachedSessionId = result.status?.session_id ?? null;- return cachedSessionId;- })- .catch(() => {- return null;- })- .finally(() => {- pendingSessionIdPromise = null;- });-- return pendingSessionIdPromise;-}--async function captureWithProps(event: TelemetryEvent, properties?: Record<string, unknown>) {- const sessionId = await getSessionId();-- void rpc.telemetry- .capture({- event,- properties: {- ...(properties ?? {}),- ...getTelemetryScope(),- ...(sessionId ? { session_id: sessionId } : {}),- },- })- .catch(() => {});-}--export function captureTelemetry<E extends TelemetryEvent>(- event: E,- properties?: TelemetryProperties<E>-): void {- void captureWithProps(event, {- ...focusTracker.getContext(),- ...(properties as Record<string, unknown> | undefined),- }).catch(() => {- // Telemetry failures never break the app- });-}--focusTracker.setTransitionEmitter((properties) => {- captureTelemetry('focus_changed', properties);-});diff --git a/dash/apps/switchdash-desktop/src/shared/telemetry.ts b/dash/apps/switchdash-desktop/src/shared/telemetry.tsdeleted file mode 100644index 275e46e25..000000000--- a/dash/apps/switchdash-desktop/src/shared/telemetry.ts+++ /dev/null@@ -1,157 +0,0 @@-import type { AgentProviderId } from '@shared/core/providers/agent-provider-registry';-import type { SessionLifecycleStatus } from '@shared/core/sessions/sessions';-import type { OpenInAppId } from '@shared/openInApps';--type EmptyProps = Record<string, never>;--export type FocusView =- | 'home'- | 'project'- | 'session'- | 'settings'- | 'server'- | 'library'- | 'skills'- | 'mcp'- | 'automations';-export type FocusMainPanel = 'agents' | 'editor' | 'diff' | 'browser';-export type FocusedRegion = 'main' | 'bottom';--export type FocusTrigger = 'navigation' | 'panel_switch' | 'region_switch';--export interface TelemetryEnvelope {- event_ts_ms?: number;- session_id?: string;- project_id?: string;- conversation_id?: string;-}--export interface FocusContext {- active_view: FocusView | null;- active_main_panel: FocusMainPanel | null;- focused_region: FocusedRegion | null;-}--export type SettingName = 'theme' | 'default_provider' | 'telemetry' | 'notifications';--export type TelemetryEventProperties = {- app_started: EmptyProps;- app_closed: { was_crash?: boolean };- app_window_focused: EmptyProps;- app_window_unfocused: EmptyProps;- daily_active_user: { date: string; timezone: string };-- focus_changed: {- view: FocusView | null;- main_panel: FocusMainPanel | null;- focused_region: FocusedRegion | null;- trigger: FocusTrigger;- };-- home_viewed: { from_view: FocusView | null };- project_viewed: { from_view: FocusView | null };- session_viewed: { from_view: FocusView | null };- settings_viewed: { from_view: FocusView | null };- server_viewed: { from_view: FocusView | null };- library_viewed: { from_view: FocusView | null };- skills_viewed: { from_view: FocusView | null };- mcp_viewed: { from_view: FocusView | null };- automations_viewed: { from_view: FocusView | null };-- project_added: { type: 'local' | 'ssh'; strategy: 'open' | 'create' | 'clone'; success: boolean };- project_deleted: EmptyProps;-- session_created: {- strategy: 'blank' | 'branch' | 'issue' | 'pr';- has_initial_prompt: boolean;- has_issue:- | 'github'- | 'linear'- | 'jira'- | 'gitlab'- | 'plane'- | 'plain'- | 'forgejo'- | 'featurebase'- | 'asana'- | 'none';- provider: AgentProviderId | null;- };- session_provisioned: EmptyProps;- session_archived: EmptyProps;- session_status_changed: {- from_status: SessionLifecycleStatus;- to_status: SessionLifecycleStatus;- };- session_deleted: EmptyProps;-- conversation_created: { provider: AgentProviderId; is_first_in_session: boolean };- conversation_deleted: EmptyProps;- agent_run_started: { provider: AgentProviderId };-- terminal_created: { terminal_id: string };- terminal_deleted: { terminal_id: string };-- pr_created: { is_draft: boolean };- pr_creation_failed: { error_type: string };-- vcs_branch_published: { success: boolean; error_type?: string };- vcs_fetch: { success: boolean; error_type?: string };- vcs_push: { success: boolean; error_type?: string };- vcs_pull: { success: boolean; strategy?: string; conflicts?: boolean; error_type?: string };- vcs_files_staged: { count: number; scope: 'single' | 'multiple' | 'all' };- vcs_files_unstaged: { count: number; scope: 'single' | 'multiple' | 'all' };- vcs_files_discarded: { count: number; scope: 'single' | 'multiple' | 'all' };-- user_signed_in: EmptyProps;- user_signed_out: EmptyProps;-- integration_connected: { provider: 'github' | 'linear' | 'jira' | 'asana' };- integration_disconnected: { provider: 'github' | 'linear' | 'jira' | 'asana' };- issue_linked_to_session: {- provider:- | 'github'- | 'linear'- | 'jira'- | 'gitlab'- | 'plane'- | 'plain'- | 'forgejo'- | 'featurebase'- | 'asana';- };-- open_in_external: { app: OpenInAppId | 'browser' };- ssh_connection_attempted: { success: boolean };-- mcp_server_added: { source: 'catalog' | 'custom' };- mcp_server_removed: EmptyProps;-- skill_installed: { source?: string };- skill_uninstalled: EmptyProps;- skill_created: EmptyProps;-- setting_changed: { setting: SettingName };- sidebar_toggled: { side: 'left' | 'right'; state: 'open' | 'closed' };-- $exception: {- $exception_message: string;- $exception_type: string;- $exception_stack_trace_raw: string;- $exception_fingerprint?: string;- severity?: 'low' | 'medium' | 'high' | 'critical';- component?: string;- action?: string;- user_action?: string;- operation?: string;- endpoint?: string;- session_errors?: number;- error_timestamp?: string;- error_type?: string;- };- error: { error_type: string; scope: string };-};--export type TelemetryEvent = keyof TelemetryEventProperties;-export type TelemetryProperties<E extends TelemetryEvent> = TelemetryEventProperties[E] &- TelemetryEnvelope;