Files
nerandClaude Opus 5 d67a0d4df6 feat(analytics): self-hosted openpanel with a typed event catalogue
Replaces Vercel Analytics with OpenPanel, driven entirely by env vars so the
whole layer is inert until NEXT_PUBLIC_OPENPANEL_CLIENT_ID is set.

Zero initial load cost. next/script emits a rel=preload even on lazyOnload,
which pulls the sdk during the first paint, so the component skips it: it
inlines the 416 byte official stub (window.op queues calls immediately) and
appends the real script itself on window load plus requestIdleCallback. The
built html carries no preload and no script src for the analytics host.

Events live in one typed catalogue (lib/analytics/events.ts) and track() is
keyed to it, so a wrong name or payload is a type error rather than a silent
bad row. Emitters sit in the hooks that already own the behaviour instead of
being sprinkled through components:

- useShowState covers every favourite and watchlist toggle
- useInfiniteList covers pagination for all six lists
- useTorrents covers all three providers
- Preview, Person and useSearch use a shared useTrackOnce hook

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-14 12:08:16 +03:00

81 lines
2.6 KiB
TypeScript

import React, { ReactNode } from 'react';
import type { Metadata, Viewport } from 'next';
import { Jost } from 'next/font/google';
import Analytics from '@/components/Analytics';
import Header from '@/components/Header';
import ThemeColor from '@/components/ThemeColor';
import { SITE_URL, TITLE } from '@/env';
import Providers from '@/providers';
import '@/styles/index.css';
const DESCRIPTION = `Explore a diverse selection of movies with ${TITLE}. Get random movie recommendations and find out top-rated, popular, and user-favorite films.`;
export const metadata: Metadata = {
metadataBase: new URL(SITE_URL),
title: `${TITLE} | Discover Your Next Favorite Movie`,
description: DESCRIPTION,
openGraph: {
type: 'website',
siteName: TITLE,
title: TITLE,
description: DESCRIPTION
},
twitter: {
card: 'summary_large_image'
}
};
export const viewport: Viewport = {
width: 'device-width',
initialScale: 1,
viewportFit: 'cover',
themeColor: 'white'
};
const font = Jost({ subsets: ['latin', 'cyrillic'], weight: ['400'] });
const RootLayout = ({ children }: { children: ReactNode }) => {
return (
<html lang='en' suppressHydrationWarning>
<head>
<link rel='preconnect' href='https://image.tmdb.org' crossOrigin='anonymous' />
<link rel='dns-prefetch' href='https://image.tmdb.org' />
<ThemeColor />
<link
rel='icon'
type='image/png'
href='/favicon-48x48.png'
sizes='48x48'
media='(prefers-color-scheme: light)'
/>
<link
rel='icon'
type='image/png'
href='/favicon-48x48-dark.png'
sizes='48x48'
media='(prefers-color-scheme: dark)'
/>
<link rel='icon' type='image/svg+xml' href='/favicon.svg' media='(prefers-color-scheme: light)' />
<link rel='icon' type='image/svg+xml' href='/favicon-dark.svg' media='(prefers-color-scheme: dark)' />
<link rel='shortcut icon' href='/favicon.ico' media='(prefers-color-scheme: light)' />
<link rel='shortcut icon' href='/favicon-dark.ico' media='(prefers-color-scheme: dark)' />
<link rel='apple-touch-icon' sizes='180x180' href='/apple-touch-icon.png' />
<meta name='apple-mobile-web-app-title' content={TITLE} />
<link rel='manifest' href='/manifest.json' />
</head>
<body className={font.className}>
<Providers>
<Header className='sticky top-0 z-20' />
<main className='container'>{children}</main>
</Providers>
<Analytics />
</body>
</html>
);
};
export default RootLayout;