Let Cloudron turn on named admins, the ops token, and Umami after the image is built.
Tracker env is read at request time and the CSP already allows the analytics host, so staging can set a rule admin, an ops bearer token, and the cookieless Umami site without rebuilding.
This commit is contained in:
1 parent
36112f95d3
commit
f7d88a7d5c
9 files changed
+132
-49
No files matched your search
+24
-22
@@ -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<Metadata> {
|
||||
};
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
async function UmamiScript() {
|
||||
await connection();
|
||||
const umami = umamiTracker();
|
||||
if (!umami) return null;
|
||||
return (
|
||||
<Script
|
||||
src={umami.src}
|
||||
strategy="afterInteractive"
|
||||
data-website-id={umami.websiteId}
|
||||
data-do-not-track="true"
|
||||
data-exclude-search="true"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<html lang="en" className="font-sans">
|
||||
<head>
|
||||
@@ -150,26 +164,14 @@ export default function RootLayout({ children }: { children: ReactNode }) {
|
||||
type="image/png"
|
||||
/>
|
||||
</head>
|
||||
{umami ? (
|
||||
<body className={`${inter.variable} ${bricolageGrotesque.variable}`}>
|
||||
<Script
|
||||
src={umami.src}
|
||||
strategy="afterInteractive"
|
||||
data-website-id={umami.websiteId}
|
||||
data-do-not-track="true"
|
||||
data-exclude-search="true"
|
||||
/>
|
||||
<div className="mx-auto flex min-h-screen w-full max-w-[1920px] flex-col">
|
||||
{children}
|
||||
</div>
|
||||
</body>
|
||||
) : (
|
||||
<body className={`${inter.variable} ${bricolageGrotesque.variable}`}>
|
||||
<div className="mx-auto flex min-h-screen w-full max-w-[1920px] flex-col">
|
||||
{children}
|
||||
</div>
|
||||
</body>
|
||||
)}
|
||||
<body className={`${inter.variable} ${bricolageGrotesque.variable}`}>
|
||||
<Suspense fallback={null}>
|
||||
<UmamiScript />
|
||||
</Suspense>
|
||||
<div className="mx-auto flex min-h-screen w-full max-w-[1920px] flex-col">
|
||||
{children}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user