diff --git a/CHANGELOG.md b/CHANGELOG.md index 76af938..2fee81c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ## [Unreleased] +### Improved + +- **Cleaner site navigation.** Dashboard, Uptime, Funnels, and Settings now use an underline tab bar instead of floating buttons. The active section is highlighted with an orange underline, making it easy to see where you are and switch between views. + +### Fixed + +- **Login no longer gets stuck after updates.** If you happened to have Pulse open when a new version was deployed, logging back in could get stuck on a loading screen. The app now automatically refreshes itself to pick up the latest version. +- **City and region data is now accurate.** Location data was incorrectly showing the CDN server's location (e.g. Paris, Villeurbanne) instead of the visitor's actual city. Fixed by reading the correct visitor IP header from Bunny CDN. +- **"Reset Data" now clears everything.** Previously, resetting a site's data in Settings only removed pageviews and daily stats. Uptime check history, uptime daily stats, and cached dashboard data were left behind. All collected data is now properly cleared when you reset, while your site configuration, goals, funnels, and uptime monitors are kept. + ## [0.13.0-alpha] - 2026-03-07 ### Added diff --git a/app/auth/callback/page.tsx b/app/auth/callback/page.tsx index 2359b75..0452bf5 100644 --- a/app/auth/callback/page.tsx +++ b/app/auth/callback/page.tsx @@ -22,7 +22,14 @@ function AuthCallbackContent() { const codeVerifier = localStorage.getItem('oauth_code_verifier') const redirectUri = typeof window !== 'undefined' ? window.location.origin + '/auth/callback' : '' if (!code) return - const result = await exchangeAuthCode(code, codeVerifier, redirectUri) + let result: Awaited> + try { + result = await exchangeAuthCode(code, codeVerifier, redirectUri) + } catch { + // * Stale build or network error — show error so user can retry via full navigation + setError('Something went wrong. Please try logging in again.') + return + } if (result.success && result.user) { // * Fetch full profile (including display_name) before navigating so header shows correct name on first paint try { diff --git a/app/sites/[id]/funnels/page.tsx b/app/sites/[id]/funnels/page.tsx index 2b565c4..ff3e0e9 100644 --- a/app/sites/[id]/funnels/page.tsx +++ b/app/sites/[id]/funnels/page.tsx @@ -6,6 +6,7 @@ import { listFunnels, deleteFunnel, type Funnel } from '@/lib/api/funnels' import { toast, PlusIcon, ArrowRightIcon, ChevronLeftIcon, TrashIcon, Button } from '@ciphera-net/ui' import { FunnelsListSkeleton, useMinimumLoading } from '@/components/skeletons' import Link from 'next/link' +import SiteNav from '@/components/dashboard/SiteNav' export default function FunnelsPage() { const params = useParams() @@ -52,14 +53,10 @@ export default function FunnelsPage() { return (
+ +
-
- - - +

Funnels @@ -68,14 +65,12 @@ export default function FunnelsPage() { Track user journeys and identify drop-off points

-
- - - -
+ + +
{funnels.length === 0 ? ( diff --git a/app/sites/[id]/page.tsx b/app/sites/[id]/page.tsx index 4c878d0..61809c0 100644 --- a/app/sites/[id]/page.tsx +++ b/app/sites/[id]/page.tsx @@ -1,6 +1,6 @@ 'use client' -import { useAuth } from '@/lib/auth/context' + import { logger } from '@/lib/utils/logger' import { useCallback, useEffect, useState, useMemo } from 'react' import { useParams, useRouter, useSearchParams } from 'next/navigation' @@ -34,6 +34,7 @@ import PerformanceStats from '@/components/dashboard/PerformanceStats' import GoalStats from '@/components/dashboard/GoalStats' import ScrollDepth from '@/components/dashboard/ScrollDepth' import Campaigns from '@/components/dashboard/Campaigns' +import SiteNav from '@/components/dashboard/SiteNav' import FilterBar from '@/components/dashboard/FilterBar' import AddFilterDropdown, { type FilterSuggestion, type FilterSuggestions } from '@/components/dashboard/AddFilterDropdown' import EventProperties from '@/components/dashboard/EventProperties' @@ -79,8 +80,8 @@ function getInitialDateRange(): { start: string; end: string } { } export default function SiteDashboardPage() { - const { user } = useAuth() - const canEdit = user?.role === 'owner' || user?.role === 'admin' + + const params = useParams() const router = useRouter() @@ -494,39 +495,12 @@ export default function SiteDashboardPage() { ]} />
-
-
- - - {canEdit && ( - - )} -
+ + {/* Dimension Filters */}
diff --git a/app/sites/[id]/settings/page.tsx b/app/sites/[id]/settings/page.tsx index e5d34ea..fefa324 100644 --- a/app/sites/[id]/settings/page.tsx +++ b/app/sites/[id]/settings/page.tsx @@ -15,6 +15,7 @@ import { APP_URL } from '@/lib/api/client' import { generatePrivacySnippet } from '@/lib/utils/privacySnippet' import { useUnsavedChanges } from '@/lib/hooks/useUnsavedChanges' import { getSubscription, type SubscriptionDetails } from '@/lib/api/billing' +import SiteNav from '@/components/dashboard/SiteNav' import { getRetentionOptionsForPlan, formatRetentionMonths } from '@/lib/plans' import { motion, AnimatePresence } from 'framer-motion' import { useAuth } from '@/lib/auth/context' @@ -403,6 +404,8 @@ export default function SiteSettingsPage() { return (
+ +

Site Settings

diff --git a/app/sites/[id]/uptime/page.tsx b/app/sites/[id]/uptime/page.tsx index 85a666b..09ac33c 100644 --- a/app/sites/[id]/uptime/page.tsx +++ b/app/sites/[id]/uptime/page.tsx @@ -21,6 +21,7 @@ import { toast } from '@ciphera-net/ui' import { useTheme } from '@ciphera-net/ui' import { getAuthErrorMessage } from '@ciphera-net/ui' import { Button, Modal } from '@ciphera-net/ui' +import SiteNav from '@/components/dashboard/SiteNav' import { UptimeSkeleton, ChecksSkeleton, useMinimumLoading } from '@/components/skeletons' import { AreaChart, @@ -723,21 +724,14 @@ export default function UptimePage() { transition={{ duration: 0.2 }} className="w-full max-w-6xl mx-auto px-4 sm:px-6 py-8" > + + {/* Header */}
-
- - / -

- Uptime -

-
+

+ Uptime +

Monitor your endpoints and track availability over time

diff --git a/components/dashboard/SiteNav.tsx b/components/dashboard/SiteNav.tsx new file mode 100644 index 0000000..0c3bae6 --- /dev/null +++ b/components/dashboard/SiteNav.tsx @@ -0,0 +1,54 @@ +'use client' + +import Link from 'next/link' +import { usePathname } from 'next/navigation' +import { useTabListKeyboard } from '@/lib/hooks/useTabListKeyboard' +import { useAuth } from '@/lib/auth/context' + +interface SiteNavProps { + siteId: string +} + +export default function SiteNav({ siteId }: SiteNavProps) { + const pathname = usePathname() + const handleTabKeyDown = useTabListKeyboard() + const { user } = useAuth() + const canEdit = user?.role === 'owner' || user?.role === 'admin' + + const tabs = [ + { label: 'Dashboard', href: `/sites/${siteId}` }, + { label: 'Uptime', href: `/sites/${siteId}/uptime` }, + { label: 'Funnels', href: `/sites/${siteId}/funnels` }, + ...(canEdit ? [{ label: 'Settings', href: `/sites/${siteId}/settings` }] : []), + ] + + const isActive = (href: string) => { + if (href === `/sites/${siteId}`) { + return pathname === href || pathname === `${href}/realtime` + } + return pathname.startsWith(href) + } + + return ( +
+ +
+ ) +} diff --git a/lib/auth/context.tsx b/lib/auth/context.tsx index 95f8b39..db49ca7 100644 --- a/lib/auth/context.tsx +++ b/lib/auth/context.tsx @@ -90,7 +90,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { const logout = useCallback(async () => { setIsLoggingOut(true) - await logoutAction() + try { await logoutAction() } catch { /* stale build — continue with client-side cleanup */ } localStorage.removeItem('user') localStorage.removeItem('ciphera_token_refreshed_at') localStorage.removeItem('ciphera_last_activity') @@ -132,7 +132,14 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { useEffect(() => { const init = async () => { // * 1. Check server-side session (cookies) - let session = await getSessionAction() + let session: Awaited> = null + try { + session = await getSessionAction() + } catch { + // * Stale build — treat as no session. The login page will redirect + // * to the auth service via window.location.href (full navigation), + // * which fetches fresh HTML/JS from the server on return. + } // * 2. If no access_token but refresh_token may exist, try refresh (fixes 15-min inactivity logout) if (!session && typeof window !== 'undefined') { @@ -142,7 +149,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { credentials: 'include', }) if (refreshRes.ok) { - session = await getSessionAction() + try { + session = await getSessionAction() + } catch { + // * Stale build — fall through as no session + } } } diff --git a/next.config.ts b/next.config.ts index a8ec28d..0052619 100644 --- a/next.config.ts +++ b/next.config.ts @@ -47,6 +47,14 @@ const nextConfig: NextConfig = { }, async headers() { return [ + { + // * Prevent CDN/browser from serving stale HTML after deploys. + // * Static assets (/_next/static/*) are content-hashed and cached separately by Next.js. + source: '/((?!_next/static|_next/image).*)', + headers: [ + { key: 'Cache-Control', value: 'no-cache, must-revalidate' }, + ], + }, { source: '/(.*)', headers: [