Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Enhance SessionCard and SessionDetails components for improved session analytics

Bill Yangdaee5b4584f5
diff --git a/client/src/app/[site]/sessions/components/SessionCard.tsx b/client/src/app/[site]/sessions/components/SessionCard.tsx
index 6aca69929..cccd40f46 100644
--- a/client/src/app/[site]/sessions/components/SessionCard.tsx
+++ b/client/src/app/[site]/sessions/components/SessionCard.tsx
@@ -11,6 +11,8 @@ import {
ChevronRight,
ArrowRight,
Clock,
+ FileText,
+ MousePointerClick,
} from "lucide-react";
import Avatar from "boring-avatars";
import { GetSessionsResponse } from "../../../../api/analytics/userSessions";
@@ -21,6 +23,7 @@ import {
TooltipTrigger,
} from "@/components/ui/tooltip";
import { SessionDetails } from "./SessionDetails";
+import { Badge } from "../../../../components/ui/badge";
interface SessionCardProps {
session: GetSessionsResponse[number];
@@ -137,6 +140,31 @@ export function SessionCard({ session, onClick }: SessionCardProps) {
<p>{session.device_type || "Unknown device"}</p>
</TooltipContent>
</Tooltip>
+
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge
+ variant="outline"
+ className="flex items-center gap-1 bg-neutral-800 text-gray-300"
+ >
+ <FileText className="w-4 h-4 text-blue-500" />
+ <span>{session.pageviews}</span>
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent>Pageviews</TooltipContent>
+ </Tooltip>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge
+ variant="outline"
+ className="flex items-center gap-1 bg-neutral-800 text-gray-300"
+ >
+ <MousePointerClick className="w-4 h-4 text-amber-500" />
+ <span>{session.events}</span>
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent>Events</TooltipContent>
+ </Tooltip>
</div>
{/* Pages section with tooltips for long paths */}
diff --git a/client/src/app/[site]/sessions/components/SessionDetails.tsx b/client/src/app/[site]/sessions/components/SessionDetails.tsx
index 391f6a92c..cb451670e 100644
--- a/client/src/app/[site]/sessions/components/SessionDetails.tsx
+++ b/client/src/app/[site]/sessions/components/SessionDetails.tsx
@@ -111,7 +111,7 @@ function PageviewItem({
<div className="flex items-center pl-7 mt-1">
<div className="text-xs text-gray-400">
<Clock className="w-3 h-3 inline mr-1 text-gray-400" />
- Time on page: {duration}
+ {duration}
</div>
</div>
)}
@@ -169,9 +169,36 @@ export function SessionDetails({ sessionId }: SessionDetailsProps) {
<div className="px-4 bg-neutral-900 border-t border-neutral-800">
{isLoading ? (
<div className="py-4">
- <Skeleton className="h-4 w-full mb-2" />
- <Skeleton className="h-4 w-3/4 mb-2" />
- <Skeleton className="h-4 w-1/2" />
+ {/* Tabs skeleton */}
+ <div className="flex gap-2 mb-6">
+ <Skeleton className="h-8 w-24 rounded-md" />
+ <Skeleton className="h-8 w-24 rounded-md" />
+ </div>
+
+ {/* Timeline tab skeleton */}
+ <div className="mb-4">
+ <div className="flex gap-2 mb-3">
+ <Skeleton className="h-6 w-32 rounded-full" />
+ <Skeleton className="h-6 w-32 rounded-full" />
+ </div>
+
+ {/* Timeline items skeleton */}
+ {[1, 2, 3].map((i) => (
+ <div key={i} className="flex mb-3">
+ <Skeleton className="h-8 w-8 rounded-full" />
+ <div className="ml-3 flex-1">
+ <div className="flex items-center">
+ <Skeleton className="h-4 w-4 mr-3" />
+ <Skeleton className="h-4 w-full max-w-md mr-4" />
+ <Skeleton className="h-3 w-16 flex-shrink-0 ml-auto" />
+ </div>
+ <div className="mt-1 pl-7">
+ <Skeleton className="h-3 w-32" />
+ </div>
+ </div>
+ </div>
+ ))}
+ </div>
</div>
) : error ? (
<Alert variant="destructive" className="mt-4">
@@ -191,7 +218,7 @@ export function SessionDetails({ sessionId }: SessionDetailsProps) {
<div className="flex gap-2 mb-2">
<Badge
variant="outline"
- className="flex items-center gap-1 bg-neutral-800 text-gray-300"
+ className="flex items-center gap-1 text-gray-300 bg-blue-500/60"
>
<FileText className="w-3 h-3" />
<span>
@@ -205,7 +232,7 @@ export function SessionDetails({ sessionId }: SessionDetailsProps) {
</Badge>
<Badge
variant="outline"
- className="flex items-center gap-1 bg-neutral-800 text-gray-300"
+ className="flex items-center gap-1 text-gray-300 bg-amber-500/60"
>
<MousePointerClick className="w-3 h-3" />
<span>
diff --git a/client/src/app/[site]/sessions/components/SessionsList.tsx b/client/src/app/[site]/sessions/components/SessionsList.tsx
index 3027db4fa..68fa3d645 100644
--- a/client/src/app/[site]/sessions/components/SessionsList.tsx
+++ b/client/src/app/[site]/sessions/components/SessionsList.tsx
@@ -57,7 +57,7 @@ export default function SessionsList({
>
{isLoading ? (
// Show skeleton cards while loading
- Array.from({ length: 10 }).map((_, index) => (
+ Array.from({ length: 30 }).map((_, index) => (
<SessionCardSkeleton key={`skeleton-${index}`} />
))
) : data.length === 0 ? (
@@ -72,7 +72,7 @@ export default function SessionsList({
)}
{isFetchingNextPage && (
- <div className="py-4">
+ <div className="">
<SessionCardSkeleton key="loading-more" />
</div>
)}
diff --git a/server/src/api/getSessions.ts b/server/src/api/getSessions.ts
index 9ecac7beb..433a18b85 100644
--- a/server/src/api/getSessions.ts
+++ b/server/src/api/getSessions.ts
@@ -85,12 +85,10 @@ GROUP BY
device_type,
operating_system
-ORDER BY session_start DESC
+ORDER BY session_end DESC
LIMIT 100 OFFSET ${(page - 1) * 100}
`;
- console.log(query);
-
try {
const result = await clickhouse.query({
query,