forked from vas3k/TaxHacker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrumentation.ts
More file actions
48 lines (43 loc) · 1.82 KB
/
instrumentation.ts
File metadata and controls
48 lines (43 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as Sentry from '@sentry/nextjs';
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('./sentry.server.config');
// Drain audit log DLQ at startup (non-blocking)
try {
const { drainDLQ, getDLQStats } = await import('./lib/audit-dlq');
const drained = await drainDLQ();
if (drained > 0) {
console.log(`[TaxHacker] Drained ${drained} audit log entries from DLQ at startup`);
}
// Check if DLQ is non-empty after drain (indicates persistent DB issues)
const dlqStats = await getDLQStats();
if (dlqStats.exists) {
console.error(
`[TaxHacker] ALERT: Audit log DLQ file still exists after drain (${dlqStats.size} bytes). ` +
`This indicates persistent database connectivity issues.`
);
}
} catch (error) {
console.error('[TaxHacker] Error during DLQ startup drain:', error);
}
// Startup log: legacy self-hosted auth cookie migration window
if (process.env.TAXHACKER_SELF_HOSTED === 'true') {
const { LEGACY_AUTH_CUTOFF } = await import('./lib/self-hosted-auth');
const now = Date.now();
const cutoff = LEGACY_AUTH_CUTOFF.getTime();
if (now < cutoff) {
const daysUntilCutoff = Math.ceil((cutoff - now) / (1000 * 60 * 60 * 24));
console.log(
`[TaxHacker] Legacy auth cookie migration window: ${daysUntilCutoff} days remaining. ` +
`After ${LEGACY_AUTH_CUTOFF.toISOString().split('T')[0]}, old SHA-256 cookies will be rejected.`
);
} else {
console.log('[TaxHacker] Legacy auth cookie cutoff date has passed. Only new HMAC tokens accepted.');
}
}
}
if (process.env.NEXT_RUNTIME === 'edge') {
await import('./sentry.edge.config');
}
}
export const onRequestError = Sentry.captureRequestError;