fix(diagnostics): getAuthToken throws when no token (type-safe), void .start(), unsyncedCount replaces conflictCount

This commit is contained in:
saravanakumardb1 2026-03-05 11:18:27 -08:00
parent 4a3ac76ff7
commit 909daf8853
2 changed files with 9 additions and 4 deletions

View File

@ -150,7 +150,7 @@ export async function timerRoutes(app: FastifyInstance) {
const active = timers.filter(t => t.state === 'active' || t.state === 'warning').length;
const pending = timers.filter(t => t.state === 'paused').length;
const lastSyncedAt = timers[0]?.lastSyncedAt ?? null;
const conflictCount = timers.filter(t => t.syncVersion === 0).length;
const unsyncedCount = timers.filter(t => t.lastSyncedAt == null).length;
return {
userId: auth.sub,
@ -158,7 +158,7 @@ export async function timerRoutes(app: FastifyInstance) {
totalTimers: timers.length,
active,
pending,
conflictCount,
unsyncedCount,
lastSyncedAt,
generatedAt: new Date().toISOString(),
};

View File

@ -31,12 +31,17 @@ export function initDiagnostics(): void {
buildNumber: process.env.NEXT_PUBLIC_BUILD_NUMBER ?? '1',
releaseChannel: process.env.NEXT_PUBLIC_RELEASE_CHANNEL ?? 'beta',
serverUrl: getBaseUrl(),
getAuthToken: () => getAuthClient().getAccessToken() ?? undefined,
getAuthToken: () => {
const token = getAuthClient().getAccessToken();
if (!token) throw new Error('unauthenticated');
return token;
},
captureConsole: true,
captureErrors: true,
captureNetwork: false,
pollIntervalMs: 30_000,
}).start();
});
void DiagnosticsClient.getInstance().start();
}
export function stopDiagnostics(): void {