🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor page titles display and enhance analytics data integration
Bill Yangdd18bd1a4a73
diff --git a/client/messages/cs.json b/client/messages/cs.jsonindex 3e2bb0b5e..595edc878 100644--- a/client/messages/cs.json+++ b/client/messages/cs.json@@ -432,10 +432,13 @@"vde3+c": "Unikátní návštěvníci","7X21Cw": "Týdenní trendy","Oh4usQ": "Vyber metriku",- "QAJbR9": "průměrný čas",- "dpse/L": "stránky",- "W0b2A/": "Chyba při načítání dat o stránkách",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "Pro zvolené období nebyla nalezena žádná data o stránkách.",+ "dpse/L": "stránky","f3v0b6": "Sběr Web Vitals je vypnutý","2HxPBE": "Sběr Web Vitals poskytuje metriky Core Web Vitals jako LCP, CLS a INP.","sE0HjV": "Zapnutí Web Vitals zvýší spotřebu událostí.",diff --git a/client/messages/de.json b/client/messages/de.jsonindex 029e1ba3a..7f61caee8 100644--- a/client/messages/de.json+++ b/client/messages/de.json@@ -432,10 +432,13 @@"vde3+c": "Eindeutige Besucher","7X21Cw": "Wöchentliche Trends","Oh4usQ": "Metrik auswählen",- "QAJbR9": "Durchschn. Zeit",- "dpse/L": "Seiten",- "W0b2A/": "Fehler beim Laden der Seitendaten",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "Keine Seitendaten für den ausgewählten Zeitraum gefunden.",+ "dpse/L": "Seiten","f3v0b6": "Web Vitals-Erfassung ist deaktiviert","2HxPBE": "Die Web Vitals-Erfassung liefert Core Web Vitals-Metriken wie LCP, CLS und INP.","sE0HjV": "Das Aktivieren von Web Vitals erhöht Ihren Event-Verbrauch.",diff --git a/client/messages/en.json b/client/messages/en.jsonindex d511a2753..421319ecc 100644--- a/client/messages/en.json+++ b/client/messages/en.json@@ -432,10 +432,13 @@"vde3+c": "Unique Visitors","7X21Cw": "Weekly Trends","Oh4usQ": "Select metric",- "QAJbR9": "avg time",- "dpse/L": "pages",- "W0b2A/": "Error loading pages data",+ "WZTXKm": "Trend",+ "akF0Ly": "Views",+ "wBSk/Y": "Bounce",+ "7kRLeH": "Failed to load pages",+ "ICwzfm": "There was a problem fetching the pages. Please try again later.","+w1g/1": "No pages data found for the selected period.",+ "dpse/L": "pages","f3v0b6": "Web Vitals Collection is Disabled","2HxPBE": "Web Vitals collection provides Core Web Vitals metrics like LCP, CLS, and INP.","sE0HjV": "Enabling Web Vitals will increase your event usage.",diff --git a/client/messages/es.json b/client/messages/es.jsonindex 9fce99095..03054751a 100644--- a/client/messages/es.json+++ b/client/messages/es.json@@ -432,10 +432,13 @@"vde3+c": "Visitantes únicos","7X21Cw": "Tendencias semanales","Oh4usQ": "Seleccionar métrica",- "QAJbR9": "tiempo promedio",- "dpse/L": "páginas",- "W0b2A/": "Error al cargar datos de páginas",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "No se encontraron datos de páginas para el periodo seleccionado.",+ "dpse/L": "páginas","f3v0b6": "Recopilación de Web Vitals Desactivada","2HxPBE": "La recopilación de Web Vitals proporciona métricas clave como LCP, CLS e INP.","sE0HjV": "Activar Web Vitals aumentará tu uso de eventos.",diff --git a/client/messages/fr.json b/client/messages/fr.jsonindex 468c53255..2a96fdc17 100644--- a/client/messages/fr.json+++ b/client/messages/fr.json@@ -432,10 +432,13 @@"vde3+c": "Visiteurs uniques","7X21Cw": "Tendances hebdomadaires","Oh4usQ": "Sélectionner une métrique",- "QAJbR9": "temps moy.",- "dpse/L": "pages",- "W0b2A/": "Erreur lors du chargement des données de pages",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "Aucune donnée de pages trouvée pour la période sélectionnée.",+ "dpse/L": "pages","f3v0b6": "La collecte des Web Vitals est désactivée","2HxPBE": "La collecte des Web Vitals fournit des métriques Core Web Vitals comme LCP, CLS et INP.","sE0HjV": "L'activation des Web Vitals augmentera votre consommation d'événements.",diff --git a/client/messages/it.json b/client/messages/it.jsonindex e763eb77a..2a1e4b822 100644--- a/client/messages/it.json+++ b/client/messages/it.json@@ -432,10 +432,13 @@"vde3+c": "Visitatori Unici","7X21Cw": "Tendenze Settimanali","Oh4usQ": "Seleziona metrica",- "QAJbR9": "tempo medio",- "dpse/L": "pagine",- "W0b2A/": "Errore nel caricamento dei dati delle pagine",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "Nessun dato delle pagine trovato per il periodo selezionato.",+ "dpse/L": "pagine","f3v0b6": "La raccolta dei Web Vitals è Disabilitata","2HxPBE": "La raccolta dei Web Vitals fornisce metriche Core Web Vitals come LCP, CLS e INP.","sE0HjV": "Abilitare i Web Vitals aumenterà l'utilizzo degli eventi.",diff --git a/client/messages/ja.json b/client/messages/ja.jsonindex b5c48c86a..eb2a1393d 100644--- a/client/messages/ja.json+++ b/client/messages/ja.json@@ -432,10 +432,13 @@"vde3+c": "ユニーク訪問者","7X21Cw": "週間トレンド","Oh4usQ": "指標を選択",- "QAJbR9": "平均時間",- "dpse/L": "ページ",- "W0b2A/": "ページデータの読み込みエラー",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "選択した期間のページデータが見つかりません。",+ "dpse/L": "ページ","f3v0b6": "Web Vitals収集は無効です","2HxPBE": "Web Vitals収集はLCP、CLS、INPなどのCore Web Vitals指標を提供します。","sE0HjV": "Web Vitalsを有効にするとイベント使用量が増加します。",diff --git a/client/messages/ko.json b/client/messages/ko.jsonindex fc5805dc6..5c329a05f 100644--- a/client/messages/ko.json+++ b/client/messages/ko.json@@ -432,10 +432,13 @@"vde3+c": "고유 방문자","7X21Cw": "주간 트렌드","Oh4usQ": "지표 선택",- "QAJbR9": "평균 시간",- "dpse/L": "페이지",- "W0b2A/": "페이지 데이터 로드 오류",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "선택한 기간에 대한 페이지 데이터를 찾을 수 없습니다.",+ "dpse/L": "페이지","f3v0b6": "Web Vitals 수집이 비활성화됨","2HxPBE": "Web Vitals 수집은 LCP, CLS, INP와 같은 Core Web Vitals 지표를 제공합니다.","sE0HjV": "Web Vitals를 활성화하면 이벤트 사용량이 증가합니다.",diff --git a/client/messages/pl.json b/client/messages/pl.jsonindex 51b7cde2a..1a1917de9 100644--- a/client/messages/pl.json+++ b/client/messages/pl.json@@ -432,10 +432,13 @@"vde3+c": "Unikalni odwiedzający","7X21Cw": "Trendy tygodniowe","Oh4usQ": "Wybierz metrykę",- "QAJbR9": "śr. czas",- "dpse/L": "strony",- "W0b2A/": "Błąd ładowania danych stron",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "Nie znaleziono danych stron dla wybranego okresu.",+ "dpse/L": "strony","f3v0b6": "Zbieranie Web Vitals jest wyłączone","2HxPBE": "Zbieranie Web Vitals dostarcza metryki Core Web Vitals, takie jak LCP, CLS i INP.","sE0HjV": "Włączenie Web Vitals zwiększy zużycie zdarzeń.",diff --git a/client/messages/pt.json b/client/messages/pt.jsonindex f3b33dad3..042ee6624 100644--- a/client/messages/pt.json+++ b/client/messages/pt.json@@ -247,8 +247,8 @@"Um1u7W": "Funil atualizado com sucesso","F9J0jM": "Falha ao clonar funil: {message}","4gZ72q": "Falha ao atualizar funil: {message}",- "IZnwKa": "Editar Funil","gMhqKV": "Clonar Funil",+ "IZnwKa": "Editar Funil","rIc2Hm": "Atualizar Funil","29V0Ci": "sessões","lHFZhY": "{count} abandonaram",@@ -432,10 +432,13 @@"vde3+c": "Visitantes Únicos","7X21Cw": "Tendências Semanais","Oh4usQ": "Selecionar métrica",- "QAJbR9": "tempo médio",- "dpse/L": "páginas",- "W0b2A/": "Erro ao carregar dados de páginas",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "Nenhum dado de páginas encontrado para o período selecionado.",+ "dpse/L": "páginas","f3v0b6": "Coleta de Web Vitals Desativada","2HxPBE": "A coleta de Web Vitals fornece métricas Core Web Vitals como LCP, CLS e INP.","sE0HjV": "Ativar Web Vitals aumentará o uso de eventos.",@@ -860,8 +863,8 @@"EjE0iv": "Time criado com sucesso","hfiE8k": "Falha ao atualizar time","DswPK3": "Falha ao criar time",- "97DGta": "Criar time","U01dmA": "Editar time",+ "97DGta": "Criar time","03IKqU": "Atualize o nome do time, membros e atribuições de sites.","Ps71bZ": "Crie um novo time para agrupar sites e controlar o acesso dos membros.","k+kHlN": "Nome do time",diff --git a/client/messages/uk.json b/client/messages/uk.jsonindex 4fa6781ee..c4fc2fb23 100644--- a/client/messages/uk.json+++ b/client/messages/uk.json@@ -432,10 +432,13 @@"vde3+c": "Унікальні відвідувачі","7X21Cw": "Тижневі тренди","Oh4usQ": "Виберіть метрику",- "QAJbR9": "сер. час",- "dpse/L": "сторінки",- "W0b2A/": "Помилка завантаження даних сторінок",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "Не знайдено даних сторінок за вибраний період.",+ "dpse/L": "сторінки","f3v0b6": "Збір Web Vitals вимкнено","2HxPBE": "Збір Web Vitals надає доступ до основних інтернет-показників (Core Web Vitals), таких як LCP, CLS та INP.","sE0HjV": "Увімкнення Web Vitals збільшить кількість використаних подій.",diff --git a/client/messages/zh.json b/client/messages/zh.jsonindex 9bf94c486..1db5bf277 100644--- a/client/messages/zh.json+++ b/client/messages/zh.json@@ -432,10 +432,13 @@"vde3+c": "独立访客","7X21Cw": "每周趋势","Oh4usQ": "选择指标",- "QAJbR9": "平均时间",- "dpse/L": "页面",- "W0b2A/": "加载页面数据出错",+ "WZTXKm": "",+ "akF0Ly": "",+ "wBSk/Y": "",+ "7kRLeH": "",+ "ICwzfm": "","+w1g/1": "在选定的时间段内未找到页面数据。",+ "dpse/L": "页面","f3v0b6": "Web Vitals 收集已禁用","2HxPBE": "Web Vitals 收集提供 Core Web Vitals 指标,如 LCP、CLS 和 INP。","sE0HjV": "启用 Web Vitals 将增加您的事件使用量。",diff --git a/client/src/api/analytics/endpoints/misc.ts b/client/src/api/analytics/endpoints/misc.tsindex b432f0c50..53de5801b 100644--- a/client/src/api/analytics/endpoints/misc.ts+++ b/client/src/api/analytics/endpoints/misc.ts@@ -28,6 +28,8 @@ export type PageTitleItem = {pathname: string; // A representative pathnamecount: number;percentage: number;+ pageviews?: number;+ bounce_rate?: number;time_on_page_seconds?: number;};diff --git a/client/src/api/analytics/hooks/useGetPageTitles.ts b/client/src/api/analytics/hooks/useGetPageTitles.tsindex c35bad278..d42e5a558 100644--- a/client/src/api/analytics/hooks/useGetPageTitles.ts+++ b/client/src/api/analytics/hooks/useGetPageTitles.ts@@ -3,10 +3,13 @@ import { useQuery, UseQueryResult } from "@tanstack/react-query";import { buildApiParams } from "../../utils";import { fetchPageTitles, PageTitlesPaginatedResponse } from "../endpoints";+type PeriodTime = "current" | "previous";+type UseGetPageTitlesOptions = {limit?: number;page?: number;useFilters?: boolean;+ periodTime?: PeriodTime;};// Hook for paginated fetching (e.g., for a dedicated "All Page Titles" screen)@@ -14,13 +17,15 @@ export function useGetPageTitlesPaginated({limit = 10,page = 1,useFilters = true,+ periodTime = "current",}: UseGetPageTitlesOptions): UseQueryResult<{ data: PageTitlesPaginatedResponse }> {- const { time, site, filters, timezone } = useStore();+ const { time, previousTime, site, filters, timezone } = useStore();- const params = buildApiParams(time, { filters: useFilters ? filters : undefined });+ const timeToUse = periodTime === "previous" ? previousTime : time;+ const params = buildApiParams(timeToUse, { filters: useFilters ? filters : undefined });return useQuery({- queryKey: ["page-titles", time, site, filters, limit, page, useFilters, timezone],+ queryKey: ["page-titles", timeToUse, site, filters, limit, page, useFilters, timezone, periodTime],queryFn: async () => {const data = await fetchPageTitles(site, {...params,diff --git a/client/src/app/[site]/pages/components/PageListItem.tsx b/client/src/app/[site]/pages/components/PageListItem.tsxdeleted file mode 100644index 512919a2a..000000000--- a/client/src/app/[site]/pages/components/PageListItem.tsx+++ /dev/null@@ -1,158 +0,0 @@-"use client";--import { useGetSite } from "@/api/admin/hooks/useSites";-import { useGetOverviewBucketed } from "@/api/analytics/hooks/useGetOverviewBucketed";-import { MetricResponse } from "@/api/analytics/endpoints";-import { usePageMetadata } from "@/api/usePageMetadata";-import { Card, CardContent } from "@/components/ui/card";-import { Filter } from "@rybbit/shared";-import { useStore } from "@/lib/store";-import { MINUTES_IN_24_HOURS } from "@/lib/const";-import { truncateString } from "@/lib/utils";-import { formatShortDuration } from "@/lib/dateTimeUtils";-import { ExternalLink } from "lucide-react";-import { useExtracted } from "next-intl";-import Link from "next/link";-import { useState } from "react";-import { PageSparklineChart } from "./PageSparklineChart";--// Maximum length for page titles-const MAX_TITLE_LENGTH = 90;--type PageListItemProps = {- pageData: MetricResponse;- isLoading?: boolean;-};--export function PageListItem({ pageData, isLoading = false }: PageListItemProps) {- const t = useExtracted();- const [isHovering, setIsHovering] = useState(false);- const [thumbnailError, setThumbnailError] = useState(false);- const { data: siteMetadata } = useGetSite();- const { site, time, bucket } = useStore(); // Get time and bucket from store-- const isPastMinutesMode = time.mode === "past-minutes";-- // Create a pathname filter for this specific page- const pageSpecificFilter: Filter = {- parameter: "page_title",- value: [pageData.title ?? ""],- type: "equals",- };-- // Regular bucketed data for sparklines- const { data: regularData, isLoading: isLoadingRegular } = useGetOverviewBucketed({- site,- bucket,- dynamicFilters: [pageSpecificFilter],- props: {- enabled: !isPastMinutesMode,- },- });-- // Past minutes data for sparklines- const { data: pastMinutesData, isLoading: isLoadingPastMinutes } = useGetOverviewBucketed({- site,- bucket,- dynamicFilters: [- {- parameter: "pathname",- type: "equals",- value: [pageData.value],- },- ],- props: {- enabled: isPastMinutesMode,- },- });-- // Use the appropriate data source based on mode- const pageTrafficData = isPastMinutesMode ? pastMinutesData : regularData;- const isLoadingTrafficData = isPastMinutesMode ? isLoadingPastMinutes : isLoadingRegular;-- // External URL for the page- const pageUrl = pageData.hostname- ? `https://${pageData.hostname}${pageData.value}`- : siteMetadata?.domain- ? `https://${siteMetadata.domain}${pageData.value}`- : "";-- // Fetch page metadata using TanStack Query- const { data: metadata, isLoading: isLoadingMetadata, isError: isMetadataError } = usePageMetadata(pageUrl);-- // Get thumbnail URL from metadata- const thumbnailUrl = !thumbnailError && !isMetadataError ? metadata?.image : null;-- // Handle image error- const handleImageError = () => {- setThumbnailError(true);- };-- return (- <Card className="w-full mb-3 overflow-visible" onMouseEnter={() => setIsHovering(true)} onMouseLeave={() => setIsHovering(false)}>- <CardContent className="p-3">- <div className="flex flex-col md:flex-row justify-between items-start md:items-center w-full gap-4">- {/* Left side: Page title/path with thumbnail */}- <div className="flex gap-3 flex-1 min-w-0">- {thumbnailUrl && !isLoadingMetadata && (- <div className="hidden sm:block shrink-0 h-12 w-16 relative rounded-md overflow-hidden border border-neutral-100 dark:border-neutral-800">- <img- src={thumbnailUrl}- alt={`Thumbnail for ${pageData.title || pageData.value}`}- className="w-full h-full object-cover"- onError={handleImageError}- />- </div>- )}-- <div className="flex-1 min-w-0">- <div className="flex items-center gap-2">- <h3 className="text-base font-medium truncate">- {truncateString(pageData.title || pageData.value, MAX_TITLE_LENGTH)}- </h3>- {pageUrl && (- <Link- href={pageUrl}- target="_blank"- rel="noopener noreferrer"- className="text-muted-foreground hover:text-primary"- >- <ExternalLink className="h-4 w-4" />- </Link>- )}- </div>- <p className="text-sm text-muted-foreground truncate">{pageData.value}</p>- </div>- </div>-- {/* Right side: Sparkline chart and session count */}- <div className="flex items-center gap-0 w-full md:w-auto">- {/* Sparkline chart */}- <div className="h-12 w-40">- <PageSparklineChart- data={pageTrafficData}- isHovering={isHovering}- pageTitle={pageData.title || pageData.value}- isLoading={isLoadingTrafficData}- />- </div>-- {/* Session count and duration */}- <div className="text-right min-w-[120px]">- <div>- <span className="text-base font-semibold">{pageData.count.toLocaleString()}</span>- <span className="text-xs text-foreground/70"> {t("sessions")}</span>- </div>- {pageData.time_on_page_seconds !== undefined && (- <div>- <span className="text-base font-semibold">{formatShortDuration(pageData.time_on_page_seconds)} </span>- <span className="text-xs text-foreground/70">{t("avg time")}</span>- </div>- )}- </div>- </div>- </div>- </CardContent>- </Card>- );-}diff --git a/client/src/app/[site]/pages/components/PageListSkeleton.tsx b/client/src/app/[site]/pages/components/PageListSkeleton.tsxdeleted file mode 100644index edfab54dc..000000000--- a/client/src/app/[site]/pages/components/PageListSkeleton.tsx+++ /dev/null@@ -1,58 +0,0 @@-"use client";--import { Card, CardContent } from "@/components/ui/card";-import { Skeleton } from "@/components/ui/skeleton";--type PageListSkeletonProps = {- count?: number;-};--export function PageListSkeleton({ count = 5 }: PageListSkeletonProps) {- return (- <>- {Array.from({ length: count }).map((_, index) => (- <Card key={index} className="w-full mb-3">- <CardContent className="p-3">- <div className="flex flex-col md:flex-row justify-between items-start md:items-center w-full gap-4">- {/* Left side: Page title/path with thumbnail skeleton */}- <div className="flex gap-3 flex-1 min-w-0">- {/* Thumbnail skeleton - conditionally shown like in PageListItem */}- <div className="hidden sm:block shrink-0 h-12 w-16 relative rounded-md overflow-hidden border border-neutral-100 dark:border-neutral-800">- <Skeleton className="w-full h-full" />- </div>-- <div className="flex-1 min-w-0">- <div className="flex items-center gap-2">- <Skeleton className="h-6 w-64" />- <Skeleton className="h-4 w-4" /> {/* External link icon skeleton */}- </div>- <Skeleton className="h-4 w-48 mt-1" />- </div>- </div>-- {/* Right side: Sparkline and session count/duration skeleton */}- <div className="flex items-center gap-0 w-full md:w-auto">- {/* Sparkline chart placeholder */}- <div className="h-12 w-40">- <Skeleton className="h-full w-full rounded-md" />- </div>-- {/* Session count and duration placeholder */}- <div className="text-right min-w-[120px]">- {/* Sessions count */}- <div className="mb-1">- <Skeleton className="h-5 w-20 ml-auto" />- </div>- {/* Average time */}- <div>- <Skeleton className="h-5 w-16 ml-auto" />- </div>- </div>- </div>- </div>- </CardContent>- </Card>- ))}- </>- );-}diff --git a/client/src/app/[site]/pages/page.tsx b/client/src/app/[site]/pages/page.tsxindex c0a5c7752..341b502cc 100644--- a/client/src/app/[site]/pages/page.tsx+++ b/client/src/app/[site]/pages/page.tsx@@ -1,143 +1,27 @@"use client";import { useExtracted } from "next-intl";-import { useGetPageTitlesPaginated } from "@/api/analytics/hooks/useGetPageTitles";-import { PageTitleItem } from "@/api/analytics/endpoints";-import { Pagination } from "@/components/pagination";import { useSetPageTitle } from "@/hooks/useSetPageTitle";import { useStore } from "@/lib/store";-import { useEffect, useState } from "react";import { DisabledOverlay } from "../../../components/DisabledOverlay";import { SubHeader } from "../components/SubHeader/SubHeader";-import { PageListItem } from "./components/PageListItem";-import { PageListSkeleton } from "./components/PageListSkeleton";--// Number of items per page-const PAGE_SIZE = 10;+import { PagesTable } from "./components/PagesTable";export default function Pages() {const t = useExtracted();const { site } = useStore();- const [pagination, setPagination] = useState({- pageIndex: 0,- pageSize: PAGE_SIZE,- });- const [totalPages, setTotalPages] = useState(0);-useSetPageTitle("Pages");- // Get page number (1-based) from pageIndex (0-based)- const pageNumber = pagination.pageIndex + 1;-- const {- data: apiResponse,- isLoading: isLoadingPages,- isError: isErrorPages,- error: pagesError,- isPlaceholderData,- isFetching,- } = useGetPageTitlesPaginated({- limit: pagination.pageSize,- page: pageNumber,- });-- const pagesDataArray: PageTitleItem[] | undefined = apiResponse?.data?.data;- const totalCount: number | undefined = apiResponse?.data?.totalCount;-- const isLoading = isLoadingPages || isFetching;-- // Create a minimal table object with the required pagination methods- const table = {- getState: () => ({- pagination: {- pageIndex: pagination.pageIndex,- pageSize: pagination.pageSize,- },- }),- getCanPreviousPage: () => pagination.pageIndex > 0,- getCanNextPage: () => {- if (totalCount === undefined) return true;- return (pagination.pageIndex + 1) * pagination.pageSize < totalCount;- },- getPageCount: () => totalPages,- setPageIndex: (index: number) => setPagination({ ...pagination, pageIndex: index }),- previousPage: () => setPagination({ ...pagination, pageIndex: pagination.pageIndex - 1 }),- nextPage: () => setPagination({ ...pagination, pageIndex: pagination.pageIndex + 1 }),- };-- useEffect(() => {- if (!isLoadingPages && !isPlaceholderData && !isFetching) {- if (totalCount !== undefined) {- setTotalPages(Math.ceil(totalCount / pagination.pageSize));- } else if (pagesDataArray && pagesDataArray.length === 0 && pagination.pageIndex === 0) {- // Fallback if totalCount is somehow undefined but we have an empty array on page 1- setTotalPages(0);- } else if (pagesDataArray && pagesDataArray.length < pagination.pageSize) {- // Fallback: if less than a full page is returned, assume it's the last- setTotalPages(pagination.pageIndex + 1);- }- } else if (pagination.pageIndex === 0 && isLoadingPages && !pagesDataArray) {- // Initial load, no data yet- setTotalPages(0);- }- }, [- apiResponse,- totalCount,- pagesDataArray,- isLoadingPages,- isPlaceholderData,- isFetching,- pagination.pageIndex,- pagination.pageSize,- ]);-if (!site) {return null;}return (<DisabledOverlay message={t("pages")} featurePath="pages">- <div className="p-2 md:p-4 max-w-[1100px] mx-auto space-y-3">+ <div className="p-2 md:p-4 max-w-[1400px] mx-auto space-y-3"><SubHeader />-- {isLoading ? (- <PageListSkeleton count={pagination.pageSize} />- ) : isErrorPages ? (- <div className="text-center p-8 text-destructive">- <p>{t("Error loading pages data")}</p>- <p className="text-sm">{pagesError?.toString()}</p>- </div>- ) : pagesDataArray && pagesDataArray.length > 0 ? (- <>- {pagesDataArray.map((pageItem: PageTitleItem, index: number) => (- <PageListItem- key={`${pageItem.value}-${index}-${pagination.pageIndex}`}- pageData={{- value: pageItem.pathname,- title: pageItem.value,- count: pageItem.count,- percentage: pageItem.percentage,- time_on_page_seconds: pageItem.time_on_page_seconds,- }}- />- ))}- {totalPages > 0 && (- <Pagination- table={table}- data={{ items: pagesDataArray || [], total: totalCount || 0 }}- pagination={pagination}- setPagination={setPagination}- isLoading={isLoading}- itemName={t("pages")}- />- )}- </>- ) : !isLoadingPages && !isFetching ? (- <div className="text-center py-12 text-muted-foreground">- <p>{t("No pages data found for the selected period.")}</p>- </div>- ) : null}+ <PagesTable /></div></DisabledOverlay>);diff --git a/server/src/api/analytics/getPageTitles.ts b/server/src/api/analytics/getPageTitles.tsindex d04fda2d8..88ddacd00 100644--- a/server/src/api/analytics/getPageTitles.ts+++ b/server/src/api/analytics/getPageTitles.ts@@ -20,6 +20,8 @@ export type PageTitleItem = {pathname: string;count: number;percentage: number;+ pageviews?: number;+ bounce_rate?: number;time_on_page_seconds?: number;};@@ -59,6 +61,17 @@ const getPageTitlesQuery = (request: FastifyRequest<GetPageTitlesRequest>, isCou// We also need a representative pathname and calculate average time on page.// Using argMax to get the pathname from the most recent event for that title in a session.const baseCteQuery = `+ SessionPageCounts AS (+ SELECT+ session_id,+ COUNT() as pageviews_in_session+ FROM events+ WHERE+ site_id = {siteId:Int32}+ AND type = 'pageview'+ ${timeStatement}+ GROUP BY session_id+ ),EventTimes AS (SELECTsession_id,@@ -77,19 +90,23 @@ const getPageTitlesQuery = (request: FastifyRequest<GetPageTitlesRequest>, isCou),PageDurations AS (SELECT- session_id,- page_title,- pathname,- timestamp,- next_timestamp,- if(isNull(next_timestamp), 0, dateDiff('second', timestamp, next_timestamp)) as time_diff_seconds- FROM EventTimes+ e.session_id as session_id,+ e.page_title as page_title,+ e.pathname as pathname,+ e.timestamp as timestamp,+ e.next_timestamp as next_timestamp,+ if(isNull(e.next_timestamp), 0, dateDiff('second', e.timestamp, e.next_timestamp)) as time_diff_seconds,+ spc.pageviews_in_session as pageviews_in_session+ FROM EventTimes e+ LEFT JOIN SessionPageCounts spc ON e.session_id = spc.session_id),PageTitleStats AS (SELECTpage_title as value,argMax(pathname, timestamp) as pathname,count(DISTINCT session_id) as unique_sessions,+ count() as pageviews,+ countIf(DISTINCT session_id, pageviews_in_session = 1) as bounced_sessions,avg(if(time_diff_seconds < 0, 0, if(time_diff_seconds > 1800, 1800, time_diff_seconds))) as avg_time_on_page_secondsFROM PageDurationsGROUP BY page_title@@ -113,6 +130,11 @@ const getPageTitlesQuery = (request: FastifyRequest<GetPageTitlesRequest>, isCouunique_sessions * 100.0 / SUM(unique_sessions) OVER (),2) as percentage,+ pageviews,+ ROUND(+ bounced_sessions * 100.0 / nullIf(unique_sessions, 0),+ 2+ ) as bounce_rate,avg_time_on_page_seconds as time_on_page_secondsFROM PageTitleStatsORDER BY count DESC