mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 09:36:08 +00:00
Adds first-party acquisition attribution and a sixteen-event funnel, written to this deployment's own database and read back on /admin/growth. Nothing is sent anywhere else, and the whole subsystem is off unless OPENFRAME_ENABLE_ANALYTICS is set, so a self-hosted instance carries the tables empty and pays nothing. The proxy gives a visitor an anonymous id and stores what brought them in two first-party cookies; signup copies that onto the account and claims the events the visitor produced before they had one, which is what joins the two halves of the funnel. Recording happens where each step actually happens rather than in the browser: an ad blocker cannot undercount landing views, and blocking rates differ by channel, so an undercounted denominator would have made GitHub traffic look like it converts better than it does. Every event carries a dedupe key on a UNIQUE column, so "recorded exactly once" is a property of the schema rather than of fifteen call sites. Subscription events are derived by comparing the row being overwritten with the row being written inside the existing Stripe sync, which makes them order-independent and replay-safe. The scoreboard reports step-to-step conversion with the denominator beside it, and splits by source over a rolling 28-day window rather than a week: at this volume a weekly per-source cell holds single digits, and a percentage computed from three visits reads exactly as confidently as one computed from three hundred. "How did you hear about us?" is asked on the first onboarding screen, not on the registration form. The number being measured is the signup conversion rate, and a question added to that form would move it.
93 lines
3.6 KiB
TypeScript
93 lines
3.6 KiB
TypeScript
import { redirect } from 'next/navigation';
|
|
import { auth } from '@/lib/auth';
|
|
import { Header } from '@/components/layout';
|
|
import Link from 'next/link';
|
|
import { LayoutDashboard, MessageSquareQuote, TrendingUp, Users } from 'lucide-react';
|
|
|
|
export default async function AdminLayout({ children }: { children: React.ReactNode }) {
|
|
const session = await auth();
|
|
|
|
if (!session?.user?.isAdmin) {
|
|
redirect('/');
|
|
}
|
|
|
|
return (
|
|
<div className="relative flex min-h-screen flex-col">
|
|
<Header user={session.user} showAppNavigation />
|
|
<div className="w-full px-4 md:px-8 flex-1 items-start md:grid md:grid-cols-[220px_minmax(0,1fr)] md:gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10">
|
|
{/* Mobile Nav */}
|
|
<div className="md:hidden py-4 border-b mb-4">
|
|
<nav className="flex items-center gap-4 overflow-x-auto">
|
|
<Link
|
|
href="/admin"
|
|
className="flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50"
|
|
>
|
|
<LayoutDashboard className="h-4 w-4" />
|
|
Dashboard
|
|
</Link>
|
|
<Link
|
|
href="/admin/users"
|
|
className="flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50"
|
|
>
|
|
<Users className="h-4 w-4" />
|
|
Users
|
|
</Link>
|
|
<Link
|
|
href="/admin/feedback"
|
|
className="flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50"
|
|
>
|
|
<MessageSquareQuote className="h-4 w-4" />
|
|
Feedback
|
|
</Link>
|
|
<Link
|
|
href="/admin/growth"
|
|
className="flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50"
|
|
>
|
|
<TrendingUp className="h-4 w-4" />
|
|
Growth
|
|
</Link>
|
|
</nav>
|
|
</div>
|
|
{/* Desktop Nav */}
|
|
<aside className="fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block">
|
|
<div className="h-full py-6 pr-6 lg:py-8">
|
|
<nav className="flex flex-col gap-2">
|
|
<Link
|
|
href="/admin"
|
|
className="flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50 transition-colors"
|
|
>
|
|
<LayoutDashboard className="h-4 w-4" />
|
|
Dashboard
|
|
</Link>
|
|
<Link
|
|
href="/admin/users"
|
|
className="flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50 transition-colors"
|
|
>
|
|
<Users className="h-4 w-4" />
|
|
Users
|
|
</Link>
|
|
<Link
|
|
href="/admin/feedback"
|
|
className="flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50 transition-colors"
|
|
>
|
|
<MessageSquareQuote className="h-4 w-4" />
|
|
Feedback
|
|
</Link>
|
|
<Link
|
|
href="/admin/growth"
|
|
className="flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium hover:bg-muted/50 transition-colors"
|
|
>
|
|
<TrendingUp className="h-4 w-4" />
|
|
Growth
|
|
</Link>
|
|
</nav>
|
|
</div>
|
|
</aside>
|
|
<main className="flex w-full flex-col overflow-hidden py-0 md:py-6 lg:py-8">
|
|
{children}
|
|
</main>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|