mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Detect automated sessions from known data center cities (Council Bluffs, Santa Clara, Ashburn, etc.) with zero session duration, and display them with robot avatars instead of human faces. This provides an instant visual indicator in the Sessions UI without needing to inspect city/duration for each session. Uses both conditions (city match AND zero duration) to minimize false positives while reliably catching obvious bots.
25 lines
581 B
TypeScript
25 lines
581 B
TypeScript
const BOT_CITIES = [
|
|
'Council Bluffs',
|
|
'North Richland Hills',
|
|
'Santa Clara',
|
|
'Ashburn',
|
|
'The Dalles',
|
|
'Boardman',
|
|
'Quincy',
|
|
];
|
|
|
|
export function isLikelyBot(session: {
|
|
city?: string;
|
|
firstAt?: string | Date;
|
|
lastAt?: string | Date;
|
|
}): boolean {
|
|
const cityMatch =
|
|
session.city && BOT_CITIES.some(botCity => session.city?.toLowerCase() === botCity.toLowerCase());
|
|
|
|
const zeroDuration =
|
|
session.firstAt &&
|
|
session.lastAt &&
|
|
new Date(session.firstAt).getTime() === new Date(session.lastAt).getTime();
|
|
|
|
return !!(cityMatch && zeroDuration);
|
|
}
|