diff --git a/public/faq.html b/public/faq.html index 047aa3c..a36bce9 100644 --- a/public/faq.html +++ b/public/faq.html @@ -460,5 +460,23 @@

ADO2 홈 · 서비스 약관 · 개인정보처리방침

+ diff --git a/public/privacy.html b/public/privacy.html index 7b37217..365b125 100644 --- a/public/privacy.html +++ b/public/privacy.html @@ -30,6 +30,7 @@
  • YouTube Data API : AI가 생성한 콘텐츠를 YouTube에 업로드하기 위한 동영상 관리 권한
  • YouTube Analytics API : 채널 및 동영상의 조회수, 시청 시간 등 성과 지표 데이터 (읽기 전용)
  • 서비스 이용 과정에서 자동 수집: 접속 IP, 쿠키, 서비스 이용 기록
  • +
  • 쿠키 없는 익명 방문 통계: 서비스 개선을 위해 방문한 페이지, 유입 경로(직전 페이지의 도메인), 캠페인 링크 표시(utm_source), 기기 종류(PC·모바일·태블릿), 접속 시각을 수집합니다. 방문자를 구분하기 위한 쿠키나 브라우저 저장소는 사용하지 않으며, 접속 IP와 브라우저 정보는 매월 바뀌는 값과 함께 일방향 암호화(해시)한 값으로만 저장하고 IP 원문은 저장하지 않습니다. 이 정보는 방문 통계 산출에만 사용하며 개인을 식별하거나 광고·마케팅 목적으로 사용하지 않습니다.
  • 2. Google 사용자 데이터의 수집 및 이용 목적

    @@ -88,5 +89,23 @@

    본 방침은 2026년 5월 7일부터 시행됩니다. 최종 수정일: 2026년 5월 27일

    + \ No newline at end of file diff --git a/public/terms.html b/public/terms.html index af48571..63ce727 100644 --- a/public/terms.html +++ b/public/terms.html @@ -62,5 +62,23 @@

    본 약관은 2026년 5월 7일부터 시행됩니다.

    + \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index c7f417e..d97df51 100755 --- a/src/App.tsx +++ b/src/App.tsx @@ -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(NAV.HOME); diff --git a/src/utils/visitBeacon.ts b/src/utils/visitBeacon.ts new file mode 100644 index 0000000..f56104e --- /dev/null +++ b/src/utils/visitBeacon.ts @@ -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 | 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 | 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, + }); +}