diff --git a/Website/lib/loader.mjs b/Website/lib/loader.mjs
index 5605f76..118bfdd 100644
--- a/Website/lib/loader.mjs
+++ b/Website/lib/loader.mjs
@@ -1,6 +1,6 @@
// The one inline script every page ends with. It starts the page's scripts. The Content Security Policy in
// public/_headers runs this script alone, by its hash, and what it starts ('strict-dynamic'), so it is the same on
-// every page and starts only the site's own files and Plausible. astro.config.mjs checks every page carries it
+// every page and starts only the site's own files, Plausible and PostHog. astro.config.mjs checks every page carries it
// unchanged and writes its hash into the built _headers.
//
// Each script's address carries a hash of the file, so a changed script is never served from a stale cache.
@@ -37,14 +37,60 @@ export function loader(publicDir) {
plausible.init();
}
if (missing) plausible("404");
+ // PostHog, on the live site only: page views, clicks, heatmaps, web vitals, errors and recordings of visits, in
+ // the edbn project ui.edbn.me uses, through /ingest on this site (worker/index.js). Calls wait in its queue until
+ // its script arrives. It keeps its random id in this site's local storage, never a cookie, so nothing joins a
+ // visit here to ui.edbn.me. Recordings never hold what is typed, and leave out anything marked ph-no-capture: the
+ // key and the buyer's email. Privacy section 6 says exactly this, so change both together.
+ var reports = location.hostname === "outbound.edbn.me";
+ if (reports) {
+ var posthog = window.posthog = [];
+ posthog.people = [];
+ posthog.capture = function () { posthog.push(["capture"].concat([].slice.call(arguments))); };
+ posthog._i = [["phc_Ckkg6Qm4MnyqPUe27H93ZjigjBJxh3booYsszWpsN8Yi", {
+ api_host: "/ingest",
+ ui_host: "https://us.posthog.com",
+ defaults: "2026-08-30",
+ persistence: "localStorage",
+ person_profiles: "identified_only",
+ capture_exceptions: true,
+ capture_heatmaps: true,
+ capture_dead_clicks: true,
+ capture_performance: { web_vitals: true, network_timing: true },
+ enable_recording_console_log: true,
+ session_recording: { maskAllInputs: true, recordHeaders: false, recordBody: false },
+ // Polar's checkout address, which a buyer arrives on the thank-you page from, is cut to its host.
+ before_send: function (event) {
+ [event && event.properties, event && event.$set_once, event && event.$set].forEach(function (props) {
+ for (var key in props || {}) {
+ if (/referr?er$/.test(key) && typeof props[key] === "string" && /polar\\.sh/.test(props[key])) {
+ props[key] = props[key].replace(/^(https?:\\/\\/[^\\/?#]+).*$/, "$1");
+ }
+ }
+ });
+ return event;
+ }
+ }]];
+ }
// Addresses go through a Trusted Types policy where the browser has them, which takes these and nothing else.
- var urls = ${JSON.stringify({ plausible: "https://plausible.io/js/pa-UjwzQoq8qX6tVKev_Xvxo.js", ...urls })};
+ var urls = ${JSON.stringify({ plausible: "https://plausible.io/js/pa-UjwzQoq8qX6tVKev_Xvxo.js", posthog: "/ingest/static/array.js", ...urls })};
var policy = window.trustedTypes && trustedTypes.createPolicy("outbound", {
createScriptURL: function (url) {
for (var name in urls) if (urls[name] === url) return url;
throw new TypeError("Not one of Outbound's scripts: " + url);
}
});
+ // PostHog fetches the rest of itself (recordings, web vitals and so on) by setting addresses of its own, which
+ // the default policy lets through when they are on this site under /ingest/static/ or /ingest/array/.
+ if (reports && window.trustedTypes) {
+ trustedTypes.createPolicy("default", {
+ createScriptURL: function (url) {
+ var address = new URL(url, location.href);
+ if (address.origin === location.origin && /^\\/ingest\\/(static|array)\\//.test(address.pathname)) return url;
+ throw new TypeError("Not one of Outbound's scripts: " + url);
+ }
+ });
+ }
function start(name, async) {
var script = document.createElement("script");
script.src = policy ? policy.createScriptURL(urls[name]) : urls[name];
@@ -52,6 +98,7 @@ export function loader(publicDir) {
document.body.appendChild(script);
}
start("plausible", true);
+ if (reports) start("posthog", true);
// The page's own scripts run in this order, as they would from tags here.
start("app", false);
if (page) start(page, false);
diff --git a/Website/public/app.js b/Website/public/app.js
index f599257..ac96b1f 100644
--- a/Website/public/app.js
+++ b/Website/public/app.js
@@ -19,11 +19,14 @@
return WORDS[key] || english;
}
- // Counts a moment with Plausible. Blocked, missing or failing, it does nothing, and nothing waits for it.
+ // Counts a moment with Plausible and PostHog. Blocked, missing or failing, each does nothing, and nothing waits.
function track(name, props) {
try {
if (typeof window.plausible === "function") window.plausible(name, { props: props });
} catch (error) {}
+ try {
+ if (window.posthog && typeof window.posthog.capture === "function") window.posthog.capture(name, props);
+ } catch (error) {}
}
// Which part of the page a link sits in, so the counts can tell the top bar's Buy from the price box's.
@@ -115,7 +118,7 @@
var small = buy.classList.contains("btn-sm");
var button = document.createElement("button");
button.type = "button";
- button.className = "btn btn-light key-button" + (small ? " btn-sm" : "");
+ button.className = "btn btn-light key-button ph-no-capture" + (small ? " btn-sm" : "");
button.title = word("js.copyKeyTitle", "Copy your key");
if (!small) {
var code = document.createElement("code");
diff --git a/Website/public/feedback.js b/Website/public/feedback.js
index 85e4384..75c1472 100644
--- a/Website/public/feedback.js
+++ b/Website/public/feedback.js
@@ -15,6 +15,9 @@
try {
if (typeof window.plausible === "function") window.plausible(name, { props: props });
} catch (error) {}
+ try {
+ if (window.posthog && typeof window.posthog.capture === "function") window.posthog.capture(name, props);
+ } catch (error) {}
}
var form = document.getElementById("feedback");
diff --git a/Website/public/thanks.js b/Website/public/thanks.js
index ca8bee1..696b2fb 100644
--- a/Website/public/thanks.js
+++ b/Website/public/thanks.js
@@ -12,13 +12,20 @@
return WORDS[key] || english;
}
- // Counts a moment with Plausible. Blocked, missing or failing, it does nothing, and nothing waits for it.
+ // Counts a moment with Plausible and PostHog. Blocked, missing or failing, each does nothing, and nothing waits.
function track(name, props, revenue) {
try {
if (typeof window.plausible === "function") {
window.plausible(name, revenue ? { props: props, revenue: revenue } : { props: props });
}
} catch (error) {}
+ try {
+ if (window.posthog && typeof window.posthog.capture === "function") {
+ var extra = revenue ? { revenue: revenue.amount, currency: revenue.currency } : {};
+ for (var prop in props) extra[prop] = props[prop];
+ window.posthog.capture(name, extra);
+ }
+ } catch (error) {}
}
var id = window.OUTBOUND_CHECKOUT;
diff --git a/Website/public/waitlist.js b/Website/public/waitlist.js
index 1614365..4fddd4c 100644
--- a/Website/public/waitlist.js
+++ b/Website/public/waitlist.js
@@ -15,6 +15,9 @@
try {
if (typeof window.plausible === "function") window.plausible(name, { props: props });
} catch (error) {}
+ try {
+ if (window.posthog && typeof window.posthog.capture === "function") window.posthog.capture(name, props);
+ } catch (error) {}
}
var form = document.getElementById("waitlist");
diff --git a/Website/src/pages/[...lang]/thanks.astro b/Website/src/pages/[...lang]/thanks.astro
index 9681eeb..76ab55a 100644
--- a/Website/src/pages/[...lang]/thanks.astro
+++ b/Website/src/pages/[...lang]/thanks.astro
@@ -29,7 +29,7 @@ const href = (path: string) => localHref(lang, path);
{/* The key, under Activate and before the menu bar, once thanks.js has it. */}
-
+
diff --git a/Website/src/pages/privacy.astro b/Website/src/pages/privacy.astro
index aef4ee1..b28eedb 100644
--- a/Website/src/pages/privacy.astro
+++ b/Website/src/pages/privacy.astro
@@ -10,7 +10,7 @@ import Topbar from "../components/Topbar.astro";
Privacy.
The app has no account and no analytics. The painting happens on your Mac. This policy says exactly what Outbound and this website do with personal data, who handles it, and what you can ask of us.