📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
online status
Blue Mouse927a6fd819a2
diff --git a/web/app/pages/Project/View/components/Users.tsx b/web/app/pages/Project/View/components/Users.tsxindex cba32decf..092f7f6f6 100644--- a/web/app/pages/Project/View/components/Users.tsx+++ b/web/app/pages/Project/View/components/Users.tsx@@ -12,12 +12,35 @@ 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 Tooltip from '~/ui/Tooltip'import { getProfileDisplayName, ProfileAvatar } from '~/utils/profileAvatars'import CCRow from './CCRow'dayjs.extend(relativeTime)+// Time thresholds for online status (in minutes)+const ONLINE_THRESHOLD_MINUTES = 5+const RECENTLY_ACTIVE_THRESHOLD_MINUTES = 30++type OnlineStatus = 'online' | 'recently_active' | 'offline'++const getOnlineStatus = (lastSeen: string): OnlineStatus => {+ const now = dayjs()+ const lastSeenTime = dayjs(lastSeen)+ const minutesAgo = now.diff(lastSeenTime, 'minute')++ if (minutesAgo < ONLINE_THRESHOLD_MINUTES) {+ return 'online'+ }++ if (minutesAgo < RECENTLY_ACTIVE_THRESHOLD_MINUTES) {+ return 'recently_active'+ }++ return 'offline'+}+interface UsersProps {profiles: ProfileType[]timeFormat: '12-hour' | '24-hour'@@ -58,6 +81,10 @@ const UserRow = ({ profile, timeFormat }: UserRowProps) => {})}, [profile.lastSeen, language, timeFormat])+ const onlineStatus = useMemo(() => getOnlineStatus(profile.lastSeen), [profile.lastSeen])++ const lastSeenAgo = useMemo(() => dayjs(profile.lastSeen).fromNow(), [profile.lastSeen])+const params = new URLSearchParams(location.search)params.set('profileId', profile.profileId)@@ -65,8 +92,25 @@ const UserRow = ({ profile, timeFormat }: UserRowProps) => {<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 */}- <ProfileAvatar profileId={profile.profileId} size={40} className='shrink-0' />+ {/* Avatar with online status indicator */}+ <div className='relative shrink-0'>+ <ProfileAvatar profileId={profile.profileId} size={40} />+ {onlineStatus === 'offline' ? null : (+ <Tooltip+ text={t('project.lastSeenAgo', { time: lastSeenAgo })}+ className='absolute right-0 bottom-2'+ tooltipNode={+ <span+ className={cx(+ 'block h-3 w-3 rounded-full ring-2 ring-gray-50 dark:ring-slate-800',+ onlineStatus === 'online' && 'bg-green-500',+ onlineStatus === 'recently_active' && 'bg-yellow-500',+ )}+ />+ }+ />+ )}+ </div><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'>diff --git a/web/app/ui/Switch.tsx b/web/app/ui/Switch.tsxindex 6f1ee4ea9..d22d4b401 100644--- a/web/app/ui/Switch.tsx+++ b/web/app/ui/Switch.tsx@@ -30,7 +30,7 @@ export const Switch = ({ checked, onChange, disabled = false, className, label,}}}className={cx(- 'relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75',+ 'relative inline-flex h-4 w-7 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring-2 focus-visible:ring-white/75',{'bg-slate-900 dark:bg-slate-500': checked,'bg-gray-300 dark:bg-slate-600': !checked,@@ -41,9 +41,9 @@ export const Switch = ({ checked, onChange, disabled = false, className, label,<spanaria-hidden='true'className={cx(- 'pointer-events-none inline-block size-5 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out',+ 'pointer-events-none inline-block size-3 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out',{- 'translate-x-5': checked,+ 'translate-x-3': checked,'translate-x-0': !checked,},)}diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex 5a3272667..7387b83a5 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -1171,6 +1171,8 @@"allUsers": "All","anonymous": "Anonymous","identified": "Identified",+ "online": "Online",+ "lastSeenAgo": "Last seen {{time}}","searchUsers": "Search users...","sessions": "Sessions","xSessions": "{{x}} sessions",