Skip to content

Commit 5c8535f

Browse files
committed
feat: integrate PostHog for analytics + instrumentation
1 parent f43efb5 commit 5c8535f

File tree

6 files changed

+114
-32
lines changed

6 files changed

+114
-32
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ NEXTAUTH_SECRET=xxxx
1111
ADMIN_EMAIL=[email protected]
1212
TURSO_DATABASE_URL=libsql://<your-db-url>
1313
GOOGLE_CLIENT_ID=xxxx.apps.googleusercontent.com
14-
NEXTAUTH_URL=https://your-site.example
14+
NEXTAUTH_URL=https://your-site.example
15+
16+
# analytics (posthog)
17+
POSTHOG_UI_HOST=https://eu.posthog.com

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# eloop-turso — Serverless Event Management
1+
# eloop by HSP — Event Management Platform
22

3-
eloop is an event management system that integrates with Turso (DBaaS), supporting hierarchical roles and dynamic form generation.
3+
Eventloop (eloop) is a serverless event management app built with Next.js and Turso. It supports hierarchical roles, dynamic registration forms, and QR-based check-ins.
44

55
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fpolarhive%2Feloop-serverless-spin&env=QR_SECRET,GOOGLE_CLIENT_SECRET,TURSO_AUTH_TOKEN,NEXTAUTH_SECRET,ADMIN_EMAIL,TURSO_DATABASE_URL,GOOGLE_CLIENT_ID,NEXTAUTH_URL)
66

@@ -19,7 +19,7 @@ The project reads configuration from environment variables. See the shipped `.en
1919
- `QR_SECRET` — secret used to sign QR payloads
2020
- `TURSO_DATABASE_URL` — your Turso/libSQL connection URL (libsql://...)
2121
- `TURSO_AUTH_TOKEN` — Turso service token used to access the database
22-
22+
- `POSTHOG_KEY=phc_xxx` Uses PostHog for instrumentation
2323

2424
## Google OAuth Client Setup
2525

instrumentation-client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import posthog from "posthog-js"
2+
3+
posthog.init(process.env.POSTHOG_KEY!, {
4+
api_host: "/blob",
5+
ui_host: process.env.POSTHOG_UI_HOST || "https://eu.posthog.com",
6+
defaults: '2025-05-24',
7+
person_profiles: 'always',
8+
capture_exceptions: true, // This enables capturing exceptions using Error Tracking, set to false if you don't want this
9+
debug: process.env.NODE_ENV === "development",
10+
})

next.config.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,34 @@ const nextConfig: NextConfig = {
1717

1818
// Disable ESLint for production build
1919
eslint: {
20-
// Only run ESLint in development
2120
ignoreDuringBuilds: true,
22-
}
21+
},
22+
23+
async rewrites() {
24+
const posthogUiHost = process.env.POSTHOG_UI_HOST || "https://eu.posthog.com"
25+
26+
const posthogAssetsHost =
27+
process.env.POSTHOG_UI_HOST ||
28+
(posthogUiHost.includes("eu.posthog") ? "https://eu-assets.i.posthog.com" : "https://us-assets.i.posthog.com")
29+
30+
const posthogApiHost =
31+
process.env.POSTHOG_UI_HOST ||
32+
(posthogUiHost.includes("eu.posthog") ? "https://eu.i.posthog.com" : "https://us.i.posthog.com")
33+
34+
return [
35+
{
36+
source: "/blob/static/:path*",
37+
destination: `${posthogAssetsHost}/static/:path*`,
38+
},
39+
{
40+
source: "/blob/:path*",
41+
destination: `${posthogApiHost}/:path*`,
42+
},
43+
];
44+
},
45+
46+
// This is required to support PostHog trailing slash API requests
47+
skipTrailingSlashRedirect: true,
2348
};
2449

2550
export default nextConfig;

package-lock.json

Lines changed: 68 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
"lucide-react": "^0.544.0",
2424
"next": "15.5.4",
2525
"next-auth": "^5.0.0-beta.29",
26+
"posthog-js": "^1.275.1",
27+
"posthog-node": "^5.9.5",
2628
"qrcode": "^1.5.4",
2729
"qrcode.react": "^4.2.0",
2830
"react": "19.1.0",

0 commit comments

Comments
 (0)