All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 28s
Build & Deploy / 🚀 Deploy (push) Successful in 34s
Build & Deploy / 🧪 QA (push) Successful in 1m43s
Build & Deploy / 🏗️ Build (push) Successful in 3m23s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 1m12s
Build & Deploy / 🔔 Notify (push) Successful in 3s
30 lines
865 B
TypeScript
30 lines
865 B
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
import { usePathname, useSearchParams } from 'next/navigation';
|
|
import { useAnalytics } from './useAnalytics';
|
|
|
|
/**
|
|
* AnalyticsProvider Component
|
|
*
|
|
* Automatically tracks pageviews on client-side route changes.
|
|
* This component handles navigation events for the Umami analytics service.
|
|
*/
|
|
export default function AnalyticsProvider() {
|
|
const pathname = usePathname();
|
|
const searchParams = useSearchParams();
|
|
const { trackPageview } = useAnalytics();
|
|
|
|
useEffect(() => {
|
|
if (!pathname) return;
|
|
|
|
const url = `${pathname}${searchParams?.size ? `?${searchParams.toString()}` : ''}`;
|
|
|
|
// Track pageview with the full URL
|
|
// The service will relay this to our internal proxy which injects the Website ID
|
|
trackPageview(url);
|
|
}, [pathname, searchParams, trackPageview]);
|
|
|
|
return null;
|
|
}
|