- 推广链接 utm_* / from 在首页或登录页采集,localStorage 保存 30 天,first-touch 优先 - 注册时随 attribution 提交,服务端按白名单归类写入 user_acquisitions(迁移 091) - 无参数按来源站点域名归类,直接访问记 direct,仅邀约链接记 referral - 后台用户列表新增来源列与筛选,用户详情显示来源明细,仪表盘新增注册来源分布 - 首页跳转 /login 时保留查询参数,修复从首页进入丢失邀约码 ?ref= - 隐私政策补充来源统计说明;README / AGENTS / CHANGELOG 同步 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
21 lines
882 B
SQL
21 lines
882 B
SQL
-- 注册来源:记录用户第一次到站的推广参数与来源站点,供后台按平台统计注册与收入。
|
|
-- 单独建表而不给 users 加列:历史用户没有来源留空(后台显示「未知」),不影响 users 的大量 SELECT u.*。
|
|
CREATE TABLE IF NOT EXISTS user_acquisitions (
|
|
user_id uuid PRIMARY KEY REFERENCES users(id),
|
|
source text NOT NULL CHECK (source IN (
|
|
'xiaohongshu', 'douyin', 'bilibili', 'zhihu', 'wechat', 'weibo', 'github',
|
|
'search-baidu', 'search-google', 'search-bing', 'referral', 'direct', 'other'
|
|
)),
|
|
raw_source text,
|
|
medium text,
|
|
campaign text,
|
|
content text,
|
|
term text,
|
|
referrer_host text,
|
|
landing_path text,
|
|
first_touch_at timestamptz,
|
|
created_at timestamptz NOT NULL DEFAULT now()
|
|
);
|
|
CREATE INDEX IF NOT EXISTS user_acquisitions_source_created
|
|
ON user_acquisitions(source, created_at DESC);
|