feat: 访问埋点记录完整referer——支持推广渠道参数(src=xx)区分来源

This commit is contained in:
Hermes Agent
2026-09-17 17:10:24 +08:00
parent c549eb532d
commit 1f0b8e7740
2 changed files with 2 additions and 0 deletions
+1
View File
@@ -80,6 +80,7 @@ app.use('/api', (req, res, next) => {
const device = /Mobile|iPhone/i.test(ua) || (/Android/i.test(ua) && /Mobile/i.test(ua)) ? '移动端' : '桌面端' const device = /Mobile|iPhone/i.test(ua) || (/Android/i.test(ua) && /Mobile/i.test(ua)) ? '移动端' : '桌面端'
VisitLog.create({ VisitLog.create({
path: String(req.originalUrl || req.path).slice(0, 120), path: String(req.originalUrl || req.path).slice(0, 120),
referer: String(req.headers.referer || '').slice(0, 200),
source, source,
ip: req.ip || '', ip: req.ip || '',
os, browser, device, os, browser, device,
+1
View File
@@ -13,6 +13,7 @@ const VisitLogSchema = new Schema({
source: { type: String, default: '直接访问', index: true }, source: { type: String, default: '直接访问', index: true },
ip: { type: String, default: '', index: true }, ip: { type: String, default: '', index: true },
referer: { type: String, default: '' },
userId: { type: Schema.Types.ObjectId, ref: 'User', default: null }, userId: { type: Schema.Types.ObjectId, ref: 'User', default: null },