Codex fixes
Some checks failed
Deploy Website / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-05-25 09:49:40 -04:00
parent 78ec3d58e3
commit 014b1836c0
101 changed files with 1048 additions and 7327 deletions

View File

@@ -1,10 +1,13 @@
'use client';
import { useEffect } from 'react';
import { usePathname } from 'next/navigation';
import { usePathname, useSearchParams } from 'next/navigation';
export function Analytics() {
const pathname = usePathname();
const searchParams = useSearchParams();
const queryString = searchParams.toString();
const visitPath = queryString ? `${pathname}?${queryString}` : pathname;
useEffect(() => {
// Send beacon on mount and path change
@@ -13,21 +16,21 @@ export function Analytics() {
// Send beacon to THIS website's API, which will relay it to the admin dash
await fetch('/api/analytics', {
method: 'POST',
body: JSON.stringify({ path: pathname, timestamp: Date.now() }),
body: JSON.stringify({ path: visitPath }),
headers: {
'Content-Type': 'application/json',
'X-Analytics-Key': process.env.NEXT_PUBLIC_ANALYTICS_KEY || 'default-analytics-key',
},
keepalive: true,
});
} catch (e) {
// Fail silently
console.error('Analytics fail', e);
if (process.env.NODE_ENV !== 'production') {
console.error('Analytics fail', e);
}
}
};
sendBeacon();
}, [pathname]);
}, [visitPath]);
return null;
}