perf: optimize app startup and background lifecycles

This commit is contained in:
inman
2026-08-19 00:56:15 +08:00
parent 31332f6d76
commit 927e13349b
121 changed files with 4359 additions and 1400 deletions

View File

@@ -28,6 +28,10 @@ export function trackUiEvent(event: string, payload: TelemetryPayload = {}): voi
const normalizedPayload = {
...payload,
};
const isDevelopment = typeof window !== 'undefined' && Boolean(window.electron?.isDev);
const isHighFrequencyHostRequest = event === 'hostapi.fetch';
const shouldRecordHistory = isDevelopment || !isHighFrequencyHostRequest;
if (!shouldRecordHistory) return;
const ts = new Date().toISOString();
const entry: UiTelemetryEntry = {
id: nextEntryId,
@@ -51,7 +55,9 @@ export function trackUiEvent(event: string, payload: TelemetryPayload = {}): voi
};
// Local-only telemetry for UX diagnostics.
console.info(`[ui-metric] ${event} ${safeStringify(logPayload)}`);
if (isDevelopment || event.endsWith('_error')) {
console.info(`[ui-metric] ${event} ${safeStringify(logPayload)}`);
}
}
export function getUiCounter(event: string): number {