mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
@coderabbitai ignore Follow-up to #725 / #726 — found during post-deploy verification. Test-throwing from \`/admin/crash-test\` showed the default Next.js "Application error" screen instead of the CrashReport card, and no pattern landed in Firestore. Root cause: the error-handling infrastructure was scoped to \`app/[locale]/\`, so routes outside that tree (\`/admin/*\`) had no coverage. ## Fix - Move \`ClientErrorInit\` mount from \`app/[locale]/layout.tsx\` to \`app/layout.tsx\` (root). \`DefaultIntlProvider\` at root already provides \`crashReport\` translations for admin pages. - Drop the \`locale\` prop from \`ClientErrorInit\`; \`client-error-setup\` now auto-detects locale from \`window.location.pathname\` (first segment, whitelisted against known locales, falls back to \`"en"\`). - Add \`app/error.tsx\` and \`app/global-error.tsx\` at root — any uncaught React error anywhere in the app now renders the CrashReport card. - Remove the redundant \`app/[locale]/error.tsx\` and \`global-error.tsx\` (root covers them; Next.js picks the closest boundary, so removing avoids duplication). ## Tests 20/20 frontend unit tests pass. Build emits \`out/admin/crash-test/\` correctly. ## Test plan - [ ] Deploy, visit \`https://gen.nomadkaraoke.com/admin/crash-test/\` as admin. - [ ] Click "Render-time throw" → expect the CrashReport card (not the default Next.js screen). - [ ] Click "Async throw" + "Unhandled rejection" → expect two new \`service=frontend\` patterns in Firestore. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
14 lines
345 B
TypeScript
14 lines
345 B
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import { useAuth } from '@/lib/auth'
|
|
import { installGlobalErrorHandlers } from '@/lib/client-error-setup'
|
|
|
|
export default function ClientErrorInit() {
|
|
const user = useAuth((s) => s.user)
|
|
useEffect(() => {
|
|
installGlobalErrorHandlers(() => user?.email ?? null)
|
|
}, [user])
|
|
return null
|
|
}
|