perf: optimize app startup and background lifecycles
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user