Compare commits
No commits in common. "83b035f1ae3ec30c5a5517bc01852ea3b24a2d7c" and "33260796f78b28970580cccd6dce0cc0bfea5fc1" have entirely different histories.
83b035f1ae
...
33260796f7
@ -1,88 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
// [MODAL-TRACKER 2026-05-14] QModal / PopupManager / contextPopup 의 atom 을 구독해
|
|
||||||
// 모달·팝업이 열리고 닫힐 때 콘솔에 컴포넌트명/id 를 출력. 모달 컴포넌트 개별 수정 없음.
|
|
||||||
import { useEffect, useRef } from 'react'
|
|
||||||
import { useRecoilValue } from 'recoil'
|
|
||||||
import { modalState, modalContent } from '@/store/modalAtom'
|
|
||||||
import { popupState, contextPopupState } from '@/store/popupAtom'
|
|
||||||
import { logger } from '@/util/logger'
|
|
||||||
|
|
||||||
const TRACK_ENABLED = process.env.NEXT_PUBLIC_ENABLE_LOGGING === 'true'
|
|
||||||
|
|
||||||
const BADGE_OPEN = 'background:#7b1fa2;color:#fff;padding:2px 8px;border-radius:3px;font-weight:bold'
|
|
||||||
const BADGE_CLOSE = 'background:#9e9e9e;color:#fff;padding:2px 8px;border-radius:3px'
|
|
||||||
const BADGE_POPUP = 'background:#00897b;color:#fff;padding:2px 8px;border-radius:3px;font-weight:bold'
|
|
||||||
const BADGE_CTX = 'background:#ef6c00;color:#fff;padding:2px 8px;border-radius:3px;font-weight:bold'
|
|
||||||
|
|
||||||
function describeNode(node) {
|
|
||||||
if (!node) return 'null'
|
|
||||||
if (Array.isArray(node)) return `Array(${node.length})`
|
|
||||||
const t = node?.type
|
|
||||||
if (!t) return typeof node
|
|
||||||
return typeof t === 'string' ? t : t.displayName || t.name || 'Anonymous'
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ModalTracker() {
|
|
||||||
const open = useRecoilValue(modalState)
|
|
||||||
const content = useRecoilValue(modalContent)
|
|
||||||
const popup = useRecoilValue(popupState)
|
|
||||||
const ctx = useRecoilValue(contextPopupState)
|
|
||||||
|
|
||||||
const firstModal = useRef(true)
|
|
||||||
const prevPopupIds = useRef({ config: [], other: [] })
|
|
||||||
const prevCtx = useRef(null)
|
|
||||||
|
|
||||||
// QModal open/close
|
|
||||||
useEffect(() => {
|
|
||||||
if (!TRACK_ENABLED) return
|
|
||||||
if (firstModal.current) {
|
|
||||||
firstModal.current = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (open) {
|
|
||||||
logger.info(`%c[MODAL OPEN] ${describeNode(content)}`, BADGE_OPEN)
|
|
||||||
} else {
|
|
||||||
logger.info(`%c[MODAL CLOSE]`, BADGE_CLOSE)
|
|
||||||
}
|
|
||||||
}, [open])
|
|
||||||
|
|
||||||
// PopupManager push/pop (config + other 두 버킷)
|
|
||||||
useEffect(() => {
|
|
||||||
if (!TRACK_ENABLED) return
|
|
||||||
const prev = prevPopupIds.current
|
|
||||||
for (const bucket of ['config', 'other']) {
|
|
||||||
const cur = popup?.[bucket] || []
|
|
||||||
const curIds = cur.map((p) => p.id)
|
|
||||||
const prevIds = prev[bucket] || []
|
|
||||||
curIds
|
|
||||||
.filter((id) => !prevIds.includes(id))
|
|
||||||
.forEach((id) => {
|
|
||||||
const item = cur.find((p) => p.id === id)
|
|
||||||
logger.info(`%c[POPUP+ ${bucket}] ${describeNode(item?.component)} (id=${id})`, BADGE_POPUP)
|
|
||||||
})
|
|
||||||
prevIds
|
|
||||||
.filter((id) => !curIds.includes(id))
|
|
||||||
.forEach((id) => {
|
|
||||||
logger.info(`%c[POPUP- ${bucket}] (id=${id})`, BADGE_CLOSE)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
prevPopupIds.current = {
|
|
||||||
config: (popup?.config || []).map((p) => p.id),
|
|
||||||
other: (popup?.other || []).map((p) => p.id),
|
|
||||||
}
|
|
||||||
}, [popup])
|
|
||||||
|
|
||||||
// contextPopup (우클릭 메뉴 등)
|
|
||||||
useEffect(() => {
|
|
||||||
if (!TRACK_ENABLED) return
|
|
||||||
if (ctx && !prevCtx.current) {
|
|
||||||
logger.info(`%c[CTX POPUP+] ${describeNode(ctx)}`, BADGE_CTX)
|
|
||||||
} else if (!ctx && prevCtx.current) {
|
|
||||||
logger.info(`%c[CTX POPUP-]`, BADGE_CLOSE)
|
|
||||||
}
|
|
||||||
prevCtx.current = ctx
|
|
||||||
}, [ctx])
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
@ -1,28 +0,0 @@
|
|||||||
'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
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user