관리자 유입 통계 추가 v1.5.35

This commit is contained in:
2026-06-02 14:46:56 +09:00
parent 5b78a8c92f
commit 1bcd2f6898
15 changed files with 718 additions and 12 deletions

View File

@@ -6,6 +6,9 @@ import {
/** @type {string} 탭 단위 클라이언트 세션 storage 키 */
const CLIENT_SESSION_STORAGE_KEY = 'sori_analytics_client_session'
/** @type {string} 최초 유입 referrer storage 키 */
const INITIAL_REFERRER_STORAGE_KEY = 'sori_analytics_initial_referrer'
/** @type {number} 읽음 판정 최소 체류 시간(ms) */
const READ_MIN_DURATION_MS = 15000
@@ -73,6 +76,25 @@ const getClientSessionId = () => {
}
}
/**
* 탭 최초 유입 referrer를 반환한다.
* @returns {string} referrer
*/
const getInitialReferrer = () => {
try {
const existing = sessionStorage.getItem(INITIAL_REFERRER_STORAGE_KEY)
if (existing !== null) {
return existing
}
const created = String(document.referrer || '').trim()
sessionStorage.setItem(INITIAL_REFERRER_STORAGE_KEY, created)
return created
} catch {
return String(document.referrer || '').trim()
}
}
/**
* 게시물 상세 경로에서 slug를 추출한다.
* @param {import('vue-router').RouteLocationNormalizedLoaded} route - 현재 라우트
@@ -209,6 +231,8 @@ const sendPageviewEvent = (payload) => {
path: payload.path,
postSlug: payload.postSlug || '',
pageSlug: payload.pageSlug || '',
referrer: getInitialReferrer(),
currentUrl: window.location.href,
read: Boolean(payload.read)
})
}