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

+2
View File
@@ -25,6 +25,7 @@
credits: { partial: 'partials/credits.html', nav: '/credits', title: 'เครดิต', tkey: 'page.credits' },
about: { partial: 'partials/about.html', nav: '/about', title: 'เกี่ยวกับเรา', tkey: 'page.about' },
blog: { partial: 'partials/blog.html', nav: '/blog', title: 'บ่นไปเรื่อย', tkey: 'page.blog' },
stats: { partial: 'partials/stats.html', nav: '/stats', title: 'สถิติการค้นหา', tkey: 'page.stats' },
};
function parseHash() {
@@ -48,6 +49,7 @@
return { name: 'stops', params: {}, query: query };
}
if (seg[0] === 'credits') return { name: 'credits', params: {}, query: query };
if (seg[0] === 'stats') return { name: 'stats', params: {}, query: query };
if (seg[0] === 'about') return { name: 'about', params: {}, query: query };
if (seg[0] === 'blog') {
if (seg[1]) return { name: 'blog', params: { postId: decodeURIComponent(seg[1]) }, query: query };