Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb14e530a1 | ||
|
|
5ca51d10b6 | ||
|
|
ba206322b7 | ||
|
|
998d609fd8 | ||
|
|
21340e767e | ||
|
|
29f798f3c7 | ||
|
|
6d2cefac91 | ||
|
|
1125f42324 |
No files matched your search
@@ -20,7 +20,10 @@
|
||||
const ALLOWED_ORIGINS = [
|
||||
'https://webforai.kr',
|
||||
'https://www.webforai.kr',
|
||||
'https://infinith.webforai.kr',
|
||||
'https://aio2o.webforai.kr',
|
||||
'https://www.o2osolution.ai',
|
||||
'https://o2osolution.ai',
|
||||
];
|
||||
|
||||
export default async function handler(req, res) {
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@
|
||||
"clean": "rm -rf dist",
|
||||
"lint": "tsc --noEmit",
|
||||
"db:sync": "tsx scripts/sync-db-local.ts",
|
||||
"sync-registry": "tsx scripts/import-registry.ts"
|
||||
"sync-registry": "tsx scripts/import-registry.ts",
|
||||
"test": "node --experimental-strip-types --no-warnings --test tests/*.test.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@google/genai": "^1.29.0",
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* 문의 유입 기록(UTM).
|
||||
*
|
||||
* webforai.kr·company·region(webforai-landing 저장소 site/assets/attr.js)과 같은 규칙·같은 쿠키(wfa_attr, Domain=.webforai.kr)를 쓴다.
|
||||
* 그래서 네이버 블로그 → infinith.webforai.kr → webforai.kr 처럼 서브도메인을 옮겨 다녀도 같은 기록이 남는다.
|
||||
*
|
||||
* 규칙: 마지막으로 들어온 '직접 방문이 아닌' 경로를 30일 기억(last non-direct touch).
|
||||
* - 주소에 utm_* 가 있으면 덮어쓴다
|
||||
* - utm 없이 외부 사이트(또는 광고 클릭 ID)로 왔으면, 살아 있는 utm 기록이 없을 때만 ref 로 남긴다
|
||||
* - 직접 방문·같은 사이트 안 이동은 기록을 바꾸지 않는다
|
||||
* 문의 함수로 보내는 source 뒤에 붙는다. 예: footer | utm:naver_blog/organic/2611_webforai_hospital | land:infinith.webforai.kr/
|
||||
*/
|
||||
|
||||
export const ATTR_KEY = 'wfa_attr';
|
||||
export const ATTR_TTL_MS = 30 * 24 * 60 * 60 * 1000;
|
||||
const UTM_KEYS = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'] as const;
|
||||
const CLICK_IDS = ['fbclid', 'gclid', 'NaPm'] as const;
|
||||
|
||||
export interface Attribution {
|
||||
utm?: Partial<Record<(typeof UTM_KEYS)[number], string>>;
|
||||
click?: string;
|
||||
ref?: string;
|
||||
land: string;
|
||||
at: number;
|
||||
}
|
||||
|
||||
const clean = (s: string) => s.replace(/[|\s]+/g, ' ').trim().slice(0, 60);
|
||||
const baseDomain = (h: string) => h.split('.').slice(-2).join('.');
|
||||
|
||||
export function nextAttribution(
|
||||
prev: Attribution | null,
|
||||
search: string,
|
||||
referrer: string,
|
||||
host: string,
|
||||
land: string,
|
||||
now: number,
|
||||
): Attribution | null {
|
||||
const q = new URLSearchParams(search);
|
||||
const utm: NonNullable<Attribution['utm']> = {};
|
||||
for (const k of UTM_KEYS) {
|
||||
const v = q.get(k);
|
||||
if (v) utm[k] = clean(v);
|
||||
}
|
||||
const click = CLICK_IDS.find((k) => q.has(k));
|
||||
const alive = prev && now - prev.at < ATTR_TTL_MS ? prev : null;
|
||||
if (Object.keys(utm).length) return { utm, click, land, at: now };
|
||||
|
||||
let refHost = '';
|
||||
try {
|
||||
refHost = referrer ? new URL(referrer).hostname : '';
|
||||
} catch {
|
||||
refHost = '';
|
||||
}
|
||||
const external = !!refHost && refHost !== host && baseDomain(refHost) !== baseDomain(host);
|
||||
if (alive?.utm) return null;
|
||||
if (click) return { click, ref: refHost || undefined, land, at: now };
|
||||
if (external) return { ref: refHost, land, at: now };
|
||||
return null;
|
||||
}
|
||||
|
||||
export function attributionSuffix(a: Attribution | null, now: number): string {
|
||||
if (!a || now - a.at >= ATTR_TTL_MS) return '';
|
||||
const parts: string[] = [];
|
||||
if (a.utm) {
|
||||
const u = a.utm;
|
||||
parts.push('utm:' + [u.utm_source ?? '-', u.utm_medium ?? '-', u.utm_campaign ?? '-'].join('/'));
|
||||
if (u.utm_content) parts.push('content:' + u.utm_content);
|
||||
if (u.utm_term) parts.push('term:' + u.utm_term);
|
||||
}
|
||||
if (a.click) parts.push('click:' + a.click);
|
||||
if (a.ref) parts.push('ref:' + a.ref);
|
||||
parts.push('land:' + a.land.slice(0, 80));
|
||||
return ' | ' + parts.join(' | ');
|
||||
}
|
||||
|
||||
function read(): Attribution | null {
|
||||
const m = document.cookie.match(new RegExp('(?:^|; )' + ATTR_KEY + '=([^;]*)'));
|
||||
if (!m) return null;
|
||||
try {
|
||||
return JSON.parse(decodeURIComponent(m[1])) as Attribution;
|
||||
} catch (e) {
|
||||
console.warn('[attribution] 유입 기록을 읽지 못했습니다', e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 앱 시작 때 한 번 부른다(main.tsx). SPA 라 첫 진입 주소에 utm 이 있다. */
|
||||
export function captureAttribution(): void {
|
||||
const host = location.hostname;
|
||||
const rec = nextAttribution(read(), location.search, document.referrer, host, host + location.pathname, Date.now());
|
||||
if (!rec) return;
|
||||
const domain = /(^|\.)webforai\.kr$/.test(host) ? '; Domain=.webforai.kr' : '';
|
||||
const secure = location.protocol === 'https:' ? '; Secure' : '';
|
||||
document.cookie = `${ATTR_KEY}=${encodeURIComponent(JSON.stringify(rec))}; Max-Age=${ATTR_TTL_MS / 1000}; Path=/${domain}; SameSite=Lax${secure}`;
|
||||
}
|
||||
|
||||
/** 문의 source 에 붙일 꼬리. */
|
||||
export function currentAttributionSuffix(): string {
|
||||
return attributionSuffix(read(), Date.now());
|
||||
}
|
||||
@@ -24,6 +24,8 @@ export interface LeadInput {
|
||||
website: string;
|
||||
}
|
||||
|
||||
import { currentAttributionSuffix } from './attribution';
|
||||
|
||||
export type LeadResult = { ok: true } | { ok: false; reason: 'failed' };
|
||||
|
||||
export async function submitLead(input: LeadInput): Promise<LeadResult> {
|
||||
@@ -31,7 +33,8 @@ export async function submitLead(input: LeadInput): Promise<LeadResult> {
|
||||
const res = await fetch('/api/lead', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(input),
|
||||
// 유입 경로(UTM 등)를 source 뒤에 붙인다. 화면 분석 이벤트에는 붙이지 않는다(ContactModal 은 원래 source 만 보냄)
|
||||
body: JSON.stringify({ ...input, source: input.source + currentAttributionSuffix() }),
|
||||
});
|
||||
const data = await res.json().catch(() => null);
|
||||
// 성공했다고 말할 근거가 없으면 실패로 둔다. 화면은 메일 폴백을 보여준다.
|
||||
|
||||
@@ -25,8 +25,11 @@ import PrivacyPage from './pages/PrivacyPage.tsx';
|
||||
import TermsPage from './pages/TermsPage.tsx';
|
||||
import SampleReportPage from './pages/SampleReportPage.tsx';
|
||||
import { DISCOVERY_SITE, SHOW_PRICING, SHOW_SAMPLE_REPORT } from './lib/site';
|
||||
import { captureAttribution } from './lib/attribution';
|
||||
import './index.css';
|
||||
|
||||
captureAttribution();
|
||||
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
|
||||
@@ -63,7 +63,9 @@
|
||||
"id": "lzx2z4cWJt0",
|
||||
"title": "[라스트닥터 3주년 인터뷰] 매출보다 직원행복 챙겼더니 일어난 3가지 변화",
|
||||
"published": "2026-10-10",
|
||||
"channel": "유튜브 @the_lastdoctor"
|
||||
"channel": "유튜브 @the_lastdoctor",
|
||||
"titleEn": "Third-anniversary interview: what changed after putting staff before revenue (in Korean)",
|
||||
"channelEn": "YouTube @the_lastdoctor"
|
||||
},
|
||||
"links": [
|
||||
{
|
||||
@@ -71,25 +73,37 @@
|
||||
"title": "모발설계자 문건학 원장 밀착인터뷰 _ 보이는 것 너머, 시간을 설계하다",
|
||||
"desc": "문건학 원장 인터뷰 원문을 블로그에서 읽을 수 있습니다.",
|
||||
"url": "https://blog.naver.com/all_artist/224436053883",
|
||||
"foot": "2026-10-09 게시 · blog.naver.com/all_artist"
|
||||
"foot": "2026-10-09 게시 · blog.naver.com/all_artist",
|
||||
"catEn": "Interview · Naver Blog",
|
||||
"titleEn": "In-depth interview with Dr. Kunhak Moon (in Korean)",
|
||||
"descEn": "Read the full interview with Dr. Kunhak Moon on the original blog.",
|
||||
"footEn": "Published 2026-10-09 · blog.naver.com/all_artist"
|
||||
},
|
||||
{
|
||||
"cat": "공식 블로그",
|
||||
"title": "모프로의원 네이버 블로그",
|
||||
"desc": "모발이식·탈모 치료 정보를 모프로의원이 직접 올리는 블로그입니다.",
|
||||
"url": "https://blog.naver.com/moprohair",
|
||||
"foot": "blog.naver.com/moprohair"
|
||||
"foot": "blog.naver.com/moprohair",
|
||||
"catEn": "Official Blog",
|
||||
"titleEn": "MOPRO Clinic Naver Blog (in Korean)",
|
||||
"descEn": "Hair transplant and hair loss treatment information posted by the clinic.",
|
||||
"footEn": "blog.naver.com/moprohair"
|
||||
},
|
||||
{
|
||||
"cat": "인스타그램",
|
||||
"title": "모프로의원 인스타그램",
|
||||
"desc": "모프로의원 공식 인스타그램 계정입니다.",
|
||||
"url": "https://www.instagram.com/moproclinic/",
|
||||
"foot": "@moproclinic"
|
||||
"foot": "@moproclinic",
|
||||
"catEn": "Instagram",
|
||||
"titleEn": "MOPRO Clinic Instagram",
|
||||
"descEn": "The clinic's official Instagram account.",
|
||||
"footEn": "@moproclinic"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_interviewNote": "2026-10-19 haewon 지시로 홈 'Interview' 섹션에 싣는다. 영상은 외부 채널(@the_lastdoctor) 인터뷰라 캡션에 그 채널을 밝힌다. 밀착인터뷰는 외부 에이전시 블로그(all_artist) 글이라 제목·링크만 싣고 본문은 옮기지 않는다(haewon 결정 2026-10-19). 게시일은 유튜브 uploadDate(2026-10-09 PDT)·블로그 게시 표기 실측. patch_site.py 가 src/data/interview.json 으로 쓴다.",
|
||||
"_interviewNote": "2026-10-19 haewon 지시로 홈 'Interview' 섹션에 싣는다. 영상은 외부 채널(@the_lastdoctor) 인터뷰라 캡션에 그 채널을 밝힌다. 밀착인터뷰는 외부 에이전시 블로그(all_artist) 글이라 제목·링크만 싣고 본문은 옮기지 않는다(haewon 결정 2026-10-19). 게시일은 유튜브 uploadDate(2026-10-09 PDT)·블로그 게시 표기 실측. patch_site.py 가 src/data/interview.json 으로 쓴다. 2026-10-19 영문 홈에도 싣는다(haewon 지시). *En 값은 Claude 번역 초안이며, 한국어 콘텐츠는 제목에 '(in Korean)'을 붙인다.",
|
||||
"footerChannels": [
|
||||
{
|
||||
"label": "유튜브",
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
2. 회복 일정 캘린더 파일 정보(PRODID·UID)에 남은 다른 병원 이름을 INFINITH·모프로로 바꾼다
|
||||
3. clinic.json excludeImages 에 해당하는 파일을 public/img 전체에서 지운다(워커는 img/clinic 만 지운다)
|
||||
3b. 영문 화면의 한글 노출을 정리한다(영문 사이트 이름·대표자·빈 값 문구, 팩트 시트 영문 값, 사진 없는 장소 이름 칸)
|
||||
3c. 홈에 'Interview' 섹션(원장 인터뷰 영상·인터뷰 글·공식 블로그·인스타그램)을 넣는다(clinic.json interview)
|
||||
3c. 한국어·영문 홈에 'Interview' 섹션(원장 인터뷰 영상·인터뷰 글·공식 블로그·인스타그램)을 넣는다(clinic.json interview)
|
||||
3d. 푸터에 채널 아이콘 줄(유튜브·인스타그램·블로그·카카오톡·플레이스·강남언니·바비톡)을 넣는다(clinic.json footerChannels)
|
||||
4. vercel.json 사이트 주소를 정식 주소로 넣고, 공유 이미지(og.jpg)를 '서포터즈' 없는 상단 문구로 다시 그린다
|
||||
5. src 에 화면용 '서포터즈'가 남아 있으면 실패로 끝낸다
|
||||
@@ -165,7 +165,36 @@ VIDEOLITE_REPLACEMENTS = [
|
||||
("const { id, title, speaker, published, note, compact = false } = Astro.props;",
|
||||
"const { id, title, speaker, published, note, compact = false, channel } = Astro.props;"),
|
||||
("{handle}{note ?", "{channel ?? handle}{note ?"),
|
||||
# 영문 홈에서 쓸 수 있게 lang='en' 이면 재생 버튼 설명·썸네일 대체 문구·게시일 표기를 영어로 낸다
|
||||
("channel?: string }", "channel?: string; lang?: string }"),
|
||||
("compact = false, channel }", "compact = false, channel, lang }"),
|
||||
("aria-label={`영상 재생: ${title}`}", "aria-label={lang === 'en' ? `Play video: ${title}` : `영상 재생: ${title}`}"),
|
||||
("alt={`유튜브 영상 썸네일: ${title}`}", "alt={lang === 'en' ? `YouTube video thumbnail: ${title}` : `유튜브 영상 썸네일: ${title}`}"),
|
||||
("{published ? `${published} 게시 · ` : ''}", "{published ? (lang === 'en' ? `Published ${published} · ` : `${published} 게시 · `) : ''}"),
|
||||
]
|
||||
# 영문 홈 Interview 섹션: Clinic Facts 아래, Principles 위. 값은 clinic.json interview 의 *En
|
||||
INTERVIEW_EN_ANCHOR = " <section class=\"section dark\"><div class=\"wrap-wide\">\n <div class=\"sec-head\"><div class=\"eyebrow\" style=\"color:var(--purple-300)\">Principles</div>"
|
||||
INTERVIEW_EN_SECTION = """ <section class="section light"><div class="wrap-wide">
|
||||
<div class="sec-head"><div class="eyebrow">Interview</div><h2>Meet The Doctor</h2><p class="sub">Interviews with Dr. Kunhak Moon and the clinic's official channels.</p></div>
|
||||
<div class="interview-grid">
|
||||
{interview.video && <div class="interview-video"><VideoLite id={interview.video.id} title={interview.video.titleEn} published={interview.video.published} channel={interview.video.channelEn} lang="en" /></div>}
|
||||
{interview.links.map((l) => (
|
||||
<article class="card">
|
||||
<div class="cat">{l.catEn}</div>
|
||||
<h3><a href={l.url} rel="noopener" target="_blank">{l.titleEn}</a></h3>
|
||||
<p>{l.descEn}</p>
|
||||
<div class="foot">{l.footEn}</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
<style>
|
||||
.interview-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1.25rem; }
|
||||
.interview-video { grid-row: span 3; align-self: start; }
|
||||
.interview-video :global(figure) { margin: 0; }
|
||||
@media (max-width: 860px) { .interview-grid { grid-template-columns: 1fr; } .interview-video { grid-row: auto; } }
|
||||
</style>
|
||||
</div></section>
|
||||
"""
|
||||
|
||||
|
||||
def patch_home_interview():
|
||||
@@ -178,17 +207,28 @@ def patch_home_interview():
|
||||
for old, new in VIDEOLITE_REPLACEMENTS:
|
||||
text = text.replace(old, new)
|
||||
open(vp, "w", encoding="utf-8").write(text)
|
||||
changed = 0
|
||||
ip = os.path.join(SITE, "src/pages/index.astro")
|
||||
text = open(ip, encoding="utf-8").read()
|
||||
if "data/interview.json" in text:
|
||||
return 0
|
||||
if INTERVIEW_ANCHOR not in text:
|
||||
sys.exit("index.astro 에서 Inside 섹션을 찾지 못해 Interview 섹션을 넣지 못함")
|
||||
text = text.replace("import Gallery from '../components/Gallery.astro';",
|
||||
"import Gallery from '../components/Gallery.astro';\nimport interview from '../data/interview.json';", 1)
|
||||
text = text.replace(INTERVIEW_ANCHOR, INTERVIEW_SECTION + INTERVIEW_ANCHOR, 1)
|
||||
open(ip, "w", encoding="utf-8").write(text)
|
||||
return 1
|
||||
if "data/interview.json" not in text:
|
||||
if INTERVIEW_ANCHOR not in text:
|
||||
sys.exit("index.astro 에서 Inside 섹션을 찾지 못해 Interview 섹션을 넣지 못함")
|
||||
text = text.replace("import Gallery from '../components/Gallery.astro';",
|
||||
"import Gallery from '../components/Gallery.astro';\nimport interview from '../data/interview.json';", 1)
|
||||
text = text.replace(INTERVIEW_ANCHOR, INTERVIEW_SECTION + INTERVIEW_ANCHOR, 1)
|
||||
open(ip, "w", encoding="utf-8").write(text)
|
||||
changed += 1
|
||||
ep = os.path.join(SITE, "src/pages/en/index.astro")
|
||||
text = open(ep, encoding="utf-8").read()
|
||||
if "data/interview.json" not in text:
|
||||
if INTERVIEW_EN_ANCHOR not in text:
|
||||
sys.exit("en/index.astro 에서 Principles 섹션을 찾지 못해 Interview 섹션을 넣지 못함")
|
||||
text = text.replace("import VisitMap from '../../components/VisitMap.astro';",
|
||||
"import VisitMap from '../../components/VisitMap.astro';\nimport VideoLite from '../../components/VideoLite.astro';\nimport interview from '../../data/interview.json';", 1)
|
||||
text = text.replace(INTERVIEW_EN_ANCHOR, INTERVIEW_EN_SECTION + INTERVIEW_EN_ANCHOR, 1)
|
||||
open(ep, "w", encoding="utf-8").write(text)
|
||||
changed += 1
|
||||
return changed
|
||||
|
||||
|
||||
# 푸터 채널 아이콘 (haewon 지시 2026-10-19). 유튜브·강남언니 글자 링크는 아이콘 줄로 옮기고 홈페이지 링크만 남긴다
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { nextAttribution, attributionSuffix, ATTR_TTL_MS } from '../src/lib/attribution.ts';
|
||||
|
||||
const NOW = 1_800_000_000_000;
|
||||
const H = 'infinith.webforai.kr';
|
||||
|
||||
test('utm 기록과 꼬리', () => {
|
||||
const a = nextAttribution(null, '?utm_source=naver_blog&utm_medium=organic&utm_campaign=2611_h', '', H, H + '/', NOW);
|
||||
assert.equal(attributionSuffix(a, NOW), ' | utm:naver_blog/organic/2611_h | land:infinith.webforai.kr/');
|
||||
});
|
||||
test('webforai.kr 에서 넘어온 것은 같은 사이트', () => {
|
||||
assert.equal(nextAttribution(null, '', 'https://webforai.kr/', H, H + '/', NOW), null);
|
||||
});
|
||||
test('외부 유입은 살아 있는 utm 을 덮지 않고, 없으면 ref', () => {
|
||||
const u = nextAttribution(null, '?utm_source=facebook', '', H, H + '/', NOW);
|
||||
assert.equal(nextAttribution(u, '', 'https://blog.naver.com/x', H, H + '/', NOW + 1), null);
|
||||
const r = nextAttribution(null, '', 'https://blog.naver.com/x', H, H + '/', NOW);
|
||||
assert.equal(attributionSuffix(r, NOW), ' | ref:blog.naver.com | land:infinith.webforai.kr/');
|
||||
assert.equal(attributionSuffix(r, NOW + ATTR_TTL_MS), '');
|
||||
});
|
||||
Reference in new issue
Block a user