Skip to content

Commit 032ad91

Browse files
committed
feat: add PostHog client
1 parent 84ff891 commit 032ad91

File tree

4 files changed

+652
-1
lines changed

4 files changed

+652
-1
lines changed

instrumentation-client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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, set to false if you don't want this
8+
debug: process.env.NODE_ENV === "development",
9+
});

next.config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,27 @@ const nextConfig: NextConfig = {
77
experimental: {
88
viewTransition: true,
99
swcPlugins: [
10-
["@swc-contrib/plugin-graphql-codegen-client-preset", { artifactDirectory: "./gql", gqlTagName: "graphql" }],
10+
[
11+
"@swc-contrib/plugin-graphql-codegen-client-preset",
12+
{ artifactDirectory: "./gql", gqlTagName: "graphql" },
13+
],
1114
],
1215
ppr: "incremental",
1316
},
17+
async rewrites() {
18+
return [
19+
{
20+
source: "/ingest/static/:path*",
21+
destination: "https://us-assets.i.posthog.com/static/:path*",
22+
},
23+
{
24+
source: "/ingest/:path*",
25+
destination: "https://us.i.posthog.com/:path*",
26+
},
27+
];
28+
},
29+
// This is required to support PostHog trailing slash API requests
30+
skipTrailingSlashRedirect: true,
1431
};
1532

1633
export default nextConfig;

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@codemirror/lang-sql": "^6.10.0",
2323
"@graphql-codegen/client-preset": "^5.1.0",
2424
"@hookform/resolvers": "^5.2.2",
25+
"@posthog/ai": "^6.4.3",
2526
"@radix-ui/react-alert-dialog": "^1.1.15",
2627
"@radix-ui/react-avatar": "^1.1.10",
2728
"@radix-ui/react-checkbox": "^1.3.3",
@@ -50,6 +51,8 @@
5051
"lucide-react": "^0.544.0",
5152
"next": "15.6.0-canary.45",
5253
"next-themes": "^0.4.6",
54+
"posthog-js": "^1.271.0",
55+
"posthog-node": "^5.9.2",
5356
"react": "19.3.0-canary-4fdf7cf2-20251003",
5457
"react-codemirror-merge": "^4.25.2",
5558
"react-dom": "19.3.0-canary-4fdf7cf2-20251003",

0 commit comments

Comments
 (0)