mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
The client bundle carries only the active locale — resolved on the server and handed to the provider with no hydration flash, halving the dashboard route to under a megabyte parsed (288 KiB gzip). The auth shell renders the app chrome immediately instead of a spinner while the session resolves in parallel, the widgets request folds into the snapshot it duplicated, and insight pills prefetch their sub-pages — a first visit to a sub-page lands in about ninety milliseconds instead of nearly a second.
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { UmamiScript } from "@/components/monitoring/umami-script";
|
|
import { GlitchtipReporter } from "@/components/monitoring/glitchtip-reporter";
|
|
import { apiGet } from "@/lib/api/api-fetch";
|
|
|
|
interface MonitoringSettings {
|
|
umamiEnabled: boolean;
|
|
umamiWebsiteId: string | null;
|
|
glitchtipEnabled: boolean;
|
|
}
|
|
|
|
export function MonitoringBootstrap() {
|
|
const [settings, setSettings] = useState<MonitoringSettings | null>(null);
|
|
|
|
useEffect(() => {
|
|
let active = true;
|
|
|
|
apiGet<MonitoringSettings | undefined>("/api/monitoring/settings", {
|
|
cache: "no-store",
|
|
})
|
|
.then((data) => {
|
|
if (!active || !data) return;
|
|
setSettings(data);
|
|
})
|
|
.catch(() => {
|
|
if (!active) return;
|
|
setSettings({
|
|
umamiEnabled: false,
|
|
umamiWebsiteId: null,
|
|
glitchtipEnabled: false,
|
|
});
|
|
});
|
|
|
|
return () => {
|
|
active = false;
|
|
};
|
|
}, []);
|
|
|
|
if (!settings) return null;
|
|
|
|
return (
|
|
<>
|
|
<UmamiScript
|
|
enabled={settings.umamiEnabled}
|
|
websiteId={settings.umamiWebsiteId}
|
|
/>
|
|
<GlitchtipReporter enabled={settings.glitchtipEnabled} />
|
|
</>
|
|
);
|
|
}
|