fix: 排序作用于组内事件+时间线限高滚动+UTM别名归一消冲突误报
- attribution.py:新增 _canon 归一(小写/去协议与域名后缀/别名表 fb→facebook、百度→baidu 等/仅留字母数字汉字), 冲突判定改为两路各自归一后比较——同源升级 combined 并在 detail 记 utm_source 原文,仍不同才 conflict - detail.vue:orderedDays 组内会话/事件同步翻转(desc=组与组内都最新在前,asc=都最早在前); .tl-body 限高 calc(100vh - 380px) 卡内滚动,日期组头随内容滚动 - test_attribution.py:+4 用例(fb↔facebook、chatgpt.com↔ChatGPT、google↔facebook 仍冲突、百度↔baidu) Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -113,6 +113,38 @@ def test_utm_contradicting_referrer_is_conflict_with_both_evidences():
|
||||
assert utm_ev["platform"] == "google" and utm_ev["evidence_kind"] == "utm_label"
|
||||
|
||||
|
||||
# ------------------------------------------- 别名归一(消 conflict 误报)
|
||||
def test_utm_alias_fb_matches_facebook_referrer():
|
||||
r = classify(referrer_url="https://facebook.com/l/abc", utm={"utm_source": "fb"})
|
||||
assert r["resolution"] != "conflict" # fb↔Facebook 归一后同源,不是矛盾
|
||||
assert r["channel"] == "social" and r["platform"] == "Facebook"
|
||||
assert r["evidence_kind"] == "combined"
|
||||
assert r["detail"].get("utm_source") == "fb" # 归一对齐时原文并记进 detail
|
||||
|
||||
|
||||
def test_utm_with_domain_suffix_matches_bare_platform():
|
||||
r = classify(referrer_url="https://chatgpt.com/c/abc", utm={"utm_source": "chatgpt.com"})
|
||||
assert r["evidence_kind"] == "combined" # chatgpt.com → chatgpt 与 ChatGPT 同源
|
||||
assert r["platform"] == "ChatGPT"
|
||||
assert r["detail"].get("utm_source") == "chatgpt.com"
|
||||
r2 = classify(referrer_url="https://www.google.com/search?q=x",
|
||||
utm={"utm_source": "google.ru"}) # 国家域名后缀 → google
|
||||
assert r2["evidence_kind"] == "combined" and r2["platform"] == "Google"
|
||||
|
||||
|
||||
def test_utm_alias_still_conflict_when_platforms_differ():
|
||||
r = classify(referrer_url="https://facebook.com/l/abc", utm={"utm_source": "google"})
|
||||
assert r["resolution"] == "conflict" # 归一后仍不同 → 保持矛盾并列
|
||||
|
||||
|
||||
def test_utm_chinese_alias_baidu_matches():
|
||||
r = classify(referrer_url="https://www.baidu.com/s?wd=x", utm={"utm_source": "百度"})
|
||||
assert r["resolution"] != "conflict" # 百度 ↔ baidu.com(平台"百度") 同源
|
||||
assert r["channel"] == "natural_search" and r["platform"] == "百度"
|
||||
assert r["evidence_kind"] == "combined"
|
||||
assert r["detail"].get("utm_source") == "百度"
|
||||
|
||||
|
||||
def test_utm_only_is_label_only():
|
||||
r = classify(utm={"utm_source": "newsletter"})
|
||||
assert r["channel"] == "referral" # 未知标签 → 有名 referral,但状态诚实标注
|
||||
|
||||
Reference in New Issue
Block a user