Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

profile avatars, better UI, icons & fix aggregate info

Blue Mouse0fe906419535
diff --git a/backend/apps/cloud/src/analytics/analytics.controller.ts b/backend/apps/cloud/src/analytics/analytics.controller.ts
index 13b492b60..34fd1182e 100644
--- a/backend/apps/cloud/src/analytics/analytics.controller.ts
+++ b/backend/apps/cloud/src/analytics/analytics.controller.ts
@@ -1873,7 +1873,6 @@ export class AnalyticsController {
to,
filters,
timezone = DEFAULT_TIMEZONE,
- search,
profileType = 'all',
} = data
@@ -1938,7 +1937,6 @@ export class AnalyticsController {
safeTimezone,
take,
skip,
- search,
profileType,
)
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.ts
index ebf75b25c..effba3c1f 100644
--- a/backend/apps/cloud/src/analytics/analytics.service.ts
+++ b/backend/apps/cloud/src/analytics/analytics.service.ts
@@ -4294,7 +4294,6 @@ export class AnalyticsService {
safeTimezone: string,
take = 30,
skip = 0,
- search?: string,
profileType: 'all' | 'anonymous' | 'identified' = 'all',
): Promise<object[]> {
let profileTypeFilter = ''
@@ -4304,58 +4303,64 @@ export class AnalyticsService {
profileTypeFilter = `AND profileId LIKE '${AnalyticsService.PROFILE_PREFIX_USER}%'`
}
- let searchFilter = ''
- if (search) {
- searchFilter = `AND profileId LIKE '%${search}%'`
- }
-
const query = `
- WITH profile_sessions AS (
+ WITH profile_analytics AS (
SELECT
profileId,
- count() AS sessionsCount,
- sum(pageviews) AS pageviewsCount,
- sum(events) AS eventsCount,
- min(firstSeen) AS firstSeen,
- max(lastSeen) AS lastSeen
- FROM sessions FINAL
+ count() AS pageviewsCount,
+ countDistinct(psid) AS sessionsCount,
+ min(created) AS firstSeen,
+ max(created) AS lastSeen,
+ any(cc) AS cc,
+ any(os) AS os,
+ any(br) AS br,
+ any(dv) AS dv
+ FROM analytics
WHERE pid = {pid:FixedString(12)}
AND profileId IS NOT NULL
AND profileId != ''
${profileTypeFilter}
- ${searchFilter}
+ ${filtersQuery}
GROUP BY profileId
),
- profile_details AS (
+ profile_events AS (
SELECT
profileId,
- any(cc) AS cc,
- any(os) AS os,
- any(br) AS br,
- any(dv) AS dv
- FROM analytics
+ count() AS eventsCount
+ FROM customEV
+ WHERE pid = {pid:FixedString(12)}
+ AND profileId IS NOT NULL
+ AND profileId != ''
+ ${profileTypeFilter}
+ GROUP BY profileId
+ ),
+ profile_errors AS (
+ SELECT
+ profileId,
+ count() AS errorsCount
+ FROM errors
WHERE pid = {pid:FixedString(12)}
AND profileId IS NOT NULL
AND profileId != ''
${profileTypeFilter}
- ${searchFilter}
- ${filtersQuery}
GROUP BY profileId
)
SELECT
- ps.profileId,
- ps.sessionsCount,
- ps.pageviewsCount,
- ps.eventsCount,
- ps.firstSeen,
- ps.lastSeen,
- pd.cc,
- pd.os,
- pd.br,
- pd.dv
- FROM profile_sessions ps
- LEFT JOIN profile_details pd ON ps.profileId = pd.profileId
- ORDER BY ps.lastSeen DESC
+ pa.profileId AS profileId,
+ pa.sessionsCount AS sessionsCount,
+ pa.pageviewsCount AS pageviewsCount,
+ COALESCE(pe.eventsCount, 0) AS eventsCount,
+ COALESCE(perr.errorsCount, 0) AS errorsCount,
+ pa.firstSeen AS firstSeen,
+ pa.lastSeen AS lastSeen,
+ pa.cc AS cc,
+ pa.os AS os,
+ pa.br AS br,
+ pa.dv AS dv
+ FROM profile_analytics AS pa
+ LEFT JOIN profile_events AS pe ON pa.profileId = pe.profileId
+ LEFT JOIN profile_errors AS perr ON pa.profileId = perr.profileId
+ ORDER BY pa.lastSeen DESC
LIMIT ${take}
OFFSET ${skip}
`
@@ -4367,10 +4372,12 @@ export class AnalyticsService {
})
.then(resultSet => resultSet.json())
- return data.map((profile: any) => ({
- ...profile,
- isIdentified: this.isUserSuppliedProfile(profile.profileId),
- }))
+ return data
+ .filter((profile: any) => profile.profileId)
+ .map((profile: any) => ({
+ ...profile,
+ isIdentified: this.isUserSuppliedProfile(profile.profileId),
+ }))
}
async getProfileDetails(
@@ -4378,18 +4385,34 @@ export class AnalyticsService {
profileId: string,
_safeTimezone: string,
): Promise<any> {
- // Query sessions for session count and duration
- const querySessionStats = `
+ // Query session count from sessions table
+ const querySessionCount = `
SELECT
count() AS sessionsCount,
min(sessions.firstSeen) AS firstSeen,
- max(sessions.lastSeen) AS lastSeen,
- avg(dateDiff('second', sessions.firstSeen, sessions.lastSeen)) AS avgDuration
+ max(sessions.lastSeen) AS lastSeen
FROM sessions FINAL
WHERE pid = {pid:FixedString(12)}
AND profileId = {profileId:String}
`
+ // Query avg duration from analytics table (more accurate than sessions table)
+ const queryAvgDuration = `
+ SELECT
+ avg(session_duration) AS avgDuration
+ FROM (
+ SELECT
+ psid,
+ dateDiff('second', min(created), max(created)) AS session_duration
+ FROM analytics
+ WHERE pid = {pid:FixedString(12)}
+ AND profileId = {profileId:String}
+ AND psid IS NOT NULL
+ GROUP BY psid
+ HAVING session_duration > 0
+ )
+ `
+
// Query analytics for accurate pageview count
const queryPageviews = `
SELECT count() AS pageviewsCount
@@ -4425,26 +4448,35 @@ export class AnalyticsService {
const params = { pid, profileId }
- const [sessionStatsResult, pageviewsResult, eventsResult, detailsResult] =
- await Promise.all([
- clickhouse
- .query({ query: querySessionStats, query_params: params })
- .then(resultSet => resultSet.json()),
- clickhouse
- .query({ query: queryPageviews, query_params: params })
- .then(resultSet => resultSet.json()),
- clickhouse
- .query({ query: queryEvents, query_params: params })
- .then(resultSet => resultSet.json()),
- clickhouse
- .query({ query: queryDetails, query_params: params })
- .then(resultSet => resultSet.json()),
- ])
-
- const sessionStats = (sessionStatsResult.data[0] || {}) as Record<
+ const [
+ sessionCountResult,
+ avgDurationResult,
+ pageviewsResult,
+ eventsResult,
+ detailsResult,
+ ] = await Promise.all([
+ clickhouse
+ .query({ query: querySessionCount, query_params: params })
+ .then(resultSet => resultSet.json()),
+ clickhouse
+ .query({ query: queryAvgDuration, query_params: params })
+ .then(resultSet => resultSet.json()),
+ clickhouse
+ .query({ query: queryPageviews, query_params: params })
+ .then(resultSet => resultSet.json()),
+ clickhouse
+ .query({ query: queryEvents, query_params: params })
+ .then(resultSet => resultSet.json()),
+ clickhouse
+ .query({ query: queryDetails, query_params: params })
+ .then(resultSet => resultSet.json()),
+ ])
+
+ const sessionCount = (sessionCountResult.data[0] || {}) as Record<
string,
any
>
+ const avgDuration = (avgDurationResult.data[0] || {}) as Record<string, any>
const pageviews = (pageviewsResult.data[0] || {}) as Record<string, any>
const events = (eventsResult.data[0] || {}) as Record<string, any>
const details = (detailsResult.data[0] || {}) as Record<string, any>
@@ -4452,12 +4484,12 @@ export class AnalyticsService {
return {
profileId,
isIdentified: this.isUserSuppliedProfile(profileId),
- sessionsCount: sessionStats.sessionsCount || 0,
+ sessionsCount: sessionCount.sessionsCount || 0,
pageviewsCount: pageviews.pageviewsCount || 0,
eventsCount: events.eventsCount || 0,
- firstSeen: sessionStats.firstSeen,
- lastSeen: sessionStats.lastSeen,
- avgDuration: sessionStats.avgDuration || 0,
+ firstSeen: sessionCount.firstSeen,
+ lastSeen: sessionCount.lastSeen,
+ avgDuration: avgDuration.avgDuration || 0,
...details,
}
}
diff --git a/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts b/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts
index e51c98a23..e786f7bc6 100644
--- a/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts
+++ b/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts
@@ -18,13 +18,6 @@ export class GetProfilesDto extends PickType(GetDataDto, [
@IsOptional()
skip?: number
- @ApiProperty({
- required: false,
- description: 'Search by profileId or display name',
- })
- @IsOptional()
- search?: string
-
@ApiProperty({
required: false,
description: 'Filter by profile type',
diff --git a/web/app/api/index.ts b/web/app/api/index.ts
index fd6d3c857..7c6a19b0d 100644
--- a/web/app/api/index.ts
+++ b/web/app/api/index.ts
@@ -675,7 +675,6 @@ export const getProfiles = (
take = 30,
skip = 0,
timezone = '',
- search = '',
profileType: 'all' | 'anonymous' | 'identified' = 'all',
password: string | undefined = '',
) =>
@@ -683,7 +682,7 @@ export const getProfiles = (
.get(
`log/profiles?pid=${pid}&take=${take}&skip=${skip}&period=${period}&filters=${JSON.stringify(
filters,
- )}&from=${from}&to=${to}&timezone=${timezone}&search=${search}&profileType=${profileType}`,
+ )}&from=${from}&to=${to}&timezone=${timezone}&profileType=${profileType}`,
{
headers: {
'x-password': password,
diff --git a/web/app/lib/constants/index.ts b/web/app/lib/constants/index.ts
index c2e72e5c1..bd8422511 100644
--- a/web/app/lib/constants/index.ts
+++ b/web/app/lib/constants/index.ts
@@ -481,7 +481,7 @@ const SELFHOSTED_PROJECT_TABS = {
const PRODUCTION_PROJECT_TABS = {
traffic: 'traffic',
performance: 'performance',
- users: 'users',
+ profiles: 'profiles',
funnels: 'funnels',
sessions: 'sessions',
errors: 'errors',
diff --git a/web/app/lib/models/Project.ts b/web/app/lib/models/Project.ts
index b6e894eca..5e5420159 100644
--- a/web/app/lib/models/Project.ts
+++ b/web/app/lib/models/Project.ts
@@ -125,6 +125,7 @@ export interface Profile {
sessionsCount: number
pageviewsCount: number
eventsCount: number
+ errorsCount: number
firstSeen: string
lastSeen: string
cc: string | null
diff --git a/web/app/pages/Project/View/ViewProject.helpers.tsx b/web/app/pages/Project/View/ViewProject.helpers.tsx
index a5f1106c6..b48b7b43a 100644
--- a/web/app/pages/Project/View/ViewProject.helpers.tsx
+++ b/web/app/pages/Project/View/ViewProject.helpers.tsx
@@ -1666,7 +1666,7 @@ const getFormatDate = (date: Date) => {
const SHORTCUTS_TABS_MAP = {
T: PROJECT_TABS.traffic,
P: PROJECT_TABS.performance,
- U: PROJECT_TABS.users,
+ U: PROJECT_TABS.profiles,
F: PROJECT_TABS.funnels,
S: PROJECT_TABS.sessions,
A: PROJECT_TABS.alerts,
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index ec409b412..77542295a 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -193,11 +193,11 @@ import SearchFilters, { getFiltersUrlParams } from './components/SearchFilters'
import { SessionChart } from './components/SessionChart'
import { SessionDetails } from './components/SessionDetails'
import { Sessions } from './components/Sessions'
-import { Users, UsersFilter } from './components/Users'
-import { UserDetails } from './components/UserDetails'
import TBPeriodSelector from './components/TBPeriodSelector'
import { TrafficChart } from './components/TrafficChart'
+import { UserDetails } from './components/UserDetails'
import UserFlow from './components/UserFlow'
+import { Users, UsersFilter } from './components/Users'
import WaitingForAnError from './components/WaitingForAnError'
import WaitingForAnEvent from './components/WaitingForAnEvent'
import {
@@ -699,7 +699,6 @@ const ViewProjectContent = () => {
const [profileSessionsSkip, setProfileSessionsSkip] = useState(0)
const [canLoadMoreProfileSessions, setCanLoadMoreProfileSessions] = useState(false)
const [profileTypeFilter, setProfileTypeFilter] = useState<'all' | 'anonymous' | 'identified'>('all')
- const [profileSearch, setProfileSearch] = useState('')
const activeProfileId = useMemo(() => {
return searchParams.get('profileId')
}, [searchParams])
@@ -1470,8 +1469,8 @@ const ViewProjectContent = () => {
icon: GaugeIcon,
},
{
- id: PROJECT_TABS.users,
- label: t('dashboard.users'),
+ id: PROJECT_TABS.profiles,
+ label: t('dashboard.profiles'),
icon: UserIcon,
},
{
@@ -2125,7 +2124,6 @@ const ViewProjectContent = () => {
SESSIONS_TAKE,
skip,
timezone,
- profileSearch,
profileTypeFilter,
projectPassword,
)
@@ -2139,7 +2137,6 @@ const ViewProjectContent = () => {
SESSIONS_TAKE,
skip,
timezone,
- profileSearch,
profileTypeFilter,
projectPassword,
)
@@ -2638,11 +2635,22 @@ const ViewProjectContent = () => {
return
}
+ if (activeTab === PROJECT_TABS.profiles) {
+ if (activeProfileId) {
+ await loadProfile(activeProfileId)
+ return
+ }
+
+ resetProfiles()
+ loadProfiles(0)
+ return
+ }
+
loadAnalytics()
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps
- [authLoading, dataLoading, activeTab, activePSID, activeEID],
+ [authLoading, dataLoading, activeTab, activePSID, activeEID, activeProfileId],
)
useEffect(() => {
@@ -2759,7 +2767,7 @@ const ViewProjectContent = () => {
// Load profiles list when users tab is active
useEffect(() => {
- if (authLoading || activeTab !== PROJECT_TABS.users || !project || activeProfileId) {
+ if (authLoading || activeTab !== PROJECT_TABS.profiles || !project || activeProfileId) {
return
}
@@ -2782,7 +2790,6 @@ const ViewProjectContent = () => {
project,
activeProfileId,
profileTypeFilter,
- profileSearch,
])
// Load single profile when profileId is set
@@ -3864,7 +3871,7 @@ const ViewProjectContent = () => {
)}
</div>
) : null}
- {activeTab === PROJECT_TABS.users && !activeProfileId ? (
+ {activeTab === PROJECT_TABS.profiles && !activeProfileId ? (
<>
<UsersFilter
profileType={profileTypeFilter}
@@ -3872,11 +3879,6 @@ const ViewProjectContent = () => {
setProfileTypeFilter(type)
resetProfiles()
}}
- search={profileSearch}
- onSearchChange={(search) => {
- setProfileSearch(search)
- resetProfiles()
- }}
/>
{(profilesLoading === null || profilesLoading) && _isEmpty(profiles) ? <Loader /> : null}
{typeof profilesLoading === 'boolean' && !profilesLoading && _isEmpty(profiles) ? (
@@ -3902,7 +3904,7 @@ const ViewProjectContent = () => {
) : null}
</>
) : null}
- {activeTab === PROJECT_TABS.users && activeProfileId ? (
+ {activeTab === PROJECT_TABS.profiles && activeProfileId ? (
<>
<div className='mx-auto mt-2 mb-4 flex max-w-max items-center space-x-4 lg:mx-0'>
<Link
diff --git a/web/app/pages/Project/View/components/UserDetails.tsx b/web/app/pages/Project/View/components/UserDetails.tsx
index e40358383..0be9f7522 100644
--- a/web/app/pages/Project/View/components/UserDetails.tsx
+++ b/web/app/pages/Project/View/components/UserDetails.tsx
@@ -1,9 +1,6 @@
-import cx from 'clsx'
import dayjs from 'dayjs'
import _capitalize from 'lodash/capitalize'
import _isEmpty from 'lodash/isEmpty'
-import { useMemo } from 'react'
-import { useTranslation } from 'react-i18next'
import {
EyeIcon,
SparklesIcon,
@@ -15,190 +12,20 @@ import {
TabletIcon,
GlobeIcon,
} from 'lucide-react'
+import { useMemo } from 'react'
+import { useTranslation } from 'react-i18next'
+import { BROWSER_LOGO_MAP, OS_LOGO_MAP, OS_LOGO_MAP_DARK } from '~/lib/constants'
import { ProfileDetails as ProfileDetailsType, Session } from '~/lib/models/Project'
-import { getLocaleDisplayName, getStringFromTime, getTimeFromSeconds } from '~/utils/generic'
+import { useTheme } from '~/providers/ThemeProvider'
+import Button from '~/ui/Button'
import Loader from '~/ui/Loader'
+import { cn, getLocaleDisplayName, getStringFromTime, getTimeFromSeconds } from '~/utils/generic'
+import { getProfileDisplayName, ProfileAvatar } from '~/utils/profileAvatars'
import CCRow from './CCRow'
-import { Sessions } from './Sessions'
import { SessionChart } from './SessionChart'
-
-// Generate display names for anonymous users
-const ADJECTIVES = [
- 'Amber',
- 'Azure',
- 'Beige',
- 'Black',
- 'Blue',
- 'Bronze',
- 'Brown',
- 'Coral',
- 'Crimson',
- 'Cyan',
- 'Emerald',
- 'Fuchsia',
- 'Gold',
- 'Gray',
- 'Green',
- 'Indigo',
- 'Ivory',
- 'Jade',
- 'Lavender',
- 'Lime',
- 'Magenta',
- 'Maroon',
- 'Mint',
- 'Navy',
- 'Olive',
- 'Orange',
- 'Peach',
- 'Pink',
- 'Plum',
- 'Purple',
- 'Red',
- 'Rose',
- 'Ruby',
- 'Salmon',
- 'Sapphire',
- 'Scarlet',
- 'Silver',
- 'Slate',
- 'Teal',
- 'Turquoise',
- 'Violet',
- 'White',
- 'Yellow',
-]
-
-const NOUNS = [
- 'Albatross',
- 'Ant',
- 'Badger',
- 'Bear',
- 'Beaver',
- 'Bison',
- 'Butterfly',
- 'Camel',
- 'Cardinal',
- 'Cat',
- 'Cheetah',
- 'Cobra',
- 'Condor',
- 'Coyote',
- 'Crane',
- 'Crow',
- 'Deer',
- 'Dolphin',
- 'Dove',
- 'Dragon',
- 'Eagle',
- 'Elephant',
- 'Elk',
- 'Falcon',
- 'Ferret',
- 'Finch',
- 'Flamingo',
- 'Fox',
- 'Frog',
- 'Gazelle',
- 'Giraffe',
- 'Goat',
- 'Goose',
- 'Gorilla',
- 'Hamster',
- 'Hare',
- 'Hawk',
- 'Hedgehog',
- 'Heron',
- 'Hippo',
- 'Horse',
- 'Hummingbird',
- 'Hyena',
- 'Iguana',
- 'Jaguar',
- 'Jay',
- 'Kangaroo',
- 'Koala',
- 'Lemur',
- 'Leopard',
- 'Lion',
- 'Llama',
- 'Lobster',
- 'Lynx',
- 'Macaw',
- 'Meerkat',
- 'Mongoose',
- 'Moose',
- 'Moth',
- 'Mouse',
- 'Narwhal',
- 'Newt',
- 'Octopus',
- 'Orca',
- 'Ostrich',
- 'Otter',
- 'Owl',
- 'Panda',
- 'Panther',
- 'Parrot',
- 'Peacock',
- 'Pelican',
- 'Penguin',
- 'Phoenix',
- 'Pig',
- 'Pigeon',
- 'Piranha',
- 'Pony',
- 'Porcupine',
- 'Puma',
- 'Quail',
- 'Rabbit',
- 'Raccoon',
- 'Raven',
- 'Rhino',
- 'Robin',
- 'Salamander',
- 'Salmon',
- 'Seal',
- 'Shark',
- 'Sheep',
- 'Sloth',
- 'Snail',
- 'Snake',
- 'Sparrow',
- 'Spider',
- 'Squirrel',
- 'Stork',
- 'Swan',
- 'Tiger',
- 'Toucan',
- 'Trout',
- 'Turtle',
- 'Viper',
- 'Vulture',
- 'Walrus',
- 'Weasel',
- 'Whale',
- 'Wolf',
- 'Wombat',
- 'Woodpecker',
- 'Yak',
- 'Zebra',
-]
-
-const generateDisplayName = (profileId: string): string => {
- let hash = 0
- for (let i = 0; i < profileId.length; i++) {
- const char = profileId.charCodeAt(i)
- hash = (hash << 5) - hash + char
- hash = hash & hash
- }
- hash = Math.abs(hash)
- const adjIndex = hash % ADJECTIVES.length
- const nounIndex = Math.floor(hash / ADJECTIVES.length) % NOUNS.length
- return `${ADJECTIVES[adjIndex]} ${NOUNS[nounIndex]}`
-}
+import { Sessions } from './Sessions'
interface UserDetailsProps {
details: ProfileDetailsType | null
@@ -292,7 +119,7 @@ const ActivityCalendar = ({ data }: { data: { date: string; count: number }[] })
{week.map((day, dayIdx) => (
<div
key={dayIdx}
- className={cx('h-2 w-2 rounded-[2px]', getColor(day.count))}
+ className={cn('h-2 w-2 rounded-[2px]', getColor(day.count))}
title={`${day.date}: ${day.count} ${t('dashboard.pageviews').toLowerCase()}`}
/>
))}
@@ -306,7 +133,7 @@ const ActivityCalendar = ({ data }: { data: { date: string; count: number }[] })
// Stat Item Component
const StatItem = ({ icon, label, value }: { icon: React.ReactNode; label: string; value: string | number }) => (
<div>
- <div className='mb-0.5 flex items-center gap-1.5 text-[10px] font-medium tracking-wide text-gray-400 uppercase'>
+ <div className='mb-0.5 flex items-center gap-1.5 text-[10px] font-medium tracking-wide text-gray-600 uppercase dark:text-gray-400'>
{icon}
{label}
</div>
@@ -317,7 +144,7 @@ const StatItem = ({ icon, label, value }: { icon: React.ReactNode; label: string
// Info Row Component for Location & Device
const InfoRow = ({ label, value }: { label: string; value: React.ReactNode }) => (
<div className='flex items-center justify-between border-b border-gray-100 py-2 last:border-0 dark:border-slate-700/50'>
- <span className='text-sm text-gray-500 dark:text-gray-400'>{label}</span>
+ <span className='text-sm text-gray-600 dark:text-gray-400'>{label}</span>
<span className='flex items-center gap-1.5 text-sm font-medium text-gray-900 dark:text-white'>{value}</span>
</div>
)
@@ -330,10 +157,30 @@ const DeviceIcon = ({ device }: { device: string | null }) => {
return <MonitorIcon className='h-4 w-4' />
}
-// Browser Icon Component (simplified - using globe as fallback)
+// Browser Icon Component
const BrowserIcon = ({ browser }: { browser: string | null }) => {
- // Could add specific browser icons here
- return <GlobeIcon className='h-4 w-4' />
+ if (!browser) return <GlobeIcon className='h-4 w-4' />
+
+ const logoUrl = BROWSER_LOGO_MAP[browser as keyof typeof BROWSER_LOGO_MAP]
+
+ if (!logoUrl) return <GlobeIcon className='h-4 w-4' />
+
+ return <img src={logoUrl} className='h-4 w-4' alt='' />
+}
+
+// OS Icon Component
+const OSIcon = ({ os, theme }: { os: string | null; theme: string }) => {
+ if (!os) return <GlobeIcon className='h-4 w-4' />
+
+ const logoPathLight = OS_LOGO_MAP[os as keyof typeof OS_LOGO_MAP]
+ const logoPathDark = OS_LOGO_MAP_DARK[os as keyof typeof OS_LOGO_MAP_DARK]
+
+ let logoPath = theme === 'dark' ? logoPathDark : logoPathLight
+ logoPath ||= logoPathLight
+
+ if (!logoPath) return <GlobeIcon className='h-4 w-4' />
+
+ return <img src={`/${logoPath}`} className='h-4 w-4' alt='' />
}
export const UserDetails = ({
@@ -349,23 +196,11 @@ export const UserDetails = ({
t,
i18n: { language },
} = useTranslation('common')
+ const { theme } = useTheme()
const displayName = useMemo(() => {
if (!details) return ''
- if (details.isIdentified) {
- const userId = details.profileId.replace('usr_', '')
- return userId.length <= 20 ? userId : `${userId.substring(0, 17)}...`
- }
- return generateDisplayName(details.profileId)
- }, [details])
-
- const avatarColor = useMemo(() => {
- if (!details) return 'hsl(0, 0%, 50%)'
- let hash = 0
- for (let i = 0; i < details.profileId.length; i++) {
- hash = details.profileId.charCodeAt(i) + ((hash << 5) - hash)
- }
- return `hsl(${Math.abs(hash) % 360}, 55%, 50%)`
+ return getProfileDisplayName(details.profileId, details.isIdentified)
}, [details])
const formatDate = (date: string | undefined) => {
@@ -390,15 +225,10 @@ export const UserDetails = ({
<div className='space-y-6'>
{/* Header */}
<div className='flex items-center gap-4'>
- <div
- className='flex h-14 w-14 shrink-0 items-center justify-center rounded-full text-2xl'
- style={{ backgroundColor: avatarColor }}
- >
- <span className='text-white'>:)</span>
- </div>
+ <ProfileAvatar profileId={details.profileId} size={56} className='shrink-0' />
<div>
<h2 className='text-2xl font-bold text-gray-900 dark:text-white'>{displayName}</h2>
- <code className='text-sm text-gray-400'>{details.profileId.substring(0, 12)}</code>
+ <code className='text-sm text-gray-400'>{details.profileId}</code>
</div>
</div>
@@ -444,7 +274,7 @@ export const UserDetails = ({
{/* Location & Device Card */}
<div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>
- <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-500 uppercase dark:text-gray-400'>
+ <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>
{t('project.locationAndDevice')}
</h3>
<div>
@@ -452,7 +282,7 @@ export const UserDetails = ({
label={t('project.mapping.cc')}
value={details.cc ? <CCRow size={16} cc={details.cc} language={language} /> : '-'}
/>
- {details.rg && <InfoRow label={t('project.mapping.rg')} value={details.rg} />}
+ {details.rg ? <InfoRow label={t('project.mapping.rg')} value={details.rg} /> : null}
<InfoRow
label={t('project.mapping.lc')}
value={details.lc ? getLocaleDisplayName(details.lc, language) : '-'}
@@ -486,25 +316,37 @@ export const UserDetails = ({
/>
<InfoRow
label={t('project.mapping.os')}
- value={details.os ? `${details.os}${details.osv ? ` v${details.osv}` : ''}` : '-'}
+ value={
+ details.os ? (
+ <>
+ <OSIcon os={details.os} theme={theme} />
+ {details.os}
+ {details.osv ? ` v${details.osv}` : ''}
+ </>
+ ) : (
+ '-'
+ )
+ }
/>
</div>
</div>
{/* Activity Calendar Card */}
<div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>
- <h3 className='mb-4 text-xs font-semibold tracking-wide text-gray-500 uppercase dark:text-gray-400'>
+ <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>
{t('project.activityCalendar')}
</h3>
<ActivityCalendar data={details.activityCalendar || []} />
</div>
</div>
- {/* Right Column - Chart */}
- <div className='flex-1'>
- {details.chart && !_isEmpty(details.chart.x) && (
- <div className='h-full rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>
- <h3 className='mb-4 text-base font-semibold text-gray-900 dark:text-white'>{t('dashboard.pageviews')}</h3>
+ {/* Right Column - Chart & Sessions */}
+ <div className='flex-1 space-y-4'>
+ {details.chart && !_isEmpty(details.chart.x) ? (
+ <div className='max-h-max rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>
+ <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>
+ {t('dashboard.pageviews')}
+ </h3>
<SessionChart
chart={details.chart}
timeBucket={details.timeBucket}
@@ -515,37 +357,36 @@ export const UserDetails = ({
className='h-[300px] [&_svg]:overflow-visible!'
/>
</div>
- )}
- </div>
- </div>
+ ) : null}
- {/* Sessions - Full Width */}
- <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>
- <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-500 uppercase dark:text-gray-400'>
- {t('project.userSessions')}
- </h3>
- {sessionsLoading && sessions.length === 0 ? (
- <Loader />
- ) : sessions.length === 0 ? (
- <p className='py-4 text-center text-sm text-gray-400'>{t('project.noSessions')}</p>
- ) : (
- <>
- <Sessions sessions={sessions} timeFormat={timeFormat} />
- {canLoadMoreSessions && (
- <button
- type='button'
- onClick={onLoadMoreSessions}
- disabled={!!sessionsLoading}
- className={cx(
- 'mt-4 w-full rounded-lg border border-gray-200 bg-gray-50 px-4 py-2.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-200 dark:hover:bg-slate-600',
- sessionsLoading && 'cursor-not-allowed opacity-50',
- )}
- >
- {t('project.loadMore')}
- </button>
+ {/* Sessions */}
+ <div className='rounded-xl border border-gray-200 bg-white p-5 dark:border-slate-700 dark:bg-slate-800'>
+ <h3 className='mb-3 text-xs font-semibold tracking-wide text-gray-900 uppercase dark:text-gray-50'>
+ {t('project.userSessions')}
+ </h3>
+ {sessionsLoading && sessions.length === 0 ? (
+ <Loader />
+ ) : sessions.length === 0 ? (
+ <p className='py-4 text-center text-sm text-gray-400'>{t('project.noSessions')}</p>
+ ) : (
+ <>
+ <Sessions sessions={sessions} timeFormat={timeFormat} />
+ {canLoadMoreSessions ? (
+ <Button
+ onClick={onLoadMoreSessions}
+ disabled={!!sessionsLoading}
+ loading={!!sessionsLoading}
+ className='mt-4 w-full'
+ primary
+ regular
+ >
+ {t('project.loadMore')}
+ </Button>
+ ) : null}
+ </>
)}
- </>
- )}
+ </div>
+ </div>
</div>
</div>
)
diff --git a/web/app/pages/Project/View/components/Users.tsx b/web/app/pages/Project/View/components/Users.tsx
index 04803dd51..cba32decf 100644
--- a/web/app/pages/Project/View/components/Users.tsx
+++ b/web/app/pages/Project/View/components/Users.tsx
@@ -1,200 +1,23 @@
import { ChevronRightIcon } from '@heroicons/react/24/outline'
+import cx from 'clsx'
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import _map from 'lodash/map'
-import { FileTextIcon, MousePointerClickIcon, UserIcon, UsersIcon, CalendarIcon } from 'lucide-react'
+import { BugIcon, FileTextIcon, MousePointerClickIcon, UsersIcon, CalendarIcon } from 'lucide-react'
import React, { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { Link, useLocation } from 'react-router'
import { ClientOnly } from 'remix-utils/client-only'
import { Profile as ProfileType } from '~/lib/models/Project'
+import { Badge } from '~/ui/Badge'
import Loader from '~/ui/Loader'
+import { getProfileDisplayName, ProfileAvatar } from '~/utils/profileAvatars'
import CCRow from './CCRow'
dayjs.extend(relativeTime)
-// Adjectives and nouns for generating anonymous display names
-const ADJECTIVES = [
- 'Amber',
- 'Azure',
- 'Beige',
- 'Black',
- 'Blue',
- 'Bronze',
- 'Brown',
- 'Coral',
- 'Crimson',
- 'Cyan',
- 'Emerald',
- 'Fuchsia',
- 'Gold',
- 'Gray',
- 'Green',
- 'Indigo',
- 'Ivory',
- 'Jade',
- 'Lavender',
- 'Lime',
- 'Magenta',
- 'Maroon',
- 'Mint',
- 'Navy',
- 'Olive',
- 'Orange',
- 'Peach',
- 'Pink',
- 'Plum',
- 'Purple',
- 'Red',
- 'Rose',
- 'Ruby',
- 'Salmon',
- 'Sapphire',
- 'Scarlet',
- 'Silver',
- 'Slate',
- 'Teal',
- 'Turquoise',
- 'Violet',
- 'White',
- 'Yellow',
-]
-
-const NOUNS = [
- 'Albatross',
- 'Ant',
- 'Badger',
- 'Bear',
- 'Beaver',
- 'Bison',
- 'Butterfly',
- 'Camel',
- 'Cardinal',
- 'Cat',
- 'Cheetah',
- 'Cobra',
- 'Condor',
- 'Coyote',
- 'Crane',
- 'Crow',
- 'Deer',
- 'Dolphin',
- 'Dove',
- 'Dragon',
- 'Eagle',
- 'Elephant',
- 'Elk',
- 'Falcon',
- 'Ferret',
- 'Finch',
- 'Flamingo',
- 'Fox',
- 'Frog',
- 'Gazelle',
- 'Giraffe',
- 'Goat',
- 'Goose',
- 'Gorilla',
- 'Hamster',
- 'Hare',
- 'Hawk',
- 'Hedgehog',
- 'Heron',
- 'Hippo',
- 'Horse',
- 'Hummingbird',
- 'Hyena',
- 'Iguana',
- 'Jaguar',
- 'Jay',
- 'Kangaroo',
- 'Koala',
- 'Lemur',
- 'Leopard',
- 'Lion',
- 'Llama',
- 'Lobster',
- 'Lynx',
- 'Macaw',
- 'Meerkat',
- 'Mongoose',
- 'Moose',
- 'Moth',
- 'Mouse',
- 'Narwhal',
- 'Newt',
- 'Octopus',
- 'Orca',
- 'Ostrich',
- 'Otter',
- 'Owl',
- 'Panda',
- 'Panther',
- 'Parrot',
- 'Peacock',
- 'Pelican',
- 'Penguin',
- 'Phoenix',
- 'Pig',
- 'Pigeon',
- 'Piranha',
- 'Pony',
- 'Porcupine',
- 'Puma',
- 'Quail',
- 'Rabbit',
- 'Raccoon',
- 'Raven',
- 'Rhino',
- 'Robin',
- 'Salamander',
- 'Salmon',
- 'Seal',
- 'Shark',
- 'Sheep',
- 'Sloth',
- 'Snail',
- 'Snake',
- 'Sparrow',
- 'Spider',
- 'Squirrel',
- 'Stork',
- 'Swan',
- 'Tiger',
- 'Toucan',
- 'Trout',
- 'Turtle',
- 'Viper',
- 'Vulture',
- 'Walrus',
- 'Weasel',
- 'Whale',
- 'Wolf',
- 'Wombat',
- 'Woodpecker',
- 'Yak',
- 'Zebra',
-]
-
-// Generate a deterministic display name from profileId
-const generateDisplayName = (profileId: string): string => {
- // Simple hash function
- let hash = 0
- for (let i = 0; i < profileId.length; i++) {
- const char = profileId.charCodeAt(i)
- hash = (hash << 5) - hash + char
- hash = hash & hash // Convert to 32bit integer
- }
- hash = Math.abs(hash)
-
- const adjIndex = hash % ADJECTIVES.length
- const nounIndex = Math.floor(hash / ADJECTIVES.length) % NOUNS.length
-
- return `${ADJECTIVES[adjIndex]} ${NOUNS[nounIndex]}`
-}
-
interface UsersProps {
profiles: ProfileType[]
timeFormat: '12-hour' | '24-hour'
@@ -219,17 +42,7 @@ const UserRow = ({ profile, timeFormat }: UserRowProps) => {
const location = useLocation()
const displayName = useMemo(() => {
- if (profile.isIdentified) {
- // For identified users, extract the user ID from the profileId
- const userId = profile.profileId.replace('usr_', '')
- // If it's a short enough ID, show it directly
- if (userId.length <= 20) {
- return userId
- }
- // Otherwise truncate it
- return `${userId.substring(0, 17)}...`
- }
- return generateDisplayName(profile.profileId)
+ return getProfileDisplayName(profile.profileId, profile.isIdentified)
}, [profile.profileId, profile.isIdentified])
const lastSeenText = useMemo(() => {
@@ -245,47 +58,20 @@ const UserRow = ({ profile, timeFormat }: UserRowProps) => {
})
}, [profile.lastSeen, language, timeFormat])
- const firstSeenText = useMemo(() => {
- return dayjs(profile.firstSeen).toDate().toLocaleDateString(language, {
- day: 'numeric',
- month: 'short',
- year: 'numeric',
- })
- }, [profile.firstSeen, language])
-
const params = new URLSearchParams(location.search)
params.set('profileId', profile.profileId)
- // Generate avatar background color from profileId
- const avatarColor = useMemo(() => {
- let hash = 0
- for (let i = 0; i < profile.profileId.length; i++) {
- hash = profile.profileId.charCodeAt(i) + ((hash << 5) - hash)
- }
- const hue = Math.abs(hash) % 360
- return `hsl(${hue}, 65%, 55%)`
- }, [profile.profileId])
-
return (
<Link to={{ search: params.toString() }}>
<li className='relative mb-3 flex cursor-pointer justify-between gap-x-6 overflow-hidden rounded-xl border border-gray-200 bg-gray-50 px-4 py-4 transition-colors hover:bg-gray-200/70 sm:px-6 dark:border-slate-800/25 dark:bg-slate-800/70 dark:hover:bg-slate-700/60'>
<div className='flex min-w-0 gap-x-4'>
{/* Avatar */}
- <div
- className='flex h-10 w-10 shrink-0 items-center justify-center rounded-full text-sm font-semibold text-white'
- style={{ backgroundColor: avatarColor }}
- >
- {profile.isIdentified ? <UserIcon className='h-5 w-5' /> : displayName.charAt(0)}
- </div>
+ <ProfileAvatar profileId={profile.profileId} size={40} className='shrink-0' />
<div className='min-w-0 flex-auto'>
<p className='flex items-center text-sm leading-6 font-semibold text-gray-900 dark:text-gray-50'>
<span className='truncate'>{displayName}</span>
- {profile.isIdentified ? (
- <span className='ml-2 inline-flex items-center rounded-full bg-indigo-100 px-2 py-0.5 text-xs font-medium text-indigo-700 dark:bg-indigo-900/50 dark:text-indigo-300'>
- {t('project.identified')}
- </span>
- ) : null}
+ {profile.isIdentified ? <Badge label={t('project.identified')} colour='indigo' className='ml-2' /> : null}
</p>
<p className='mt-1 flex flex-wrap items-center gap-x-2 text-xs leading-5 text-gray-500 dark:text-gray-300'>
<span className='flex'>
@@ -304,10 +90,15 @@ const UserRow = ({ profile, timeFormat }: UserRowProps) => {
<FileTextIcon className='mr-1 size-4' strokeWidth={1.5} /> {profile.pageviewsCount}
</span>
{profile.eventsCount > 0 ? (
- <span className='flex items-center' title={t('dashboard.events')}>
+ <span className='mr-2 flex items-center' title={t('dashboard.events')}>
<MousePointerClickIcon className='mr-1 size-4' strokeWidth={1.5} /> {profile.eventsCount}
</span>
) : null}
+ {profile.errorsCount > 0 ? (
+ <span className='flex items-center text-red-400' title={t('dashboard.errors')}>
+ <BugIcon className='mr-1 size-4' strokeWidth={1.5} /> {profile.errorsCount}
+ </span>
+ ) : null}
</p>
</div>
</div>
@@ -325,6 +116,14 @@ const UserRow = ({ profile, timeFormat }: UserRowProps) => {
<MousePointerClickIcon className='mr-1 size-5' strokeWidth={1.5} /> {profile.eventsCount}
</span>
) : null}
+ {profile.errorsCount > 0 ? (
+ <span
+ className='flex items-center text-red-500'
+ title={t('dashboard.xErrors', { x: profile.errorsCount })}
+ >
+ <BugIcon className='mr-1 size-5' strokeWidth={1.5} /> {profile.errorsCount}
+ </span>
+ ) : null}
</div>
<p className='mt-1 flex items-center text-xs leading-5 text-gray-500 dark:text-gray-400'>
<CalendarIcon className='mr-1 size-3' strokeWidth={1.5} />
@@ -341,64 +140,42 @@ const UserRow = ({ profile, timeFormat }: UserRowProps) => {
interface UsersFilterProps {
profileType: 'all' | 'anonymous' | 'identified'
onProfileTypeChange: (type: 'all' | 'anonymous' | 'identified') => void
- search: string
- onSearchChange: (search: string) => void
}
-export const UsersFilter: React.FC<UsersFilterProps> = ({
- profileType,
- onProfileTypeChange,
- search,
- onSearchChange,
-}) => {
+export const UsersFilter: React.FC<UsersFilterProps> = ({ profileType, onProfileTypeChange }) => {
const { t } = useTranslation('common')
+ const filterButtonClass = (isActive: boolean) =>
+ cx(
+ 'rounded-md px-3 py-1.5 text-sm font-medium transition-colors border',
+ isActive
+ ? 'border-slate-900 bg-slate-900 text-gray-50 dark:border-slate-700 dark:bg-slate-800'
+ : 'border-gray-200 bg-gray-50 text-gray-700 hover:border-gray-300 hover:bg-white dark:border-slate-700/50 dark:bg-slate-800/50 dark:text-gray-300 dark:hover:border-slate-600 dark:hover:bg-slate-700',
+ )
+
return (
- <div className='mb-4 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between'>
- <div className='flex items-center gap-2'>
- <button
- type='button'
- onClick={() => onProfileTypeChange('all')}
- className={`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${
- profileType === 'all'
- ? 'bg-indigo-600 text-white'
- : 'bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-slate-700 dark:text-gray-300 dark:hover:bg-slate-600'
- }`}
- >
- {t('project.allUsers')}
- </button>
- <button
- type='button'
- onClick={() => onProfileTypeChange('anonymous')}
- className={`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${
- profileType === 'anonymous'
- ? 'bg-indigo-600 text-white'
- : 'bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-slate-700 dark:text-gray-300 dark:hover:bg-slate-600'
- }`}
- >
- {t('project.anonymous')}
- </button>
- <button
- type='button'
- onClick={() => onProfileTypeChange('identified')}
- className={`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${
- profileType === 'identified'
- ? 'bg-indigo-600 text-white'
- : 'bg-gray-100 text-gray-700 hover:bg-gray-200 dark:bg-slate-700 dark:text-gray-300 dark:hover:bg-slate-600'
- }`}
- >
- {t('project.identified')}
- </button>
- </div>
- <div className='relative'>
- <input
- type='text'
- value={search}
- onChange={(e) => onSearchChange(e.target.value)}
- placeholder={t('project.searchUsers')}
- className='block w-full rounded-md border border-gray-300 bg-white px-3 py-1.5 text-sm text-gray-900 placeholder-gray-500 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 sm:w-64 dark:border-slate-600 dark:bg-slate-800 dark:text-gray-100 dark:placeholder-gray-400'
- />
- </div>
+ <div className='mb-4 flex items-center gap-2'>
+ <button
+ type='button'
+ onClick={() => onProfileTypeChange('all')}
+ className={filterButtonClass(profileType === 'all')}
+ >
+ {t('project.allUsers')}
+ </button>
+ <button
+ type='button'
+ onClick={() => onProfileTypeChange('anonymous')}
+ className={filterButtonClass(profileType === 'anonymous')}
+ >
+ {t('project.anonymous')}
+ </button>
+ <button
+ type='button'
+ onClick={() => onProfileTypeChange('identified')}
+ className={filterButtonClass(profileType === 'identified')}
+ >
+ {t('project.identified')}
+ </button>
</div>
)
}
diff --git a/web/app/utils/profileAvatars.tsx b/web/app/utils/profileAvatars.tsx
new file mode 100644
index 000000000..6488b15ad
--- /dev/null
+++ b/web/app/utils/profileAvatars.tsx
@@ -0,0 +1,216 @@
+import Avatar from 'boring-avatars'
+
+// Adjectives and nouns for generating anonymous display names
+const ADJECTIVES = [
+ 'Amber',
+ 'Azure',
+ 'Beige',
+ 'Black',
+ 'Blue',
+ 'Bronze',
+ 'Brown',
+ 'Coral',
+ 'Crimson',
+ 'Cyan',
+ 'Emerald',
+ 'Fuchsia',
+ 'Gold',
+ 'Gray',
+ 'Green',
+ 'Indigo',
+ 'Ivory',
+ 'Jade',
+ 'Lavender',
+ 'Lime',
+ 'Magenta',
+ 'Maroon',
+ 'Mint',
+ 'Navy',
+ 'Olive',
+ 'Orange',
+ 'Peach',
+ 'Pink',
+ 'Plum',
+ 'Purple',
+ 'Red',
+ 'Rose',
+ 'Ruby',
+ 'Salmon',
+ 'Sapphire',
+ 'Scarlet',
+ 'Silver',
+ 'Slate',
+ 'Teal',
+ 'Turquoise',
+ 'Violet',
+ 'White',
+ 'Yellow',
+]
+
+const NOUNS = [
+ 'Albatross',
+ 'Ant',
+ 'Badger',
+ 'Bear',
+ 'Beaver',
+ 'Bison',
+ 'Butterfly',
+ 'Camel',
+ 'Cardinal',
+ 'Cat',
+ 'Cheetah',
+ 'Cobra',
+ 'Condor',
+ 'Coyote',
+ 'Crane',
+ 'Crow',
+ 'Deer',
+ 'Dolphin',
+ 'Dove',
+ 'Dragon',
+ 'Eagle',
+ 'Elephant',
+ 'Elk',
+ 'Falcon',
+ 'Ferret',
+ 'Finch',
+ 'Flamingo',
+ 'Fox',
+ 'Frog',
+ 'Gazelle',
+ 'Giraffe',
+ 'Goat',
+ 'Goose',
+ 'Gorilla',
+ 'Hamster',
+ 'Hare',
+ 'Hawk',
+ 'Hedgehog',
+ 'Heron',
+ 'Hippo',
+ 'Horse',
+ 'Hummingbird',
+ 'Hyena',
+ 'Iguana',
+ 'Jaguar',
+ 'Jay',
+ 'Kangaroo',
+ 'Koala',
+ 'Lemur',
+ 'Leopard',
+ 'Lion',
+ 'Llama',
+ 'Lobster',
+ 'Lynx',
+ 'Macaw',
+ 'Meerkat',
+ 'Mongoose',
+ 'Moose',
+ 'Moth',
+ 'Mouse',
+ 'Narwhal',
+ 'Newt',
+ 'Octopus',
+ 'Orca',
+ 'Ostrich',
+ 'Otter',
+ 'Owl',
+ 'Panda',
+ 'Panther',
+ 'Parrot',
+ 'Peacock',
+ 'Pelican',
+ 'Penguin',
+ 'Phoenix',
+ 'Pig',
+ 'Pigeon',
+ 'Piranha',
+ 'Pony',
+ 'Porcupine',
+ 'Puma',
+ 'Quail',
+ 'Rabbit',
+ 'Raccoon',
+ 'Raven',
+ 'Rhino',
+ 'Robin',
+ 'Salamander',
+ 'Salmon',
+ 'Seal',
+ 'Shark',
+ 'Sheep',
+ 'Sloth',
+ 'Snail',
+ 'Snake',
+ 'Sparrow',
+ 'Spider',
+ 'Squirrel',
+ 'Stork',
+ 'Swan',
+ 'Tiger',
+ 'Toucan',
+ 'Trout',
+ 'Turtle',
+ 'Viper',
+ 'Vulture',
+ 'Walrus',
+ 'Weasel',
+ 'Whale',
+ 'Wolf',
+ 'Wombat',
+ 'Woodpecker',
+ 'Yak',
+ 'Zebra',
+]
+
+// Color palette for boring-avatars
+const AVATAR_COLORS = ['#92A1C6', '#146A7C', '#F0AB3D', '#C271B4', '#C20D90']
+
+/**
+ * Generate a deterministic display name from profileId
+ */
+export const generateDisplayName = (profileId: string): string => {
+ let hash = 0
+ for (let i = 0; i < profileId.length; i++) {
+ const char = profileId.charCodeAt(i)
+ hash = (hash << 5) - hash + char
+ hash = hash & hash // Convert to 32bit integer
+ }
+ hash = Math.abs(hash)
+
+ const adjIndex = hash % ADJECTIVES.length
+ const nounIndex = Math.floor(hash / ADJECTIVES.length) % NOUNS.length
+
+ return `${ADJECTIVES[adjIndex]} ${NOUNS[nounIndex]}`
+}
+
+/**
+ * Get display name for a profile - handles both identified and anonymous users
+ */
+export const getProfileDisplayName = (profileId: string, isIdentified: boolean): string => {
+ if (isIdentified) {
+ const userId = profileId.replace('usr_', '')
+ if (userId.length <= 20) {
+ return userId
+ }
+ return `${userId.substring(0, 17)}...`
+ }
+ return generateDisplayName(profileId)
+}
+
+interface ProfileAvatarProps {
+ profileId: string
+ size?: number
+ className?: string
+}
+
+/**
+ * Avatar component for user profiles using boring-avatars
+ */
+export const ProfileAvatar = ({ profileId, size = 40, className }: ProfileAvatarProps) => {
+ return (
+ <div className={className}>
+ <Avatar size={size} name={profileId} variant='beam' colors={AVATAR_COLORS} />
+ </div>
+ )
+}
diff --git a/web/package-lock.json b/web/package-lock.json
index 76e947819..81ae634c2 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -22,6 +22,7 @@
"axios": "^1.13.2",
"axios-auth-refresh": "^3.3.6",
"billboard.js": "^3.17.2",
+ "boring-avatars": "^2.0.4",
"clsx": "^2.1.1",
"d3": "^7.9.0",
"d3-scale": "^4.0.2",
@@ -4725,6 +4726,16 @@
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
"license": "MIT"
},
+ "node_modules/boring-avatars": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/boring-avatars/-/boring-avatars-2.0.4.tgz",
+ "integrity": "sha512-xhZO/w/6aFmRfkaWohcl2NfyIy87gK5SBbys8kctZeTGF1Apjpv/10pfUuv+YEfVPkESU/h2Y6tt/Dwp+bIZPw==",
+ "license": "MIT",
+ "peerDependencies": {
+ "react": ">=18.0.0",
+ "react-dom": ">=18.0.0"
+ }
+ },
"node_modules/brace-expansion": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
diff --git a/web/package.json b/web/package.json
index 06091268d..c0916bd03 100644
--- a/web/package.json
+++ b/web/package.json
@@ -36,6 +36,7 @@
"axios": "^1.13.2",
"axios-auth-refresh": "^3.3.6",
"billboard.js": "^3.17.2",
+ "boring-avatars": "^2.0.4",
"clsx": "^2.1.1",
"d3": "^7.9.0",
"d3-scale": "^4.0.2",
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index f9ee88c43..c289cf4a9 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -826,7 +826,7 @@
"cumulativeMode": "Cumulative mode",
"traffic": "Traffic",
"performance": "Performance",
- "users": "Users",
+ "profiles": "Profiles",
"funnels": "Funnels",
"sessions": "Sessions",
"xOccurrences": "{{x}} occurrences",