🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Remove LiveUserCount component and update Sidebar and SubHeader to reflect changes. Integrate new filter button in SubHeader and adjust layout for better organization. Enhance Sidebar with additional links and improved styling.
Bill Yang68e05fc40dda
diff --git a/client/src/app/[site]/components/Sidebar/Sidebar.tsx b/client/src/app/[site]/components/Sidebar/Sidebar.tsxindex 8b9dbc82a..a96a93c20 100644--- a/client/src/app/[site]/components/Sidebar/Sidebar.tsx+++ b/client/src/app/[site]/components/Sidebar/Sidebar.tsx@@ -2,7 +2,9 @@import { Funnel, Target } from "@phosphor-icons/react/dist/ssr";import {AlertTriangle,+ ChartColumnDecreasing,Earth,+ File,Gauge,LayoutDashboard,LayoutGrid,@@ -12,18 +14,16 @@ import {Settings,Split,User,- File,- Play,+ Video,} from "lucide-react";import Link from "next/link";import { usePathname } from "next/navigation";import { useGetSite } from "../../../../api/admin/sites";import { SiteSettings } from "../../../../components/SiteSettings/SiteSettings";import { authClient } from "../../../../lib/auth";+import { IS_CLOUD } from "../../../../lib/const";import { cn } from "../../../../lib/utils";-import LiveUserCount from "./LiveUserCount";import { SiteSelector } from "./SiteSelector";-import { IS_CLOUD } from "../../../../lib/const";export function Sidebar() {const session = authClient.useSession();@@ -44,122 +44,135 @@ export function Sidebar() {};return (- <div className="w-56 bg-neutral-900 border-r border-neutral-800 h-full flex-col">- <div className="p-3 border-b border-neutral-800 flex flex-col gap-2">- <SiteSelector />- </div>- <div className="flex flex-col p-3 ">- <LiveUserCount />- <SidebarLink- label="Main"- active={isActiveTab("main")}- href={getTabPath("main")}- icon={<LayoutDashboard className="w-4 h-4" />}- />- <SidebarLink- label="Realtime"- active={isActiveTab("realtime")}- href={getTabPath("realtime")}- icon={<Earth className="w-4 h-4" />}- />- <div className="hidden md:block">+ <div className="w-56 bg-neutral-900 border-r border-neutral-800 flex flex-col justify-between">+ <div className="flex flex-col">+ <div className="flex flex-col p-3 border-b border-neutral-800">+ <SiteSelector />+ </div>+ <div className="flex flex-col p-3">+ <div className="text-xs text-neutral-400 mt-0 mb-1 mx-3 font-medium">+ Web Analytics+ </div><SidebarLink- label="Replay"- active={isActiveTab("replay")}- href={getTabPath("replay")}- icon={<Play className="w-4 h-4" />}+ label="Main"+ active={isActiveTab("main")}+ href={getTabPath("main")}+ icon={<LayoutDashboard className="w-4 h-4" />}/>- </div>- {IS_CLOUD && (<SidebarLink- label="Pages"- active={isActiveTab("pages")}- href={getTabPath("pages")}- icon={<File className="w-4 h-4" />}+ label="Realtime"+ active={isActiveTab("realtime")}+ href={getTabPath("realtime")}+ icon={<Earth className="w-4 h-4" />}/>- )}- {IS_CLOUD && (+<SidebarLink- label="Performance"- active={isActiveTab("performance")}- href={getTabPath("performance")}- icon={<Gauge className="w-4 h-4" />}+ label="Map"+ active={isActiveTab("map")}+ href={getTabPath("map")}+ icon={<Map className="w-4 h-4" />}/>- )}- <SidebarLink- label="Map"- active={isActiveTab("map")}- href={getTabPath("map")}- icon={<Map className="w-4 h-4" />}- />- <SidebarLink- label="Funnels"- active={isActiveTab("funnels")}- href={getTabPath("funnels")}- icon={<Funnel weight="bold" />}- />- <SidebarLink- label="Goals"- active={isActiveTab("goals")}- href={getTabPath("goals")}- icon={<Target weight="bold" />}- />- <SidebarLink- label="Journeys"- active={isActiveTab("journeys")}- href={getTabPath("journeys")}- icon={<Split className="w-4 h-4" />}- />- <SidebarLink- label="Sessions"- active={isActiveTab("sessions")}- href={getTabPath("sessions")}- icon={<Rewind className="w-4 h-4" />}- />- <SidebarLink- label="Users"- active={isActiveTab("users")}- href={getTabPath("users")}- icon={<User className="w-4 h-4" />}- />- <SidebarLink- label="Retention"- active={isActiveTab("retention")}- href={getTabPath("retention")}- icon={<LayoutGrid className="w-4 h-4" />}- />- <SidebarLink- label="Events"- active={isActiveTab("events")}- href={getTabPath("events")}- icon={<MousePointerClick className="w-4 h-4" />}- />- <SidebarLink- label="Errors"- active={isActiveTab("errors")}- href={getTabPath("errors")}- icon={<AlertTriangle className="w-4 h-4" />}- />- {/* <SidebarLink+ {IS_CLOUD && (+ <SidebarLink+ label="Pages"+ active={isActiveTab("pages")}+ href={getTabPath("pages")}+ icon={<File className="w-4 h-4" />}+ />+ )}+ {IS_CLOUD && (+ <SidebarLink+ label="Performance"+ active={isActiveTab("performance")}+ href={getTabPath("performance")}+ icon={<Gauge className="w-4 h-4" />}+ />+ )}+ <SidebarLink+ label="Goals"+ active={isActiveTab("goals")}+ href={getTabPath("goals")}+ icon={<Target weight="bold" />}+ />+ <div className="text-xs text-neutral-400 mt-3 mb-1 mx-3 font-medium">+ Product Analytics+ </div>+ <div className="hidden md:block">+ <SidebarLink+ label="Replay"+ active={isActiveTab("replay")}+ href={getTabPath("replay")}+ icon={<Video className="w-4 h-4" />}+ />+ </div>+ <SidebarLink+ label="Funnels"+ active={isActiveTab("funnels")}+ href={getTabPath("funnels")}+ icon={<Funnel weight="bold" />}+ />+ <SidebarLink+ label="Journeys"+ active={isActiveTab("journeys")}+ href={getTabPath("journeys")}+ icon={<Split className="w-4 h-4" />}+ />+ <SidebarLink+ label="Retention"+ active={isActiveTab("retention")}+ href={getTabPath("retention")}+ icon={<ChartColumnDecreasing className="w-4 h-4" />}+ />+ <div className="text-xs text-neutral-400 mt-3 mb-1 mx-3 font-medium">+ Behavior+ </div>+ <SidebarLink+ label="Sessions"+ active={isActiveTab("sessions")}+ href={getTabPath("sessions")}+ icon={<Rewind className="w-4 h-4" />}+ />+ <SidebarLink+ label="Users"+ active={isActiveTab("users")}+ href={getTabPath("users")}+ icon={<User className="w-4 h-4" />}+ />+ <SidebarLink+ label="Events"+ active={isActiveTab("events")}+ href={getTabPath("events")}+ icon={<MousePointerClick className="w-4 h-4" />}+ />+ <SidebarLink+ label="Errors"+ active={isActiveTab("errors")}+ href={getTabPath("errors")}+ icon={<AlertTriangle className="w-4 h-4" />}+ />+ {/* <SidebarLinklabel="Reports"active={isActiveTab("reports")}href={getTabPath("reports")}icon={<ChartBarDecreasing className="w-4 h-4" />}- /> */}- {session.data && (+ /> */}+ </div>+ </div>+ {session.data && (+ <div className="flex flex-col p-3"><SiteSettingssiteId={site?.siteId ?? 0}trigger={<div className="px-3 py-2 rounded-lg transition-colors w-full text-neutral-200 hover:text-white hover:bg-neutral-800/50 cursor-pointer"><div className="flex items-center gap-2"><Settings className="h-4 w-4" />- <span className="text-sm">Settings</span>+ <span className="text-sm">Site Settings</span></div></div>}/>- )}- </div>+ </div>+ )}</div>);}diff --git a/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx b/client/src/app/[site]/components/SubHeader/Filters/Filters.tsxindex 137d6dd34..ef2b5322d 100644--- a/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx+++ b/client/src/app/[site]/components/SubHeader/Filters/Filters.tsx@@ -6,18 +6,13 @@ import {TooltipTrigger,} from "../../../../../components/ui/tooltip";import { useGetRegionName } from "../../../../../lib/geo";-import {- removeFilter,- updateFilter,- useStore,-} from "../../../../../lib/store";+import { removeFilter, updateFilter, useStore } from "../../../../../lib/store";import { cn } from "../../../../../lib/utils";import {filterTypeToLabel,getParameterNameLabel,getParameterValueLabel,} from "../../shared/Filters/utils";-import { NewFilterButton } from "./NewFilterButton";export function Filters({availableFilters,@@ -29,7 +24,6 @@ export function Filters({return (<div className="flex gap-2 flex-wrap">- <NewFilterButton availableFilters={availableFilters} />{filters.map((filter, i) => {const disabled =availableFilters && !availableFilters.includes(filter.parameter);diff --git a/client/src/app/[site]/components/Sidebar/LiveUserCount.tsx b/client/src/app/[site]/components/SubHeader/LiveUserCount.tsxsimilarity index 71%rename from client/src/app/[site]/components/Sidebar/LiveUserCount.tsxrename to client/src/app/[site]/components/SubHeader/LiveUserCount.tsxindex 4169cc4f8..c18d799d8 100644--- a/client/src/app/[site]/components/Sidebar/LiveUserCount.tsx+++ b/client/src/app/[site]/components/SubHeader/LiveUserCount.tsx@@ -6,12 +6,11 @@ import {} from "../../../../components/ui/tooltip";import NumberFlow from "@number-flow/react";-export default function LiveUserCount() {+export function LiveUserCount() {const { data } = useGetLiveUsercount(5);return (- <div className="flex items-center gap-2 text-base text-neutral-200 ml-3 mb-1">- {/* <div className="flex items-center gap-2 text-base text-neutral-200 cursor-default bg-neutral-800/50 rounded-lg px-2 py-1 border border-neutral-750"> */}+ <div className="flex items-center gap-1 text-base text-neutral-200 mr-1"><div className="flex justify-center"><span className="relative flex h-3 w-3"><span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"></span>@@ -21,14 +20,14 @@ export default function LiveUserCount() {<Tooltip><TooltipTrigger>- <span className="text-sm text-neutral-300 ml-1">+ <span className="text-sm text-neutral-200 ml-1 font-medium">{<NumberFlowrespectMotionPreference={false}value={data?.count ?? 0}/>}- <span className="ml-1">users online</span>+ <span className="ml-1"></span></span></TooltipTrigger><TooltipContent>diff --git a/client/src/app/[site]/components/SubHeader/SubHeader.tsx b/client/src/app/[site]/components/SubHeader/SubHeader.tsxindex 61ca08793..761be37e0 100644--- a/client/src/app/[site]/components/SubHeader/SubHeader.tsx+++ b/client/src/app/[site]/components/SubHeader/SubHeader.tsx@@ -9,6 +9,8 @@ import { Filters } from "./Filters/Filters";import { DateSelector } from "../../../../components/DateSelector/DateSelector";import { Time } from "../../../../components/DateSelector/types";import { MobileSidebar } from "../../../../components/MobileSidebar";+import { NewFilterButton } from "./Filters/NewFilterButton";+import { LiveUserCount } from "./LiveUserCount";const canGoForward = (time: Time) => {const currentDay = DateTime.now().startOf("day");@@ -41,52 +43,18 @@ export function SubHeader({availableFilters?: FilterParameter[];}) {const { time, setTime } = useStore();- // const { width } = useWindowSize();-- // if (width && width < 768) {- // return (- // <div className="flex flex-col relative">- // <div className="flex gap-2 mb-2 justify-between sticky top-0 z-10 bg-background">- // <div className="flex items-center gap-2">- // <MobileSidebar />- // </div>- // <div className="flex items-center gap-2">- // <DateSelector time={time} setTime={setTime} />- // <div className="flex items-center">- // <Button- // variant="outline"- // size="icon"- // onClick={goBack}- // className="rounded-r-none h-8 w-8 sm:h-9 sm:w-9"- // >- // <ChevronLeft />- // </Button>- // <Button- // variant="outline"- // size="icon"- // onClick={goForward}- // disabled={!canGoForward(time)}- // className="rounded-l-none -ml-px h-8 w-8 sm:h-9 sm:w-9"- // >- // <ChevronRight />- // </Button>- // </div>- // </div>- // </div>- // </div>- // );- // }return (<div>- <div className="flex gap-2 mb-2 justify-between">+ <div className="flex gap-2 mb-3 justify-between"><div className="flex items-center gap-2"><MobileSidebar /><div className="hidden md:block">- <Filters availableFilters={availableFilters} />+ <NewFilterButton availableFilters={availableFilters} /></div></div><div className="flex items-center gap-2">+ <LiveUserCount /><DateSelector time={time} setTime={setTime} /><div className="flex items-center"><Button@@ -110,7 +78,10 @@ export function SubHeader({</div></div></div>- <div className=" md:hidden">+ <div className="flex gap-2">+ <div className="md:hidden">+ <NewFilterButton availableFilters={availableFilters} />+ </div><Filters availableFilters={availableFilters} /></div></div>diff --git a/client/src/components/SiteSettings/ScriptBuilder.tsx b/client/src/components/SiteSettings/ScriptBuilder.tsxindex 43051b15e..dfeaa0a58 100644--- a/client/src/components/SiteSettings/ScriptBuilder.tsx+++ b/client/src/components/SiteSettings/ScriptBuilder.tsx@@ -6,6 +6,7 @@ import { Label } from "@/components/ui/label";import { Switch } from "@/components/ui/switch";import { Textarea } from "@/components/ui/textarea";import { useState } from "react";+import { IS_CLOUD } from "../../lib/const";interface ScriptBuilderProps {siteId: number;@@ -270,27 +271,29 @@ export function ScriptBuilder({ siteId }: ScriptBuilderProps) {</div> */}{/* Web Vitals Option */}- <div className="space-y-2">- <div className="flex items-center justify-between">- <div>- <Label- htmlFor="webVitals"- className="text-sm font-medium text-foreground block"- >- Enable Web Vitals performance metrics- </Label>- <p className="text-xs text-muted-foreground mt-1">- Collect Core Web Vitals (LCP, CLS, INP) and additional metrics- (FCP, TTFB)- </p>+ {IS_CLOUD && (+ <div className="space-y-2">+ <div className="flex items-center justify-between">+ <div>+ <Label+ htmlFor="webVitals"+ className="text-sm font-medium text-foreground block"+ >+ Enable Web Vitals performance metrics+ </Label>+ <p className="text-xs text-muted-foreground mt-1">+ Collect Core Web Vitals (LCP, CLS, INP) and additional+ metrics (FCP, TTFB)+ </p>+ </div>+ <Switch+ id="webVitals"+ checked={webVitals}+ onCheckedChange={setWebVitals}+ /></div>- <Switch- id="webVitals"- checked={webVitals}- onCheckedChange={setWebVitals}- /></div>- </div>+ )}{/* Track Errors Option */}<div className="space-y-2">