Files
openmotion/shared/desktop-telemetry.ts
open-design-crew[bot] 6d38d942f2 feat(desktop): cloud-first thin shell, local atoms, signed config, and Sentry observability (#1001)
* feat(desktop): cloud-first thin shell, local atoms, signed config, and complete Sentry observability

* feat(desktop): add in-app update banner, release notes preview, and mandatory update gate

* fix(ci): resolve backend typecheck, dock short-host floor, ci-scope, and source privacy scan

* fix(desktop): address all P1 and P2 security/robustness review findings on PR #1001

* fix(local-atoms): accept TOML array-of-tables headers in merged structure check

---------

Co-authored-by: heggria <bshengtao@gmail.com>
2026-11-24 19:13:55 -08:00

84 lines
2.1 KiB
TypeScript

/**
* Privacy-safe, zero-PII Edge Health Telemetry Contract.
*
* Strictly records bounded operational counters and latency metrics (startup,
* PKCE auth handoff, auto-updater, signed config refresh, Connect Script pairing,
* and local Agent connect outcomes). Never captures tokens, emails, user prompts,
* hostnames, or filesystem paths.
*/
import type { HostPlatform, HostReleaseChannel } from './desktop-contract.ts';
export const DESKTOP_TELEMETRY_CATEGORIES = [
'app.startup',
'auth.handoff',
'updater.check',
'updater.download',
'updater.install',
'signed_config.refresh',
'connect_script.pair',
'connect_script.pna_preflight',
'agent.connect',
] as const;
export type DesktopTelemetryCategory = (typeof DESKTOP_TELEMETRY_CATEGORIES)[number];
export const DESKTOP_TELEMETRY_OUTCOMES = [
'ok',
'applied',
'unchanged',
'authenticated',
'cancelled',
'timeout',
'fallback',
'conflict',
'user_denied',
'version_too_old',
'rejected',
'network_error',
'error',
] as const;
export type DesktopTelemetryOutcome = (typeof DESKTOP_TELEMETRY_OUTCOMES)[number];
export type DesktopTelemetryRecordInput = {
category: DesktopTelemetryCategory;
outcome: DesktopTelemetryOutcome;
durationMs?: number;
agentId?: string;
connectMode?: 'cli' | 'config';
pairMethod?: 'hash' | 'manual';
targetVersion?: string;
sequence?: number;
errorCode?: string;
};
export type DesktopTelemetryEvent = DesktopTelemetryRecordInput & {
timestamp: string;
channel: HostReleaseChannel;
platform: HostPlatform;
arch: string;
shellVersion: string;
};
export type DesktopTelemetryCategoryCounters = {
total: number;
outcomes: Partial<Record<DesktopTelemetryOutcome, number>>;
avgDurationMs?: number;
maxDurationMs?: number;
};
export type DesktopTelemetrySummary = {
schemaVersion: 1;
enabled: boolean;
channel: HostReleaseChannel;
platform: HostPlatform;
arch: string;
shellVersion: string;
totalEvents: number;
retainedEvents: number;
updatedAt: string;
categories: Partial<Record<DesktopTelemetryCategory, DesktopTelemetryCategoryCounters>>;
recentEvents: DesktopTelemetryEvent[];
};