Skip to content

Commit e77579e

Browse files
Add website PostHog analytics
Wire the landing site to initialize posthog-js from public environment variables.
1 parent 181ff31 commit e77579e

4 files changed

Lines changed: 309 additions & 0 deletions

File tree

apps/landing/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@tiptap/react": "^3.20.0",
2020
"@tiptap/starter-kit": "^3.20.0",
2121
"astro": "^5.1.0",
22+
"posthog-js": "^1.369.3",
2223
"react": "^19.2.4",
2324
"react-dom": "^19.2.4"
2425
},

apps/landing/src/env.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
/// <reference types="astro/client" />
22
/// <reference types="@astrojs/mdx/client" />
3+
4+
interface ImportMetaEnv {
5+
readonly PUBLIC_GOOGLE_SITE_VERIFICATION?: string;
6+
readonly PUBLIC_POSTHOG_HOST?: string;
7+
readonly PUBLIC_POSTHOG_KEY?: string;
8+
}

apps/landing/src/layouts/SiteLayout.astro

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ const jsonLd = Array.isArray(schema,) ? schema : [schema,];
7878
))
7979
}
8080
<slot name="head" />
81+
<script>
82+
import posthog from "posthog-js";
83+
84+
const posthogKey = import.meta.env.PUBLIC_POSTHOG_KEY?.trim();
85+
const posthogHost = import.meta.env.PUBLIC_POSTHOG_HOST?.trim() || "https://us.i.posthog.com";
86+
87+
if (posthogKey) {
88+
posthog.init(posthogKey, {
89+
api_host: posthogHost,
90+
defaults: "2026-01-30",
91+
},);
92+
}
93+
</script>
8194
</head>
8295
<body>
8396
<div class="site-ambient"></div>

0 commit comments

Comments
 (0)