Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

add home page

Bill Yanga3978f17c494
diff --git a/client/package-lock.json b/client/package-lock.json
index 0fadb5709..667f7684b 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -15,6 +15,7 @@
"@radix-ui/react-dialog": "^1.1.5",
"@radix-ui/react-dropdown-menu": "^2.1.5",
"@radix-ui/react-label": "^2.1.2",
+ "@radix-ui/react-navigation-menu": "^1.2.5",
"@radix-ui/react-popover": "^1.1.5",
"@radix-ui/react-select": "^2.1.5",
"@radix-ui/react-slot": "^1.1.2",
@@ -2153,6 +2154,136 @@
}
}
},
+ "node_modules/@radix-ui/react-navigation-menu": {
+ "version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.2.5.tgz",
+ "integrity": "sha512-myMHHQUZ3ZLTi8W381/Vu43Ia0NqakkQZ2vzynMmTUtQQ9kNkjzhOwkZC9TAM5R07OZUVIQyHC06f/9JZJpvvA==",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.1",
+ "@radix-ui/react-collection": "1.1.2",
+ "@radix-ui/react-compose-refs": "1.1.1",
+ "@radix-ui/react-context": "1.1.1",
+ "@radix-ui/react-direction": "1.1.0",
+ "@radix-ui/react-dismissable-layer": "1.1.5",
+ "@radix-ui/react-id": "1.1.0",
+ "@radix-ui/react-presence": "1.1.2",
+ "@radix-ui/react-primitive": "2.0.2",
+ "@radix-ui/react-use-callback-ref": "1.1.0",
+ "@radix-ui/react-use-controllable-state": "1.1.0",
+ "@radix-ui/react-use-layout-effect": "1.1.0",
+ "@radix-ui/react-use-previous": "1.1.0",
+ "@radix-ui/react-visually-hidden": "1.1.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-navigation-menu/node_modules/@radix-ui/react-collection": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.2.tgz",
+ "integrity": "sha512-9z54IEKRxIa9VityapoEYMuByaG42iSy1ZXlY2KcuLSEtq8x4987/N6m15ppoMffgZX72gER2uHe1D9Y6Unlcw==",
+ "dependencies": {
+ "@radix-ui/react-compose-refs": "1.1.1",
+ "@radix-ui/react-context": "1.1.1",
+ "@radix-ui/react-primitive": "2.0.2",
+ "@radix-ui/react-slot": "1.1.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-navigation-menu/node_modules/@radix-ui/react-dismissable-layer": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.1.5.tgz",
+ "integrity": "sha512-E4TywXY6UsXNRhFrECa5HAvE5/4BFcGyfTyK36gP+pAW1ed7UTK4vKwdr53gAJYwqbfCWC6ATvJa3J3R/9+Qrg==",
+ "dependencies": {
+ "@radix-ui/primitive": "1.1.1",
+ "@radix-ui/react-compose-refs": "1.1.1",
+ "@radix-ui/react-primitive": "2.0.2",
+ "@radix-ui/react-use-callback-ref": "1.1.0",
+ "@radix-ui/react-use-escape-keydown": "1.1.0"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-navigation-menu/node_modules/@radix-ui/react-primitive": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.0.2.tgz",
+ "integrity": "sha512-Ec/0d38EIuvDF+GZjcMU/Ze6MxntVJYO/fRlCPhCaVUyPY9WTalHJw54tp9sXeJo3tlShWpy41vQRgLRGOuz+w==",
+ "dependencies": {
+ "@radix-ui/react-slot": "1.1.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@radix-ui/react-navigation-menu/node_modules/@radix-ui/react-visually-hidden": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-visually-hidden/-/react-visually-hidden-1.1.2.tgz",
+ "integrity": "sha512-1SzA4ns2M1aRlvxErqhLHsBHoS5eI5UUcI2awAMgGUp4LoaoWOKYmvqDY2s/tltuPkh3Yk77YF/r3IRj+Amx4Q==",
+ "dependencies": {
+ "@radix-ui/react-primitive": "2.0.2"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-popover": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.1.5.tgz",
diff --git a/client/package.json b/client/package.json
index cb52aa88d..7b4d9ce0a 100644
--- a/client/package.json
+++ b/client/package.json
@@ -16,6 +16,7 @@
"@radix-ui/react-dialog": "^1.1.5",
"@radix-ui/react-dropdown-menu": "^2.1.5",
"@radix-ui/react-label": "^2.1.2",
+ "@radix-ui/react-navigation-menu": "^1.2.5",
"@radix-ui/react-popover": "^1.1.5",
"@radix-ui/react-select": "^2.1.5",
"@radix-ui/react-slot": "^1.1.2",
diff --git a/client/src/app/[site]/page.tsx b/client/src/app/[site]/page.tsx
new file mode 100644
index 000000000..937208ed4
--- /dev/null
+++ b/client/src/app/[site]/page.tsx
@@ -0,0 +1,3 @@
+export default function SitePage() {
+ return <div>fads</div>;
+}
diff --git a/client/src/app/components/MainSection/Overview.tsx b/client/src/app/components/MainSection/Overview.tsx
index 37ec90831..3bd00fd02 100644
--- a/client/src/app/components/MainSection/Overview.tsx
+++ b/client/src/app/components/MainSection/Overview.tsx
@@ -15,6 +15,21 @@ const ChangePercentage = ({
}) => {
const change = ((current - previous) / previous) * 100;
+ if (previous === 0) {
+ if (current === 0) {
+ return (
+ <Badge variant="minimal" className="text-xs">
+ 0%
+ </Badge>
+ );
+ }
+ return (
+ <Badge className="text-xs" variant="green">
+ +999%
+ </Badge>
+ );
+ }
+
if (change === 0) {
return (
<Badge variant="minimal" className="text-xs">
diff --git a/client/src/app/layout.tsx b/client/src/app/layout.tsx
index 1e81dd11c..022c50211 100644
--- a/client/src/app/layout.tsx
+++ b/client/src/app/layout.tsx
@@ -1,16 +1,14 @@
"use client";
-import type { Metadata } from "next";
-import { Inter } from "next/font/google";
-import "./globals.css";
+import { TopBar } from "@/components/TopBar";
import QueryProvider from "@/providers/QueryProvider";
import { ThemeProvider } from "@/providers/ThemeProvider";
-import { TopBar } from "@/components/TopBar";
-import { authClient } from "../lib/auth";
-import { redirect } from "next/navigation";
-import { usePathname } from "next/navigation";
-import { useEffect, useState } from "react";
+import type { Metadata } from "next";
+import { Inter } from "next/font/google";
+import { redirect, usePathname } from "next/navigation";
+import { useEffect } from "react";
import { userStore } from "../lib/useStore";
+import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
diff --git a/client/src/components/TopBar.tsx b/client/src/components/TopBar.tsx
index 6784073f3..cc5ca86cd 100644
--- a/client/src/components/TopBar.tsx
+++ b/client/src/components/TopBar.tsx
@@ -1,5 +1,14 @@
import Link from "next/link";
import { ThemeToggle } from "./ThemeToggle";
+import {
+ NavigationMenu,
+ NavigationMenuContent,
+ NavigationMenuItem,
+ NavigationMenuLink,
+ NavigationMenuList,
+ NavigationMenuTrigger,
+ navigationMenuTriggerStyle,
+} from "./ui/navigation-menu";
export function TopBar() {
return (
@@ -10,7 +19,25 @@ export function TopBar() {
</Link>
</div>
<div className="ml-auto flex items-center space-x-4">
- <nav className="flex items-center space-x-4">
+ <NavigationMenu>
+ <NavigationMenuList>
+ <NavigationMenuItem>
+ <Link href="/">
+ <NavigationMenuLink className={navigationMenuTriggerStyle()}>
+ Dashboard
+ </NavigationMenuLink>
+ </Link>
+ </NavigationMenuItem>
+ <NavigationMenuItem>
+ <Link href="/settings">
+ <NavigationMenuLink className={navigationMenuTriggerStyle()}>
+ Settings
+ </NavigationMenuLink>
+ </Link>
+ </NavigationMenuItem>
+ </NavigationMenuList>
+ </NavigationMenu>
+ {/* <nav className="flex items-center space-x-4">
<Link
href="/"
className="text-sm font-medium transition-colors hover:text-primary"
@@ -23,7 +50,7 @@ export function TopBar() {
>
Settings
</Link>
- </nav>
+ </nav> */}
<ThemeToggle />
</div>
</div>
diff --git a/client/src/components/ui/navigation-menu.tsx b/client/src/components/ui/navigation-menu.tsx
new file mode 100644
index 000000000..a4375bd5d
--- /dev/null
+++ b/client/src/components/ui/navigation-menu.tsx
@@ -0,0 +1,129 @@
+import * as React from "react";
+import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
+import { cva } from "class-variance-authority";
+import { ChevronDown } from "lucide-react";
+
+import { cn } from "@/lib/utils";
+
+const NavigationMenu = React.forwardRef<
+ React.ElementRef<typeof NavigationMenuPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Root>
+>(({ className, children, ...props }, ref) => (
+ <NavigationMenuPrimitive.Root
+ ref={ref}
+ className={cn(
+ "relative z-10 flex max-w-max flex-1 items-center justify-center",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <NavigationMenuViewport />
+ </NavigationMenuPrimitive.Root>
+));
+NavigationMenu.displayName = NavigationMenuPrimitive.Root.displayName;
+
+const NavigationMenuList = React.forwardRef<
+ React.ElementRef<typeof NavigationMenuPrimitive.List>,
+ React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.List>
+>(({ className, ...props }, ref) => (
+ <NavigationMenuPrimitive.List
+ ref={ref}
+ className={cn(
+ "group flex flex-1 list-none items-center justify-center space-x-1",
+ className
+ )}
+ {...props}
+ />
+));
+NavigationMenuList.displayName = NavigationMenuPrimitive.List.displayName;
+
+const NavigationMenuItem = NavigationMenuPrimitive.Item;
+
+const navigationMenuTriggerStyle = cva(
+ "group inline-flex h-9 w-max items-center justify-center rounded-md bg-white px-4 py-2 text-sm font-medium transition-colors hover:bg-neutral-100 hover:text-neutral-900 focus:bg-neutral-100 focus:text-neutral-900 focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-neutral-100/50 data-[state=open]:bg-neutral-100/50 dark:bg-neutral-950 dark:hover:bg-neutral-800 dark:text-neutral-200 dark:hover:text-neutral-50 dark:focus:bg-neutral-800 dark:focus:text-neutral-50 dark:data-[active]:bg-neutral-800/50 dark:data-[state=open]:bg-neutral-800/50"
+);
+
+const NavigationMenuTrigger = React.forwardRef<
+ React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
+ <NavigationMenuPrimitive.Trigger
+ ref={ref}
+ className={cn(navigationMenuTriggerStyle(), "group", className)}
+ {...props}
+ >
+ {children}
+ {""}
+ <ChevronDown
+ className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
+ aria-hidden="true"
+ />
+ </NavigationMenuPrimitive.Trigger>
+));
+NavigationMenuTrigger.displayName = NavigationMenuPrimitive.Trigger.displayName;
+
+const NavigationMenuContent = React.forwardRef<
+ React.ElementRef<typeof NavigationMenuPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Content>
+>(({ className, ...props }, ref) => (
+ <NavigationMenuPrimitive.Content
+ ref={ref}
+ className={cn(
+ "left-0 top-0 w-full data-[motion^=from-]:animate-in data-[motion^=to-]:animate-out data-[motion^=from-]:fade-in data-[motion^=to-]:fade-out data-[motion=from-end]:slide-in-from-right-52 data-[motion=from-start]:slide-in-from-left-52 data-[motion=to-end]:slide-out-to-right-52 data-[motion=to-start]:slide-out-to-left-52 md:absolute md:w-auto",
+ className
+ )}
+ {...props}
+ />
+));
+NavigationMenuContent.displayName = NavigationMenuPrimitive.Content.displayName;
+
+const NavigationMenuLink = NavigationMenuPrimitive.Link;
+
+const NavigationMenuViewport = React.forwardRef<
+ React.ElementRef<typeof NavigationMenuPrimitive.Viewport>,
+ React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Viewport>
+>(({ className, ...props }, ref) => (
+ <div className={cn("absolute left-0 top-full flex justify-center")}>
+ <NavigationMenuPrimitive.Viewport
+ className={cn(
+ "origin-top-center relative mt-1.5 h-[var(--radix-navigation-menu-viewport-height)] w-full overflow-hidden rounded-md border border-neutral-200 bg-white text-neutral-950 shadow data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-90 md:w-[var(--radix-navigation-menu-viewport-width)] dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50",
+ className
+ )}
+ ref={ref}
+ {...props}
+ />
+ </div>
+));
+NavigationMenuViewport.displayName =
+ NavigationMenuPrimitive.Viewport.displayName;
+
+const NavigationMenuIndicator = React.forwardRef<
+ React.ElementRef<typeof NavigationMenuPrimitive.Indicator>,
+ React.ComponentPropsWithoutRef<typeof NavigationMenuPrimitive.Indicator>
+>(({ className, ...props }, ref) => (
+ <NavigationMenuPrimitive.Indicator
+ ref={ref}
+ className={cn(
+ "top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden data-[state=visible]:animate-in data-[state=hidden]:animate-out data-[state=hidden]:fade-out data-[state=visible]:fade-in",
+ className
+ )}
+ {...props}
+ >
+ <div className="relative top-[60%] h-2 w-2 rotate-45 rounded-tl-sm bg-neutral-200 shadow-md dark:bg-neutral-800" />
+ </NavigationMenuPrimitive.Indicator>
+));
+NavigationMenuIndicator.displayName =
+ NavigationMenuPrimitive.Indicator.displayName;
+
+export {
+ navigationMenuTriggerStyle,
+ NavigationMenu,
+ NavigationMenuList,
+ NavigationMenuItem,
+ NavigationMenuContent,
+ NavigationMenuTrigger,
+ NavigationMenuLink,
+ NavigationMenuIndicator,
+ NavigationMenuViewport,
+};
diff --git a/server/src/actions/sites/addSite.ts b/server/src/actions/sites/addSite.ts
new file mode 100644
index 000000000..8bc350835
--- /dev/null
+++ b/server/src/actions/sites/addSite.ts
@@ -0,0 +1,17 @@
+import { FastifyReply } from "fastify";
+
+import { FastifyRequest } from "fastify";
+
+export function addSite(
+ request: FastifyRequest<{ Params: { domain: string } }>,
+ reply: FastifyReply
+) {
+ const { domain } = request.params;
+ const { user } = request.user;
+
+ console.info(request);
+
+ // if (!user) {
+ // return reply.status(401).send({ error: "Unauthorized" });
+ // }
+}
diff --git a/server/src/actions/sites/deleteSite.ts b/server/src/actions/sites/deleteSite.ts
new file mode 100644
index 000000000..e69de29bb
diff --git a/server/src/db/postgres/postgres.ts b/server/src/db/postgres/postgres.ts
index 1548e5930..551755f29 100644
--- a/server/src/db/postgres/postgres.ts
+++ b/server/src/db/postgres/postgres.ts
@@ -59,6 +59,17 @@ export async function initializePostgres() {
referrer TEXT
);
`,
+
+ sql`
+ CREATE TABLE IF NOT EXISTS sites (
+ site_id SERIAL PRIMARY KEY,
+ name TEXT NOT NULL,
+ domain TEXT NOT NULL UNIQUE,
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ created_by TEXT NOT NULL REFERENCES "user" ("id")
+ );
+ `,
]);
// Phase 2: Create tables with foreign key dependencies
diff --git a/server/src/index.ts b/server/src/index.ts
index 0c754c737..c4e93a0c3 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -23,6 +23,7 @@ import { auth } from "./lib/auth.js";
import { TrackingPayload } from "./types.js";
import { toNodeHandler } from "better-auth/node";
import { mapHeaders } from "./lib/betterAuth.js";
+import { addSite } from "./actions/sites/addSite.js";
// ESM replacement for __dirname:
const __filename = fileURLToPath(import.meta.url);
@@ -44,7 +45,7 @@ server.register(cors, {
"http://localhost:3002",
"https://tracking.tomato.gg",
"https://tomato.gg",
- ], // In production, you should specify your frontend domain
+ ],
credentials: true,
});
@@ -113,11 +114,6 @@ server.addHook("onRequest", async (request, reply) => {
}
});
-// Health check endpoint
-server.get("/health", async () => {
- return { status: "ok" };
-});
-
server.get("/live-user-count", async () => {
return { count: await getLiveUsercount() };
});
@@ -131,6 +127,8 @@ server.get("/pages", getPages);
server.get("/referrers", getReferrers);
server.get("/pageviews", getPageViews);
+server.post("/add-site", addSite);
+
// Track pageview endpoint
server.post<{ Body: TrackingPayload }>(
"/track/pageview",