fix(site): replace GA4 with PostHog cookieless analytics (#894)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Darius Cepulis
2026-03-11 16:03:26 -05:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 464d5e5fa2
commit 0de0c28123
5 changed files with 104 additions and 21 deletions
+15
View File
@@ -3,6 +3,21 @@
publish = "site/dist"
ignore = "pnpm dlx turbo-ignore site --task=build --fallback=origin/main"
# PostHog reverse proxy (ad-blocker bypass)
[[redirects]]
from = "/ph/static/*"
to = "https://us-assets.i.posthog.com/static/:splat"
host = "us-assets.i.posthog.com"
status = 200
force = true
[[redirects]]
from = "/ph/*"
to = "https://us.i.posthog.com/:splat"
host = "us.i.posthog.com"
status = 200
force = true
# Netlify aliases -> videojs.org
[[redirects]]
from = "https://videojs.com/*"
@@ -2,6 +2,10 @@ import type { Config } from '@netlify/edge-functions';
export default async (request: Request) => {
const url = new URL(request.url);
// Skip PostHog proxy paths — handled by Netlify redirects
if (url.pathname.startsWith('/ph/')) return;
const redirectUrl = new URL(url.pathname.replace(/\/$/, ''), url.origin);
redirectUrl.search = url.search;
redirectUrl.hash = url.hash;
+80
View File
@@ -0,0 +1,80 @@
---
/**
* PostHog analytics with cookieless server-side hashing.
* Idle-loaded to minimize impact on page performance.
*
* Requires "Cookieless server hash mode" enabled in PostHog project settings.
*/
---
<link rel="dns-prefetch" href="/" />
<link rel="preconnect" href="/" crossorigin />
<script is:inline>
(function () {
function load() {
!(function (t, e) {
var o, n, p, r;
e.__SV ||
((window.posthog = e),
(e._i = []),
(e.init = function (i, s, a) {
function g(t, e) {
var o = e.split(".");
(2 == o.length && ((t = t[o[0]]), (e = o[1])),
(t[e] = function () {
t.push([e].concat(Array.prototype.slice.call(arguments, 0)));
}));
}
(((p = t.createElement("script")).type = "text/javascript"),
(p.async = !0),
(p.src =
s.api_host.replace(".i.posthog.com", "-assets.i.posthog.com") +
"/static/array.js"),
(r = t.getElementsByTagName("script")[0]).parentNode.insertBefore(
p,
r,
));
var u = e;
for (
void 0 !== a ? (u = e[a] = []) : (a = "posthog"),
u.people = u.people || [],
u.toString = function (t) {
var e = "posthog";
return (
"posthog" !== a && (e += "." + a),
t || (e += " (stub)"),
e
);
},
u.people.toString = function () {
return u.toString(1) + ".people (stub)";
},
o =
"init capture register register_once register_for_session unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group identify setPersonProperties setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags resetGroups onFeatureFlags addFeatureFlagsHandler onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep".split(
" ",
),
n = 0;
n < o.length;
n++
)
g(u, o[n]);
e._i.push([i, s, a]);
}),
(e.__SV = 1));
})(document, window.posthog || []);
posthog.init("phc_5gaDOyX1jWPR1n7JAiGiHdwXwGwfsknwdj1ILI2IiBr", {
api_host: "/ph",
ui_host: "https://us.posthog.com",
defaults: "2026-01-30",
cookieless_mode: "always",
});
}
if (typeof requestIdleCallback === "function") {
requestIdleCallback(load);
} else {
setTimeout(load, 3000);
}
})();
</script>
+2 -2
View File
@@ -1,6 +1,6 @@
---
title: "Privacy Policy"
description: "Last Updated March 9, 2026"
description: "Last Updated March 11, 2026"
---
## Introduction
@@ -18,7 +18,7 @@ Like most websites, our web servers may automatically collect standard technical
This information is used solely for maintaining the website's functionality, security, and performance, as well as to understand how individuals are using the website. It is not used for tracking or profiling visitors across services or browsing sessions, or for advertising purposes.
We may use Google Analytics to collect and process this information for the purposes identified above. We have configured Google Analytics to collect this information without the use of cookies. You can learn more about Google Analytics and its relevant processing of data in Google's "Safeguarding Your Data" Analytics Guide. You can learn about Google Analytics' currently available opt-outs, including the Google Analytics Browser Add-On here: https://tools.google.com/dlpage/gaoptout/.
We may use PostHog to collect and process this information for the purposes identified above. We have configured PostHog to collect this information without the use of cookies. PostHog's cookieless mode uses server-side hashing to count unique visitors without storing any cookies, localStorage, or sessionStorage data on your device.
## Open Source and Development Platforms
+3 -19
View File
@@ -9,6 +9,7 @@ import '@/styles/globals.css';
import BannerInit from '@/components/BannerInit.astro';
import { PreferenceSync } from '@/components/docs/PreferenceSync';
import LegacyBanner from '@/components/LegacyBanner.astro';
import Posthog from '@/components/Posthog.astro';
import ThemeInit from '@/components/ThemeInit.astro';
interface Props {
@@ -55,25 +56,8 @@ const fullTitle =
/>
<meta name="generator" content={Astro.generator} />
{/* Google Analytics (cookieless) */}
<script
is:inline
async
src="https://www.googletagmanager.com/gtag/js?id=G-WTF4CZJSGP"></script>
<script is:inline>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("consent", "default", {
analytics_storage: "denied",
ad_storage: "denied",
ad_user_data: "denied",
ad_personalization: "denied",
});
gtag("js", new Date());
gtag("config", "G-WTF4CZJSGP");
</script>
{/* Analytics (production only) */}
{import.meta.env.PROD && <Posthog />}
{/* Important stuff */}
<slot name="priority-head" />