Skip to content

Commit 71bfb09

Browse files
committed
add posthog
1 parent d68274e commit 71bfb09

File tree

8 files changed

+2156
-623
lines changed

8 files changed

+2156
-623
lines changed

instrumentation-client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import posthog from "posthog-js"
2+
3+
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
4+
api_host: "/ingest",
5+
ui_host: "https://us.posthog.com",
6+
defaults: "2025-05-24",
7+
capture_exceptions: true, // This enables capturing exceptions using Error Tracking
8+
session_recording: {
9+
// Prevent large base64 images from being serialized into recordings
10+
blockClass: "ph-no-capture",
11+
blockSelector: ".ph-no-capture",
12+
},
13+
debug: process.env.NODE_ENV === "development",
14+
});

next.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ const nextConfig: NextConfig = {
1616
},
1717
];
1818
},
19+
async rewrites() {
20+
return [
21+
{
22+
source: "/ingest/static/:path*",
23+
destination: "https://us-assets.i.posthog.com/static/:path*",
24+
},
25+
{
26+
source: "/ingest/:path*",
27+
destination: "https://us.i.posthog.com/:path*",
28+
},
29+
];
30+
},
31+
// This is required to support PostHog trailing slash API requests
32+
skipTrailingSlashRedirect: true,
1933
};
2034

2135
export default nextConfig;

0 commit comments

Comments
 (0)