📈 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
Move profiles filter to a dropdown menu
Blue Mouse5d41f318dd17
diff --git a/web/app/pages/Project/View/components/DashboardHeader.tsx b/web/app/pages/Project/View/components/DashboardHeader.tsxindex 8ddf55bdb..95d562451 100644--- a/web/app/pages/Project/View/components/DashboardHeader.tsx+++ b/web/app/pages/Project/View/components/DashboardHeader.tsx@@ -1,7 +1,7 @@import cx from 'clsx'import dayjs from 'dayjs'import _find from 'lodash/find'-import { SearchIcon } from 'lucide-react'+import { SearchIcon, UsersIcon } from 'lucide-react'import React from 'react'import { useTranslation } from 'react-i18next'import { useSearchParams } from 'react-router'@@ -22,6 +22,8 @@ import LiveVisitorsDropdown from './LiveVisitorsDropdown'import { RefreshStatsButton } from './RefreshStatsButton'import TBPeriodSelector from './TBPeriodSelector'+export type ProfileTypeFilter = 'all' | 'anonymous' | 'identified'+interface DashboardHeaderProps {// Optional propsshowLiveVisitors?: boolean@@ -41,6 +43,10 @@ interface DashboardHeaderProps {// Right side content (for segments/export dropdowns or action buttons)rightContent?: React.ReactNode++ // Profile type filter (for Profiles view)+ profileTypeFilter?: ProfileTypeFilter+ onProfileTypeFilterChange?: (type: ProfileTypeFilter) => void}const DashboardHeader = ({@@ -55,6 +61,8 @@ const DashboardHeader = ({onBack,leftContent,rightContent,+ profileTypeFilter,+ onProfileTypeFilterChange,}: DashboardHeaderProps) => {const { isLoading: authLoading } = useAuth()const {@@ -142,6 +150,35 @@ const DashboardHeader = ({) : null}{leftContent}{showLiveVisitors ? <LiveVisitorsDropdown /> : null}+ {profileTypeFilter && onProfileTypeFilterChange ? (+ <Dropdown+ items={+ [+ { value: 'all', label: t('project.allUsers') },+ { value: 'anonymous', label: t('project.anonymous') },+ { value: 'identified', label: t('project.identified') },+ ] as const+ }+ title={+ <span className='flex items-center'>+ <UsersIcon className='mr-1.5 h-4 w-4' />+ {profileTypeFilter === 'all'+ ? t('project.allUsers')+ : profileTypeFilter === 'anonymous'+ ? t('project.anonymous')+ : t('project.identified')}+ </span>+ }+ labelExtractor={(item) => item.label}+ keyExtractor={(item) => item.value}+ onSelect={(item) => {+ onProfileTypeFilterChange(item.value as ProfileTypeFilter)+ }}+ buttonClassName='rounded-md border border-gray-50/0 p-2 text-sm font-medium text-gray-700 transition-colors ring-inset hover:border-gray-300 hover:bg-white focus:z-10 focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500 focus:outline-hidden dark:text-gray-50 hover:dark:border-slate-700/80 dark:hover:bg-slate-800 focus:dark:ring-gray-200'+ chevron='mini'+ headless+ />+ ) : null}</div><div className='mx-auto mt-3 flex w-full max-w-[420px] flex-wrap items-center justify-center gap-x-2 gap-y-1 sm:mx-0 sm:w-auto sm:max-w-none sm:flex-nowrap sm:justify-between lg:mt-0'>{showRefreshButton ? (diff --git a/web/app/pages/Project/tabs/Profiles/Profiles.tsx b/web/app/pages/Project/tabs/Profiles/Profiles.tsxindex 4c561ffc6..5e77fcb20 100644--- a/web/app/pages/Project/tabs/Profiles/Profiles.tsx+++ b/web/app/pages/Project/tabs/Profiles/Profiles.tsx@@ -245,52 +245,6 @@ const ProfileRow = ({ profile, timeFormat }: ProfileRowProps) => {)}-interface ProfilesFilterProps {- profileType: 'all' | 'anonymous' | 'identified'- onProfileTypeChange: (type: 'all' | 'anonymous' | 'identified') => void-}--export const ProfilesFilter: React.FC<ProfilesFilterProps> = ({- profileType,- onProfileTypeChange,-}) => {- const { t } = useTranslation('common')-- const filterButtonClass = (isActive: boolean) =>- cx(- 'rounded-md border px-3 py-1.5 text-sm font-medium transition-colors',- 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 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>- )-}-export const Profiles: React.FC<UsersProps> = ({ profiles, timeFormat }) => {return (<ClientOnly@@ -301,7 +255,7 @@ export const Profiles: React.FC<UsersProps> = ({ profiles, timeFormat }) => {}>{() => (- <ul className='mt-4'>+ <ul>{_map(profiles, (profile) => (<ProfileRowkey={profile.profileId}diff --git a/web/app/pages/Project/tabs/Profiles/ProfilesView.tsx b/web/app/pages/Project/tabs/Profiles/ProfilesView.tsxindex 539a5bf11..20c44b2ce 100644--- a/web/app/pages/Project/tabs/Profiles/ProfilesView.tsx+++ b/web/app/pages/Project/tabs/Profiles/ProfilesView.tsx@@ -18,10 +18,7 @@ import {} from '~/lib/models/Project'import NoProfiles from '~/pages/Project/tabs/Profiles/components/NoProfiles'import { ProfileDetails } from '~/pages/Project/tabs/Profiles/ProfileDetails'-import {- Profiles,- ProfilesFilter,-} from '~/pages/Project/tabs/Profiles/Profiles'+import { Profiles } from '~/pages/Project/tabs/Profiles/Profiles'import DashboardHeader from '~/pages/Project/View/components/DashboardHeader'import {useViewProjectContext,@@ -408,18 +405,18 @@ const ProfilesView = ({ tnMapping }: ProfilesViewProps) => {// Profiles list viewreturn (<>- <DashboardHeader showLiveVisitors />- {profilesLoading && !_isEmpty(profiles) ? <LoadingBar /> : null}- {!_isEmpty(profiles) ? (- <Filters className='mb-3' tnMapping={tnMapping} />- ) : null}- <ProfilesFilter- profileType={profileTypeFilter}- onProfileTypeChange={(type) => {+ <DashboardHeader+ showLiveVisitors+ profileTypeFilter={profileTypeFilter}+ onProfileTypeFilterChange={(type) => {setProfileTypeFilter(type)setProfilesSkip(0)}}/>+ {profilesLoading && !_isEmpty(profiles) ? <LoadingBar /> : null}+ {!_isEmpty(profiles) ? (+ <Filters className='mb-3' tnMapping={tnMapping} />+ ) : null}{(profilesLoading === null || profilesLoading) && _isEmpty(profiles) ? (<LoaderView />) : null}