analytics: privacy-first search stats (Umami-style), #/stats page

- ui/analytics.js: cookie-less local-first tracker (localStorage), DNT/GPC
  honoured, opt-out switch, term sanitiser (email/@handle/long digits stripped),
  900ms debounce, caps 300 terms / 200 views / 120 days
- optional Umami-compatible beacon (window.AT_ANALYTICS endpoint+siteId),
  disabled by default: no third-party requests unless the owner configures it
- #/stats view: KPIs, 14-day CSS bar chart, top terms, top route/stop pages,
  no-result terms, privacy panel, JSON export, clear, opt-out
- hooks: busStop search apply(), stopDetail route filter, hashchange pageviews
- i18n th/en (395 keys each), credits section, sw.js precache + VERSION 2026.09.27.105
This commit is contained in:
Bkk1234 committed 2026-11-03 00:07:57 +07:00
1 parent 5381e0690a
commit 2504c39305
11 files changed
+850 -13

No files matched your search

+44 -3
View File
@@ -131,10 +131,10 @@
"stops.noOffset": "No travel time from the first stop yet",
"stops.noBusLine": "No bus line listed",
"stops.modeCode": "Search by stop code",
"stops.modeNear": "Near me",
"stops.modeNear": "Near me",
"stops.nearCta": "Use my location",
"stops.nearHint": "We ask your device for a location, then rank stops by real distance from their coordinates.",
"stops.modePlace": "Search by place name",
"stops.modePlace": "Search by place name",
"stops.codePh": "3+000",
"stops.codeHint": "Type 4 digits and the + sign is added automatically (e.g. 3000 → 3+000)",
"stops.codeHintBox": "Type digits in the boxes — empty boxes are filled with 0 automatically. For 4-digit codes such as 8+591, enter 08+591",
@@ -352,5 +352,46 @@
"credits.osmCredit": "OpenStreetMap © contributors (ODbL)",
"credits.facebookGroup": "Facebook group (web.facebook.com)",
"credits.from": "from",
"credits.routeN": "Route {n}"
"credits.routeN": "Route {n}",
"nav.stats": "Stats",
"page.stats": "Search stats",
"stats.title": "Search statistics on this device",
"stats.lead": "Only counts and search terms are kept — no cookies, no user id, no IP, and nothing leaves this device unless the site owner connects Umami.",
"stats.kpi.views": "Page views",
"stats.kpi.searches": "Searches",
"stats.kpi.terms": "Unique terms",
"stats.kpi.noResult": "No results",
"stats.chart.title": "Last 14 days",
"stats.chart.lead": "Solid bar = page views · light bar = searches",
"stats.terms.title": "Top search terms",
"stats.terms.lead": "Terms are sanitised — emails, phone numbers and long digit runs are stripped before saving",
"stats.terms.empty": "No searches on this device yet — try the stop search page, then come back",
"stats.views.title": "Most opened pages",
"stats.views.lead": "Counts route and stop detail pages only (not tied to any user)",
"stats.views.empty": "No data yet — open a route or stop detail once",
"stats.views.stopPrefix": "Stop {code}",
"stats.col.term": "Term",
"stats.col.count": "Hits",
"stats.col.last": "Last",
"stats.col.target": "Page",
"stats.noresult.title": "Searched, nothing found",
"stats.noresult.lead": "A signal that data is missing — these terms should exist if they are real routes",
"stats.privacy.title": "Privacy",
"stats.privacy.collect": "Stored: page-view counts · sanitised search terms · no-result counts · last-used time",
"stats.privacy.reject": "Not stored: IP · User-Agent · location · cookies · device id · cross-site history",
"stats.privacy.local": "Data lives in this browser's localStorage only — clear it anytime",
"stats.privacy.optoutTitle": "Turn off stats on this device",
"stats.privacy.optoutLead": "Switching this on stops recording immediately (existing numbers stay visible). Do Not Track / GPC are respected anyway.",
"stats.privacy.off": "Stats turned off — nothing new is recorded",
"stats.privacy.on": "Stats turned on",
"stats.btn.export": "Download data (JSON)",
"stats.btn.clear": "Clear data on this device",
"stats.clear.confirm": "Clear all stats on this device? This cannot be undone.",
"stats.clear.done": "Data cleared",
"stats.export.done": "File downloaded",
"stats.since": "Collecting since",
"credits.analyticsTitle": "Analytics — inspired by Umami",
"credits.analyticsBody": "The analytics layer is written here in",
"credits.analyticsBody2": "(no dependencies) — it borrows only the privacy-first approach and the /api/send payload shape from Umami; no Umami code is copied",
"credits.analyticsLocal": "Stats live in the user's browser only (localStorage) — view or clear them on the Stats page"
}
+44 -3
View File
@@ -131,10 +131,10 @@
"stops.noOffset": "ยังไม่ระบุเวลาเดินทางจากจุดแรก",
"stops.noBusLine": "ยังไม่ระบุสายรถ",
"stops.modeCode": "ค้นหาด้วยรหัสป้าย",
"stops.modeNear": "ป้ายใกล้ฉัน",
"stops.modeNear": "ป้ายใกล้ฉัน",
"stops.nearCta": "ขอพิกัดและหาป้ายใกล้ฉัน",
"stops.nearHint": "ระบบจะขอตำแหน่งจากเครื่อง แล้วคำนวณระยะจากพิกัดป้าย/ศาลารถ เรียงจากใกล้ไปไกล",
"stops.modePlace": "ค้นหาด้วยชื่อสถานที่",
"stops.modePlace": "ค้นหาด้วยชื่อสถานที่",
"stops.codePh": "3+000",
"stops.codeHint": "พิมพ์ตัวเลข 4 หลัก ระบบจะเติมเครื่องหมาย + ให้อัตโนมัติ (เช่น 3000 → 3+000)",
"stops.codeHintBox": "พิมพ์ตัวเลขในช่อง ระบบจะเติม 0 ให้อัตโนมัติเมื่อเว้นว่าง และถ้าเจอรหัส 4 หลัก เช่น 8+591 ให้กรอก 08+591",
@@ -352,5 +352,46 @@
"credits.osmCredit": "OpenStreetMap © ผู้มีส่วนร่วม (ODbL)",
"credits.facebookGroup": "กลุ่ม Facebook (web.facebook.com)",
"credits.from": "จาก",
"credits.routeN": "สาย {n}"
"credits.routeN": "สาย {n}",
"nav.stats": "สถิติ",
"page.stats": "สถิติการค้นหา",
"stats.title": "สถิติการค้นหาในเครื่องนี้",
"stats.lead": "เก็บเฉพาะจำนวนครั้งและคำที่ค้น — ไม่มีคุกกี้ ไม่มีรหัสผู้ใช้ ไม่เก็บ IP และไม่ส่งออกนอกเครื่อง เว้นแต่เจ้าของเว็บจะตั้งค่าเชื่อม Umami เอง",
"stats.kpi.views": "ครั้งที่เปิดหน้า",
"stats.kpi.searches": "ครั้งที่ค้นหา",
"stats.kpi.terms": "คำค้นต่างกัน",
"stats.kpi.noResult": "ค้นแล้วไม่พบ",
"stats.chart.title": "14 วันล่าสุด",
"stats.chart.lead": "แท่งเข้ม = เปิดหน้า · แท่งอ่อน = ค้นหา",
"stats.terms.title": "คำที่ค้นมากที่สุด",
"stats.terms.lead": "คำถูกทำให้ปลอดภัยแล้ว — ตัดอีเมล เบอร์โทร และเลขยาวออกก่อนบันทึก",
"stats.terms.empty": "ยังไม่มีคำค้นในเครื่องนี้ — ลองค้นหาป้ายที่หน้า “ป้ายหยุดรถ” แล้วกลับมาดู",
"stats.views.title": "หน้าที่ถูกเปิดบ่อย",
"stats.views.lead": "นับเฉพาะรายละเอียดสายรถและรายละเอียดป้าย (ไม่ผูกกับผู้ใช้)",
"stats.views.empty": "ยังไม่มีข้อมูล — เปิดรายละเอียดสายหรือป้ายสักครั้ง",
"stats.views.stopPrefix": "ป้าย {code}",
"stats.col.term": "คำค้น",
"stats.col.count": "ครั้ง",
"stats.col.last": "ล่าสุด",
"stats.col.target": "หน้า",
"stats.noresult.title": "ค้นแล้วไม่พบ",
"stats.noresult.lead": "สัญญาณว่าข้อมูลยังขาด — คำเหล่านี้ควรมีในระบบถ้าเป็นเส้นทางจริง",
"stats.privacy.title": "ความเป็นส่วนตัว",
"stats.privacy.collect": "เก็บ: จำนวนเปิดหน้า · คำที่ค้น (ตัดข้อมูลส่วนตัวออก) · จำนวนครั้งที่ค้นไม่พบ · เวลาล่าสุด",
"stats.privacy.reject": "ไม่เก็บ: IP · User-Agent · ตำแหน่ง · คุกกี้ · รหัสเครื่อง · ประวัติข้ามเว็บ",
"stats.privacy.local": "ข้อมูลอยู่ใน localStorage ของเบราว์เซอร์นี้เท่านั้น — ล้างได้ทุกเมื่อ",
"stats.privacy.optoutTitle": "ปิดการเก็บสถิติในเครื่องนี้",
"stats.privacy.optoutLead": "เปิดสวิตช์นี้ = หยุดบันทึกทันที (ยังดูตัวเลขเดิมได้) · ระบบเคารพ Do Not Track / GPC อยู่แล้ว",
"stats.privacy.off": "ปิดการเก็บสถิติแล้ว — ไม่มีการบันทึกใหม่",
"stats.privacy.on": "เปิดการเก็บสถิติแล้ว",
"stats.btn.export": "ดาวน์โหลดข้อมูล (JSON)",
"stats.btn.clear": "ล้างข้อมูลในเครื่อง",
"stats.clear.confirm": "ล้างสถิติทั้งหมดในเครื่องนี้? การลบย้อนกลับไม่ได้",
"stats.clear.done": "ล้างข้อมูลเรียบร้อย",
"stats.export.done": "ดาวน์โหลดไฟล์แล้ว",
"stats.since": "เริ่มเก็บเมื่อ",
"credits.analyticsTitle": "สถิติ — แนวคิดจาก Umami",
"credits.analyticsBody": "ระบบสถิติของเว็บนี้เขียนเองใน",
"credits.analyticsBody2": "(ไม่มี dependency) — ยืมเฉพาะแนวคิด privacy-first และรูปแบบ payload ของ Umami (/api/send) ไม่ได้คัดลอกโค้ดของ Umami มาใช้",
"credits.analyticsLocal": "ข้อมูลสถิติเก็บในเบราว์เซอร์ของผู้ใช้เท่านั้น (localStorage) — ดู/ล้างได้ที่หน้า “สถิติ”"
}