Files
HealthLog/src/components/monitoring/bootstrap.tsx
T
Marc-André Bombeck 3b480b9885 perf(i18n,shell): ship one locale and stop blocking the first paint
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.
2026-06-11 02:19:27 +02:00

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} />
</>
);
}