qcast-front/src/components/common/PageTracker.jsx
2026-05-14 14:49:41 +09:00

29 lines
815 B
JavaScript

'use client'
// [PAGE-TRACKER 2026-05-14] 라우트 변경마다 콘솔 + document.title 에 현재 경로 표시.
// production 에서는 NEXT_PUBLIC_ENABLE_LOGGING=false 라 logger.info 가 무음.
import { useEffect } from 'react'
import { usePathname } from 'next/navigation'
import { logger } from '@/util/logger'
const TRACK_ENABLED = process.env.NEXT_PUBLIC_ENABLE_LOGGING === 'true'
export default function PageTracker() {
const pathname = usePathname()
useEffect(() => {
if (!TRACK_ENABLED || !pathname) return
logger.info(
`%c[PAGE] ${pathname}`,
'background:#1e88e5;color:#fff;padding:2px 8px;border-radius:3px;font-weight:bold',
)
if (typeof document !== 'undefined') {
document.title = `${pathname} · HANASYS DESIGN`
}
}, [pathname])
return null
}