Files
Haewon KamandClaude Opus 5.5 fb14e530a1 feat: 문의 source 에 UTM·유입 경로를 붙인다(.webforai.kr 공용 쿠키)
- src/lib/attribution.ts: webforai-landing attr.js 와 같은 규칙·같은 쿠키(wfa_attr), 30일 마지막 비직접 방문
- main.tsx 에서 기록, submitLead 가 source 꼬리로 전송(분석 이벤트 값은 그대로)
- tests/attribution.test.ts (npm test)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 16:50:19 +09:00

22 lines
1.1 KiB
TypeScript

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), '');
});