21 lines
618 B
TypeScript
21 lines
618 B
TypeScript
'use client';
|
|
|
|
import { useEffect } from 'react';
|
|
import { usePathname, useSearchParams } from 'next/navigation';
|
|
import { getAppServices } from '@/lib/services/create-services';
|
|
|
|
// Minimal client-side hook that sends Umami pageviews on route changes.
|
|
export default function AnalyticsProvider() {
|
|
const pathname = usePathname();
|
|
const searchParams = useSearchParams();
|
|
|
|
useEffect(() => {
|
|
const services = getAppServices();
|
|
const url = `${pathname}${searchParams?.size ? `?${searchParams.toString()}` : ''}`;
|
|
services.analytics.trackPageview(url);
|
|
}, [pathname, searchParams]);
|
|
|
|
return null;
|
|
}
|
|
|