umami/src/components/common/Avatar.tsx
Arthur Sepiol 5413ce5d61 Mark obvious bot sessions with robot avatars
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.
2025-12-07 20:35:38 +03:00

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 }} />;
}