Skip to content

Conversation

@Lokimorty
Copy link
Contributor

Problem

Automated bot sessions from known data center locations are visually indistinguishable from real user sessions in the Sessions UI, making analytics harder to interpret at a glance.

Solution

Detect sessions from known bot-hosting cities (Council Bluffs, Santa Clara, Ashburn, etc.) with zero session duration, and display them with robot avatars instead of human faces. Uses both conditions (city AND zero duration) to minimize false positives while reliably catching obvious bots.

Changes

  • Add isLikelyBot() detection utility in src/lib/botDetection.ts
  • Update Avatar component to support isBot prop with DiceBear's bottts style
  • Apply bot detection in SessionsTable and SessionProfile

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.
@vercel
Copy link

vercel bot commented Dec 7, 2025

@Lokimorty is attempting to deploy a commit to the umami-software Team on Vercel.

A member of the Team first needs to authorize it.

@Lokimorty Lokimorty changed the title Mark obvious bot sessions with robot avatars feat(sessions): mark obvious bot sessions with robot avatars Dec 7, 2025
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 7, 2025

Greptile Overview

Greptile Summary

Implemented visual bot detection by displaying robot avatars for sessions from known data center cities with zero duration.

  • Created isLikelyBot() utility combining city-based detection with zero-duration filtering to minimize false positives
  • Enhanced Avatar component to conditionally render DiceBear's bottts style for bot sessions
  • Applied bot detection across SessionsTable and SessionProfile components for consistent UI treatment
  • One minor style improvement suggested for useMemo dependency management

Confidence Score: 4/5

  • This PR is safe to merge with one minor style improvement recommended
  • The implementation is solid and logically sound with proper dual-condition bot detection. The only issue is a minor style concern with useMemo dependencies that won't affect runtime behavior
  • src/components/common/Avatar.tsx could benefit from moving computed values inside useMemo, but this is a style improvement rather than a critical issue

Important Files Changed

File Analysis

Filename Score Overview
src/lib/botDetection.ts 4/5 Added bot detection utility based on data center cities and zero session duration
src/components/common/Avatar.tsx 4/5 Updated to support bot avatars using DiceBear's bottts style, with potential useMemo dependency issue
src/app/(main)/websites/[websiteId]/sessions/SessionsTable.tsx 5/5 Integrated bot detection into session list view
src/app/(main)/websites/[websiteId]/sessions/SessionProfile.tsx 5/5 Applied bot detection to session profile avatar

Sequence Diagram

sequenceDiagram
    participant UI as SessionsTable/SessionProfile
    participant Avatar as Avatar Component
    participant BotDetect as isLikelyBot()
    participant DiceBear as DiceBear API
    
    UI->>BotDetect: isLikelyBot(session)
    BotDetect->>BotDetect: Check city in BOT_CITIES
    BotDetect->>BotDetect: Check firstAt === lastAt (zero duration)
    BotDetect-->>UI: return boolean (cityMatch && zeroDuration)
    
    UI->>Avatar: render(seed, size, isBot)
    Avatar->>Avatar: select style (bottts if bot, lorelei otherwise)
    Avatar->>DiceBear: createAvatar(style, seed, size, backgroundColor)
    DiceBear-->>Avatar: return avatar data URI
    Avatar-->>UI: render img element with avatar
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. src/components/common/Avatar.tsx, line 18-24 (link)

    style: style and backgroundColor are computed outside useMemo but used inside - ESLint exhaustive-deps rule may flag this

4 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant