mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04: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.
27 lines
711 B
TypeScript
27 lines
711 B
TypeScript
import { bottts, lorelei } from '@dicebear/collection';
|
|
import { createAvatar, type Style } from '@dicebear/core';
|
|
import { useMemo } from 'react';
|
|
import { getColor, getPastel } from '@/lib/colors';
|
|
|
|
export function Avatar({
|
|
seed,
|
|
size = 128,
|
|
isBot = false,
|
|
}: {
|
|
seed: string;
|
|
size?: number;
|
|
isBot?: boolean;
|
|
}) {
|
|
const backgroundColor = getPastel(getColor(seed), 4);
|
|
const style = (isBot ? bottts : lorelei) as Style<object>;
|
|
|
|
const avatar = useMemo(() => {
|
|
return createAvatar(style, {
|
|
seed,
|
|
size,
|
|
backgroundColor: [backgroundColor],
|
|
}).toDataUri();
|
|
}, [seed, isBot]);
|
|
|
|
return <img src={avatar} alt="Avatar" style={{ borderRadius: '100%', width: size }} />;
|
|
}
|