diff --git a/.env.example b/.env.example index 2a11349..da3552d 100644 --- a/.env.example +++ b/.env.example @@ -61,6 +61,7 @@ NEXT_PUBLIC_ENABLE_BACKEND_SYNC= # Optional Umami (self-hosted beside the app). Unset: no tracker script. # Cookie-free / no-cookies is an Umami server setting. +# Read at request time on Cloudron, so `cloudron env set` does not need a rebuild. # NEXT_PUBLIC_UMAMI_SRC=https://analytics.example.com/script.js # NEXT_PUBLIC_UMAMI_WEBSITE_ID= diff --git a/app/layout.tsx b/app/layout.tsx index 439c3bf..3d9c1a9 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,7 +1,8 @@ import { Inter, Bricolage_Grotesque } from "next/font/google"; import type { Metadata, Viewport } from "next"; -import type { ReactNode } from "react"; +import { Suspense, type ReactNode } from "react"; import { headers } from "next/headers"; +import { connection } from "next/server"; import Script from "next/script"; import messages from "../messages/en/index"; import { ASSETS, getAssetPath } from "../lib/assetUtils"; @@ -125,9 +126,22 @@ export async function generateMetadata(): Promise { }; } -export default function RootLayout({ children }: { children: ReactNode }) { +async function UmamiScript() { + await connection(); const umami = umamiTracker(); + if (!umami) return null; + return ( +