Client-side posthog-js was using a random anonymous ID (reset every page load) while server-side posthog-node used a deterministic SHA256(hostname:username) hash. Bootstrap the client with the server's anonymous ID so both sides share the same per-machine-per-user identity.
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import type { Metadata, Viewport } from "next";
|
|
import { Suspense } from "react";
|
|
import { getAnonymousId } from "@/lib/telemetry";
|
|
import { PostHogPageviewTracker } from "./components/posthog-provider";
|
|
import "./globals.css";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "DenchClaw",
|
|
description:
|
|
"AI Workspace with an agent that connects to your apps and does the work for you",
|
|
};
|
|
|
|
export const viewport: Viewport = {
|
|
width: "device-width",
|
|
initialScale: 1,
|
|
maximumScale: 1,
|
|
};
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
return (
|
|
<html lang="en" suppressHydrationWarning>
|
|
<head>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
<link
|
|
rel="preconnect"
|
|
href="https://fonts.gstatic.com"
|
|
crossOrigin="anonymous"
|
|
/>
|
|
<link
|
|
href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter:wght@300;400;500;600;700&display=swap"
|
|
rel="stylesheet"
|
|
/>
|
|
{/* Inline script to prevent FOUC — reads localStorage or system preference */}
|
|
<script
|
|
dangerouslySetInnerHTML={{
|
|
__html: `try{if(localStorage.theme==="dark"||(!("theme" in localStorage)&&window.matchMedia("(prefers-color-scheme: dark)").matches)){document.documentElement.classList.add("dark")}else{document.documentElement.classList.remove("dark")}}catch(e){}`,
|
|
}}
|
|
/>
|
|
</head>
|
|
<body className="antialiased">
|
|
<Suspense fallback={null}>
|
|
<PostHogPageviewTracker anonymousId={getAnonymousId()} />
|
|
</Suspense>
|
|
{children}
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|