Skip to content

Commit 5a51429

Browse files
committed
feat: add Vercel Analytics, Speed Insights, and Umami analytics
- Add @vercel/analytics and @vercel/speed-insights packages - Create SiteAnalytics component with Vercel + conditional Umami tracking - Add analytics to main layout and dashboard layout - Add Umami self-hosted setup documentation Vercel Analytics/Speed Insights work automatically on deploy. Umami activates when NEXT_PUBLIC_UMAMI_WEBSITE_ID env var is set.
1 parent 7d88229 commit 5a51429

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

components/analytics.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"use client";
2+
3+
import { Analytics } from "@vercel/analytics/next";
4+
import { SpeedInsights } from "@vercel/speed-insights/next";
5+
import Script from "next/script";
6+
7+
export function SiteAnalytics() {
8+
return (
9+
<>
10+
<Analytics />
11+
<SpeedInsights />
12+
{process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID && (
13+
<Script
14+
src={process.env.NEXT_PUBLIC_UMAMI_URL || "https://analytics.codingcat.dev/script.js"}
15+
data-website-id={process.env.NEXT_PUBLIC_UMAMI_WEBSITE_ID}
16+
strategy="afterInteractive"
17+
/>
18+
)}
19+
</>
20+
);
21+
}

docs/umami-setup.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Umami Analytics Setup
2+
3+
## Overview
4+
Umami is self-hosted on Vercel + Supabase for $0/month analytics.
5+
6+
## Setup Steps
7+
8+
### 1. Fork Umami
9+
Fork https://github.com/umami-is/umami to the CodingCatDev GitHub org.
10+
11+
### 2. Create Umami tables in Supabase
12+
Run the Umami PostgreSQL schema in your Supabase SQL editor.
13+
See: https://umami.is/docs/install
14+
15+
### 3. Deploy to Vercel
16+
- Import the forked repo in Vercel
17+
- Set environment variable: `DATABASE_URL` = your Supabase connection string
18+
- Deploy
19+
20+
### 4. Configure
21+
- Visit your Umami instance (e.g., analytics.codingcat.dev)
22+
- Create a website entry for codingcat.dev
23+
- Copy the Website ID
24+
25+
### 5. Set environment variables in codingcat.dev
26+
```
27+
NEXT_PUBLIC_UMAMI_WEBSITE_ID=<your-website-id>
28+
NEXT_PUBLIC_UMAMI_URL=https://analytics.codingcat.dev/script.js
29+
```
30+
31+
### 6. Custom domain (optional)
32+
Add `analytics.codingcat.dev` as a custom domain in Vercel for the Umami project.
33+
34+
## Querying Analytics Data
35+
Since Umami writes to your Supabase database, you can query analytics directly:
36+
37+
```sql
38+
-- Top pages last 30 days
39+
SELECT url_path, COUNT(*) as views
40+
FROM website_event
41+
WHERE website_id = '<your-id>'
42+
AND created_at > NOW() - INTERVAL '30 days'
43+
AND event_type = 1
44+
GROUP BY url_path
45+
ORDER BY views DESC
46+
LIMIT 20;
47+
48+
-- Sponsor report: views by content type
49+
SELECT
50+
CASE
51+
WHEN url_path LIKE '/post/%' THEN 'Blog Post'
52+
WHEN url_path LIKE '/podcast/%' THEN 'Podcast'
53+
WHEN url_path LIKE '/course/%' THEN 'Course'
54+
ELSE 'Other'
55+
END as content_type,
56+
COUNT(*) as views,
57+
COUNT(DISTINCT session_id) as unique_visitors
58+
FROM website_event
59+
WHERE website_id = '<your-id>'
60+
AND created_at > NOW() - INTERVAL '30 days'
61+
AND event_type = 1
62+
GROUP BY content_type
63+
ORDER BY views DESC;
64+
```

0 commit comments

Comments
 (0)