feat: 사이트 방문 통계 비콘과 개인정보처리방침 문구 추가

This commit is contained in:
skkim committed 2026-10-20 13:51:37 +09:00
1 parent 2438ef2dd9
commit 526013058d
5 files changed
+155 -1

No files matched your search

+18
View File
@@ -460,5 +460,23 @@
</section>
<p style="margin-top:40px; font-size:14px; color:#999;"><a href="/">ADO2 홈</a> · <a href="/terms.html">서비스 약관</a> · <a href="/privacy.html">개인정보처리방침</a></p>
<script>
// 방문 통계 비콘(쿠키 없음) — src/utils/visitBeacon.ts 와 같은 규칙. 끄기: localStorage 'ado2.stats.disabled' = '1'
(function () {
var disabled = false;
try { disabled = localStorage.getItem('ado2.stats.disabled') === '1'; }
catch (e) { console.warn('[VisitBeacon] localStorage unavailable:', e); }
if (disabled || typeof navigator.sendBeacon !== 'function') return;
try {
navigator.sendBeacon('/api/track/view', JSON.stringify({
path: location.pathname,
referrer: document.referrer || null,
utm_source: new URLSearchParams(location.search).get('utm_source')
}));
} catch (e) {
console.warn('[VisitBeacon] send failed:', e);
}
})();
</script>
</body>
</html>
+19
View File
@@ -30,6 +30,7 @@
<li><strong>YouTube Data API :</strong> AI가 생성한 콘텐츠를 YouTube에 업로드하기 위한 동영상 관리 권한</li>
<li><strong>YouTube Analytics API :</strong> 채널 및 동영상의 조회수, 시청 시간 등 성과 지표 데이터 (읽기 전용)</li>
<li><strong>서비스 이용 과정에서 자동 수집:</strong> 접속 IP, 쿠키, 서비스 이용 기록</li>
<li><strong>쿠키 없는 익명 방문 통계:</strong> 서비스 개선을 위해 방문한 페이지, 유입 경로(직전 페이지의 도메인), 캠페인 링크 표시(utm_source), 기기 종류(PC·모바일·태블릿), 접속 시각을 수집합니다. 방문자를 구분하기 위한 쿠키나 브라우저 저장소는 사용하지 않으며, 접속 IP와 브라우저 정보는 매월 바뀌는 값과 함께 일방향 암호화(해시)한 값으로만 저장하고 IP 원문은 저장하지 않습니다. 이 정보는 방문 통계 산출에만 사용하며 개인을 식별하거나 광고·마케팅 목적으로 사용하지 않습니다.</li>
</ul>
<h2>2. Google 사용자 데이터의 수집 및 이용 목적</h2>
@@ -88,5 +89,23 @@
</ul>
<p style="margin-top:40px; font-size:14px; color:#999;">본 방침은 2026년 5월 7일부터 시행됩니다. 최종 수정일: 2026년 5월 27일</p>
<script>
// 방문 통계 비콘(쿠키 없음) — src/utils/visitBeacon.ts 와 같은 규칙. 끄기: localStorage 'ado2.stats.disabled' = '1'
(function () {
var disabled = false;
try { disabled = localStorage.getItem('ado2.stats.disabled') === '1'; }
catch (e) { console.warn('[VisitBeacon] localStorage unavailable:', e); }
if (disabled || typeof navigator.sendBeacon !== 'function') return;
try {
navigator.sendBeacon('/api/track/view', JSON.stringify({
path: location.pathname,
referrer: document.referrer || null,
utm_source: new URLSearchParams(location.search).get('utm_source')
}));
} catch (e) {
console.warn('[VisitBeacon] send failed:', e);
}
})();
</script>
</body>
</html>
+18
View File
@@ -62,5 +62,23 @@
</ul>
<p style="margin-top:40px; font-size:14px; color:#999;">본 약관은 2026년 5월 7일부터 시행됩니다.</p>
<script>
// 방문 통계 비콘(쿠키 없음) — src/utils/visitBeacon.ts 와 같은 규칙. 끄기: localStorage 'ado2.stats.disabled' = '1'
(function () {
var disabled = false;
try { disabled = localStorage.getItem('ado2.stats.disabled') === '1'; }
catch (e) { console.warn('[VisitBeacon] localStorage unavailable:', e); }
if (disabled || typeof navigator.sendBeacon !== 'function') return;
try {
navigator.sendBeacon('/api/track/view', JSON.stringify({
path: location.pathname,
referrer: document.referrer || null,
utm_source: new URLSearchParams(location.search).get('utm_source')
}));
} catch (e) {
console.warn('[VisitBeacon] send failed:', e);
}
})();
</script>
</body>
</html>
+9 -1
View File
@@ -8,8 +8,9 @@ import YouTubeOAuthCallback from './pages/Social/YouTubeOAuthCallback';
import VideoDetailPage from './components/VideoDetailPage';
import SsulDetailPage from './pages/Ssulbox/SsulDetailPage';
import P2vDetailPage from './pages/P2v/P2vDetailPage';
import { kakaoCallback, saveTokens, storeUtmFromUrl, trackViewContent, trackCompleteRegistration } from './utils/api';
import { API_URL, kakaoCallback, saveTokens, storeUtmFromUrl, trackViewContent, trackCompleteRegistration } from './utils/api';
import { clearSessionStorage } from './utils/storageKeys';
import { isBlockedInDev, sendVisitBeaconFromBrowser } from './utils/visitBeacon';
import { NAV } from './components/navItems';
const SESSION_KEY = 'castad_session_active';
@@ -28,6 +29,13 @@ const initializeOnNewSession = () => {
// 앱 시작 시 세션 체크
initializeOnNewSession();
// 방문 통계 비콘 — 콜백 처리가 URL 쿼리를 지우기 전에, 렌더(StrictMode 이중 실행)와 무관하게 페이지당 1번.
// 개발 서버에서는 보내지 않는다. 로컬 확인 때만 .env 에 VITE_TRAFFIC_BEACON_IN_DEV=true
sendVisitBeaconFromBrowser(
API_URL,
isBlockedInDev(import.meta.env.DEV, import.meta.env.VITE_TRAFFIC_BEACON_IN_DEV),
);
const App: React.FC = () => {
const { t } = useTranslation();
const [initialTab, setInitialTab] = useState<string>(NAV.HOME);
+91
View File
@@ -0,0 +1,91 @@
/**
* 사이트 방문 비콘 — 백엔드 `POST /track/view` 로 페이지 방문 1건을 보낸다.
*
* 쿠키·식별자를 남기지 않는다. 방문자 구분은 서버가 IP·UA·월로 만든 해시로만 한다
* (개인정보처리방침 "쿠키 없는 익명 방문 통계").
* 이 앱은 화면 이동이 모두 전체 페이지 로드라 페이지가 열릴 때 한 번만 보내면 된다.
* 로그인 콜백이 replaceState 로 쿼리를 지우기 전에 보내야 utm_source 가 남으므로 App 모듈 최상단에서 부른다.
*
* 운영자 본인 방문 제외: 그 브라우저 콘솔에서 localStorage.setItem('ado2.stats.disabled', '1')
*/
export const STATS_DISABLED_KEY = 'ado2.stats.disabled';
/** OAuth 콜백 화면 — 방문으로 치지 않는다(백엔드도 거른다) */
const EXCLUDED_PREFIXES = ['/social/'];
export interface VisitPayload {
path: string;
referrer: string | null;
utm_source: string | null;
}
export function buildVisitPayload(pathname: string, search: string, referrer: string): VisitPayload {
return {
path: pathname || '/',
referrer: referrer || null,
utm_source: new URLSearchParams(search).get('utm_source'),
};
}
export function isExcludedPath(pathname: string): boolean {
return EXCLUDED_PREFIXES.some((prefix) => pathname.startsWith(prefix));
}
export function isStatsDisabled(storage: Pick<Storage, 'getItem'> | undefined): boolean {
try {
return storage?.getItem(STATS_DISABLED_KEY) === '1';
} catch (error) {
// 저장소가 막힌 브라우저(사생활 보호 모드 등) — 끄기 설정을 못 읽을 뿐 방문은 센다
console.warn('[VisitBeacon] localStorage unavailable:', error);
return false;
}
}
export interface BeaconEnv {
pathname: string;
search: string;
referrer: string;
storage: Pick<Storage, 'getItem'> | undefined;
sendBeacon: ((url: string, data: string) => boolean) | undefined;
}
/**
* 개발 서버에서 비콘을 막을지. 기본은 막는다(새로고침마다 통계가 쌓이지 않게).
* 로컬에서 집계를 확인할 때만 `.env` 에 `VITE_TRAFFIC_BEACON_IN_DEV=true` 를 두고 개발 서버를 다시 띄운다.
*/
export function isBlockedInDev(isDev: boolean, enableInDev: unknown): boolean {
return isDev && String(enableInDev).trim().toLowerCase() !== 'true';
}
/** 보냈으면 true. 개발 서버(옵션으로 끄지 않은 경우)·제외 경로·끄기 설정·sendBeacon 미지원이면 보내지 않는다. */
export function sendVisitBeacon(apiUrl: string, blockedInDev: boolean, env: BeaconEnv): boolean {
if (blockedInDev || !env.sendBeacon) return false;
if (isExcludedPath(env.pathname) || isStatsDisabled(env.storage)) return false;
const body = JSON.stringify(buildVisitPayload(env.pathname, env.search, env.referrer));
try {
// 문자열 본문은 text/plain 단순 요청이라 CORS 사전 요청이 없다
return env.sendBeacon(`${apiUrl.replace(/\/$/, '')}/track/view`, body);
} catch (error) {
console.warn('[VisitBeacon] send failed:', error);
return false;
}
}
/** 브라우저 값으로 한 번 보낸다. */
export function sendVisitBeaconFromBrowser(apiUrl: string, blockedInDev: boolean): boolean {
let storage: Storage | undefined;
try {
storage = window.localStorage;
} catch (error) {
console.warn('[VisitBeacon] localStorage unavailable:', error);
}
return sendVisitBeacon(apiUrl, blockedInDev, {
pathname: window.location.pathname,
search: window.location.search,
referrer: document.referrer,
storage,
sendBeacon: typeof navigator.sendBeacon === 'function' ? navigator.sendBeacon.bind(navigator) : undefined,
});
}