Changeset 0f48411 in Klonkt
- Timestamp:
- 07/31/2026 10:52:04 AM (6 weeks ago)
- Branches:
- main
- Children:
- cae8ded
- Parents:
- 2a17f0a
- Files:
-
- 1 added
- 1 edited
-
src/services/StatsService.js (modified) (1 diff)
-
test/stats-bots.test.js (added)
Legend:
- Unmodified
- Added
- Removed
-
src/services/StatsService.js
r2a17f0a r0f48411 47 47 // Skip known bots/crawlers + link-preview fetchers + scripts so they don't inflate 48 48 // view/visitor-day counts. Empty UA = almost always automated. 49 const BOT_RE = /bot|crawl|spider|slurp|mediapartners|bingpreview|facebookexternalhit|whatsapp|telegram|discord|twitter|linkedin|embedly|pinterest|redditbot|applebot|petalbot|yandex|baidu|duckduckbot|semrush|ahrefs|mj12|dotbot|uptimerobot|pingdom|statuscake|headless|lighthouse|gptbot|claude|ccbot|perplexity|bytespider|amazonbot|googleother|google-read-aloud|python-requests|scrapy|curl|wget|axios|node-fetch|go-http|java\/|okhttp|libwww|httpclient /i;49 const BOT_RE = /bot|crawl|spider|slurp|mediapartners|bingpreview|facebookexternalhit|whatsapp|telegram|discord|twitter|linkedin|embedly|pinterest|redditbot|applebot|petalbot|yandex|baidu|duckduckbot|semrush|ahrefs|mj12|dotbot|uptimerobot|pingdom|statuscake|headless|lighthouse|gptbot|claude|ccbot|perplexity|bytespider|amazonbot|googleother|google-read-aloud|python-requests|scrapy|curl|wget|axios|node-fetch|go-http|java\/|okhttp|libwww|httpclient|mastodon|pleroma|akkoma|misskey|calckey|firefish|friendica|hubzilla|lemmy|pixelfed|peertube|gotosocial|honk|http\.rb|activitypub/i; 50 50 function isBot(req) { 51 51 const ua = (req && req.headers && req.headers['user-agent']) || ''; 52 52 if (!ua) return true; // empty UA = script/bot 53 // A signed request or an ActivityPub content-negotiation is BY DEFINITION a 54 // server fetching, not a reader (Robins vraag, 31-7): one boosted post made 55 // every fediverse instance's link-preview fetch count as a unique visitor. 56 const h = (req && req.headers) || {}; 57 if (h['signature']) return true; 58 if (/application\/(activity|ld)\+json/i.test(String(h['accept'] || ''))) return true; 53 59 return BOT_RE.test(ua); 54 60 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)