Skip to content

Commit fb4e1ed

Browse files
committed
posthog migration
1 parent 94e2cbc commit fb4e1ed

38 files changed

+272
-543
lines changed

apps/dashboard/.env.example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,8 @@ STRIPE_SECRET_KEY=""
108108

109109
# required for server wallet management
110110
NEXT_PUBLIC_THIRDWEB_VAULT_URL=""
111-
NEXT_PUBLIC_ENGINE_CLOUD_URL=""
111+
NEXT_PUBLIC_ENGINE_CLOUD_URL=""
112+
113+
# posthog setup
114+
NEXT_PUBLIC_POSTHOG_KEY=""
115+
NEXT_PUBLIC_POSTHOG_HOST=https://us.i.posthog.com

apps/dashboard/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import posthog from "posthog-js";
2+
3+
const NEXT_PUBLIC_POSTHOG_KEY = process.env.NEXT_PUBLIC_POSTHOG_KEY;
4+
5+
if (NEXT_PUBLIC_POSTHOG_KEY) {
6+
posthog.init(NEXT_PUBLIC_POSTHOG_KEY, {
7+
api_host: "/_ph",
8+
ui_host: "https://us.posthog.com",
9+
capture_pageview: "history_change",
10+
capture_pageleave: "if_capture_pageview",
11+
// disable exception capture (for now)
12+
capture_exceptions: false,
13+
// specifically disable autocapture (does not affect pageview capture)
14+
autocapture: false,
15+
debug: process.env.NODE_ENV === "development",
16+
});
17+
}

apps/dashboard/knip.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"@thirdweb-dev/service-utils",
1414
"@thirdweb-dev/vault-sdk",
1515
"@types/color",
16-
"fast-xml-parser"
16+
"fast-xml-parser",
17+
"posthog-js",
18+
"posthog-node"
1719
]
1820
}

apps/dashboard/next.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ const baseNextConfig: NextConfig = {
146146
},
147147
async rewrites() {
148148
return [
149+
{
150+
source: "/_ph/static/:path*",
151+
destination: "https://us-assets.i.posthog.com/static/:path*",
152+
},
153+
{
154+
source: "/_ph/:path*",
155+
destination: "https://us.i.posthog.com/:path*",
156+
},
157+
{
158+
source: "/_ph/decide",
159+
destination: "https://us.i.posthog.com/decide",
160+
},
149161
{
150162
source: "/thirdweb.eth",
151163
destination: "/deployer.thirdweb.eth",
@@ -173,6 +185,8 @@ const baseNextConfig: NextConfig = {
173185
]),
174186
];
175187
},
188+
// This is required to support PostHog trailing slash API requests
189+
skipTrailingSlashRedirect: true,
176190
images: {
177191
dangerouslyAllowSVG: true,
178192
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",

apps/dashboard/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"date-fns": "4.1.0",
6464
"fast-xml-parser": "^5.2.5",
6565
"fetch-event-stream": "0.1.5",
66-
"flat": "^6.0.1",
6766
"framer-motion": "12.17.0",
6867
"fuse.js": "7.1.0",
6968
"input-otp": "^1.4.1",
@@ -78,7 +77,8 @@
7877
"p-limit": "^6.2.0",
7978
"papaparse": "^5.5.3",
8079
"pluralize": "^8.0.0",
81-
"posthog-js": "1.67.1",
80+
"posthog-js": "1.252.0",
81+
"posthog-node": "5.1.0",
8282
"prettier": "3.5.3",
8383
"qrcode": "^1.5.3",
8484
"react": "19.1.0",

apps/dashboard/src/app/(app)/layout.tsx

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import "../../global.css";
22
import { DashboardRouterTopProgressBar } from "@/lib/DashboardRouter";
33
import { cn } from "@/lib/utils";
4-
import { PHProvider } from "lib/posthog/Posthog";
5-
import { PosthogHeadSetup } from "lib/posthog/PosthogHeadSetup";
6-
import { PostHogPageView } from "lib/posthog/PosthogPageView";
4+
75
import type { Metadata } from "next";
86
import PlausibleProvider from "next-plausible";
97
import { Inter } from "next/font/google";
@@ -61,26 +59,19 @@ export default function RootLayout({
6159
customDomain="https://pl.thirdweb.com"
6260
selfHosted
6361
/>
64-
<PosthogHeadSetup />
6562
</head>
66-
<PHProvider disable_session_recording={true}>
67-
<PostHogPageView />
68-
<body
69-
className={cn(
70-
"bg-background font-sans antialiased",
71-
fontSans.variable,
72-
)}
73-
>
74-
<AppRouterProviders>{children}</AppRouterProviders>
75-
<DashboardRouterTopProgressBar />
76-
<NextTopLoader
77-
color="hsl(var(--foreground))"
78-
height={3}
79-
shadow={false}
80-
showSpinner={false}
81-
/>
82-
</body>
83-
</PHProvider>
63+
<body
64+
className={cn("bg-background font-sans antialiased", fontSans.variable)}
65+
>
66+
<AppRouterProviders>{children}</AppRouterProviders>
67+
<DashboardRouterTopProgressBar />
68+
<NextTopLoader
69+
color="hsl(var(--foreground))"
70+
height={3}
71+
shadow={false}
72+
showSpinner={false}
73+
/>
74+
</body>
8475
</html>
8576
);
8677
}

apps/dashboard/src/app/(app)/team/[team_slug]/layout.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getTeamBySlug, hasToCompleteTeamOnboarding } from "@/api/team";
2-
import { PosthogIdentifierServer } from "components/wallets/PosthogIdentifierServer";
32
import { redirect } from "next/navigation";
43
import { Suspense } from "react";
54
import { getAuthToken } from "../../api/lib/getAuthToken";
@@ -60,9 +59,6 @@ export default async function RootTeamLayout(props: {
6059
<Suspense fallback={null}>
6160
<EnsureValidConnectedWalletLoginServer />
6261
</Suspense>
63-
<Suspense fallback={null}>
64-
<PosthogIdentifierServer />
65-
</Suspense>
6662
</div>
6763
);
6864
}

apps/dashboard/src/app/bridge/components/client/Providers.client.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import { ThemeProvider } from "next-themes";
33
import { Toaster } from "sonner";
44
import { ThirdwebProvider } from "thirdweb/react";
5-
import { PHProvider } from "../../../../lib/posthog/Posthog";
6-
import { PostHogPageView } from "../../../../lib/posthog/PosthogPageView";
75

86
export function BridgeProviders({ children }: { children: React.ReactNode }) {
97
return (
@@ -14,11 +12,8 @@ export function BridgeProviders({ children }: { children: React.ReactNode }) {
1412
enableSystem={false}
1513
defaultTheme="dark"
1614
>
17-
<PHProvider disable_session_recording={true}>
18-
<PostHogPageView />
19-
{children}
20-
<Toaster richColors theme="dark" />
21-
</PHProvider>
15+
{children}
16+
<Toaster richColors theme="dark" />
2217
</ThemeProvider>
2318
</ThirdwebProvider>
2419
);

apps/dashboard/src/app/nebula-app/layout.tsx

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import "../../global.css";
33
import "./nebula-global.css";
44
import { DashboardRouterTopProgressBar } from "@/lib/DashboardRouter";
55
import { cn } from "@/lib/utils";
6-
import { PHProvider } from "lib/posthog/Posthog";
7-
import { PosthogHeadSetup } from "lib/posthog/PosthogHeadSetup";
8-
import { PostHogPageView } from "lib/posthog/PosthogPageView";
96
import { Inter } from "next/font/google";
107
import NextTopLoader from "nextjs-toploader";
118
import { NebulaProviders } from "./providers";
@@ -37,26 +34,19 @@ export default function Layout(props: {
3734
<html lang="en" suppressHydrationWarning>
3835
<head>
3936
<link rel="icon" href="/assets/nebula/favicon.ico" />
40-
<PosthogHeadSetup />
4137
</head>
42-
<PHProvider disable_session_recording={false}>
43-
<PostHogPageView />
44-
<body
45-
className={cn(
46-
"bg-background font-sans antialiased",
47-
fontSans.variable,
48-
)}
49-
>
50-
<NebulaProviders>{props.children}</NebulaProviders>
51-
<DashboardRouterTopProgressBar />
52-
<NextTopLoader
53-
color="hsl(var(--foreground))"
54-
height={3}
55-
shadow={false}
56-
showSpinner={false}
57-
/>
58-
</body>
59-
</PHProvider>
38+
<body
39+
className={cn("bg-background font-sans antialiased", fontSans.variable)}
40+
>
41+
<NebulaProviders>{props.children}</NebulaProviders>
42+
<DashboardRouterTopProgressBar />
43+
<NextTopLoader
44+
color="hsl(var(--foreground))"
45+
height={3}
46+
shadow={false}
47+
showSpinner={false}
48+
/>
49+
</body>
6050
</html>
6151
);
6252
}

0 commit comments

Comments
 (0)