fix(diagnostics): getAuthToken throws when no token (type-safe), void .start(), unsyncedCount replaces conflictCount
This commit is contained in:
parent
4a3ac76ff7
commit
909daf8853
@ -150,7 +150,7 @@ export async function timerRoutes(app: FastifyInstance) {
|
|||||||
const active = timers.filter(t => t.state === 'active' || t.state === 'warning').length;
|
const active = timers.filter(t => t.state === 'active' || t.state === 'warning').length;
|
||||||
const pending = timers.filter(t => t.state === 'paused').length;
|
const pending = timers.filter(t => t.state === 'paused').length;
|
||||||
const lastSyncedAt = timers[0]?.lastSyncedAt ?? null;
|
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 {
|
return {
|
||||||
userId: auth.sub,
|
userId: auth.sub,
|
||||||
@ -158,7 +158,7 @@ export async function timerRoutes(app: FastifyInstance) {
|
|||||||
totalTimers: timers.length,
|
totalTimers: timers.length,
|
||||||
active,
|
active,
|
||||||
pending,
|
pending,
|
||||||
conflictCount,
|
unsyncedCount,
|
||||||
lastSyncedAt,
|
lastSyncedAt,
|
||||||
generatedAt: new Date().toISOString(),
|
generatedAt: new Date().toISOString(),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -31,12 +31,17 @@ export function initDiagnostics(): void {
|
|||||||
buildNumber: process.env.NEXT_PUBLIC_BUILD_NUMBER ?? '1',
|
buildNumber: process.env.NEXT_PUBLIC_BUILD_NUMBER ?? '1',
|
||||||
releaseChannel: process.env.NEXT_PUBLIC_RELEASE_CHANNEL ?? 'beta',
|
releaseChannel: process.env.NEXT_PUBLIC_RELEASE_CHANNEL ?? 'beta',
|
||||||
serverUrl: getBaseUrl(),
|
serverUrl: getBaseUrl(),
|
||||||
getAuthToken: () => getAuthClient().getAccessToken() ?? undefined,
|
getAuthToken: () => {
|
||||||
|
const token = getAuthClient().getAccessToken();
|
||||||
|
if (!token) throw new Error('unauthenticated');
|
||||||
|
return token;
|
||||||
|
},
|
||||||
captureConsole: true,
|
captureConsole: true,
|
||||||
captureErrors: true,
|
captureErrors: true,
|
||||||
captureNetwork: false,
|
captureNetwork: false,
|
||||||
pollIntervalMs: 30_000,
|
pollIntervalMs: 30_000,
|
||||||
}).start();
|
});
|
||||||
|
void DiagnosticsClient.getInstance().start();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stopDiagnostics(): void {
|
export function stopDiagnostics(): void {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user