[feat] solution/backend,frontend: 방문 통계 오늘 방문자·직접 유입 — 최근 5분 대신 KST 오늘 0시부터, 리퍼러 없는 페이지뷰를 '직접·알 수 없음'으로
This commit is contained in:
1 parent
832fc81272
commit
2fc50de161
7 files changed
+52
-32
No files matched your search
@@ -7,7 +7,7 @@ import {RangeTabs} from './CrawlerStatsPanel';
|
||||
import {rangeParams, type RangeDays} from './range';
|
||||
import {VisitStatsPanel} from './VisitStatsPanel';
|
||||
|
||||
/** 실시간 숫자는 30초마다 다시 부른다 — "지금 몇 명" 은 화면을 열어 둔 채 보는 숫자다. */
|
||||
/** 30초마다 다시 부른다 — 오늘 방문자·페이지뷰는 화면을 열어 둔 채 보는 숫자다. */
|
||||
const REFRESH_MS = 30_000;
|
||||
|
||||
export function OverallVisitStats() {
|
||||
|
||||
@@ -13,15 +13,16 @@ const DEVICE_LABEL: Record<string, string> = {desktop: '데스크톱', mobile: '
|
||||
/** 방문 탭 본문. 전체: 사이트 순위 / 사이트별: 페이지·캠페인. 유입·기기는 공통. */
|
||||
export function VisitStatsPanel({data, scope}: {data: ResVisitStats; scope: 'overall' | 'site'}) {
|
||||
const summary = data.summary;
|
||||
const realtime = data.realtime ?? 0;
|
||||
// 기간 안에 기록이 없어도 지금 들어와 있는 사람이 있으면 그 숫자는 보여 준다.
|
||||
if (!summary?.views && !realtime) {
|
||||
const today = data.today_visitors ?? 0;
|
||||
const direct = summary?.direct_views ?? 0;
|
||||
// 기간 안에 기록이 없어도 오늘 들어온 사람이 있으면 그 숫자는 보여 준다.
|
||||
if (!summary?.views && !today) {
|
||||
return <EmptyState icon={Users} title="아직 방문 기록이 없습니다" description="선택한 기간에 들어온 방문이 없습니다." />;
|
||||
}
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-2 gap-3 md:grid-cols-4">
|
||||
<Stat label="실시간 방문자 (최근 5분)" value={realtime} />
|
||||
<Stat label="오늘 방문자" value={today} />
|
||||
<Stat label="페이지뷰" value={summary?.views ?? 0} />
|
||||
<Stat label="방문자" value={summary?.visitors ?? 0} />
|
||||
<Stat label="마지막 방문" value={<span className="text-base">{formatKst(summary?.last_at)}</span>} />
|
||||
@@ -69,7 +70,16 @@ export function VisitStatsPanel({data, scope}: {data: ResVisitStats; scope: 'ove
|
||||
)}
|
||||
|
||||
<Section title="유입 도메인">
|
||||
<Table head={['도메인', '페이지뷰']} rows={(data.referrers ?? []).map((r) => [r.domain, r.views])} />
|
||||
<Table
|
||||
head={['도메인', '페이지뷰']}
|
||||
rows={[
|
||||
// 출처를 알 수 없는 방문 — 직접 입력뿐 아니라 메신저·앱·QR 도 여기 섞인다.
|
||||
...(direct > 0
|
||||
? [[<span key="d" className="text-muted-foreground">직접·알 수 없음</span>, direct]]
|
||||
: []),
|
||||
...(data.referrers ?? []).map((r) => [r.domain, r.views]),
|
||||
]}
|
||||
/>
|
||||
</Section>
|
||||
<Section title="기기">
|
||||
<Table
|
||||
|
||||
Reference in new issue
Block a user