Monitoring Clerk Auth Integration
Clerk handles auth infrastructure, but your integration needs observability.
Track Middleware Latency
export default clerkMiddleware(async (auth, req) => {
const start = Date.now();
const { userId } = await auth();
const duration = Date.now() - start;
if (duration > 100) {
console.warn('clerk_auth_slow: ' + duration + 'ms on ' + req.nextUrl.pathname);
}
});
Webhook Delivery
export async function POST(req: Request) {
try {
const evt = wh.verify(await req.text(), getHeaders(req));
await syncUser(evt);
return new Response('OK', { status: 200 });
} catch (err) {
console.error('webhook_failed');
return new Response('Error', { status: 400 });
}
}
Health Check
export async function GET() {
return Response.json({ status: 'ok', clerk: !!process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY });
}
Monitor with Vigilmon. Subscribe to status.clerk.com.
Alert Priorities
- Auth check latency above 200ms
- Webhook failure rate above 1%
- Clerk status page incidents
Top comments (0)