Files
zeekay 2898607b0b Count a hanzo.chat visit once, not twice
A first visit loads / and then round-trips through the issuer's silent
sign-in to /auth/callback, a second document that sent a second
page_view for the same visit.  The callback no longer sends one; GA4's
history listener still counts the routes that follow.
2026-09-28 10:43:41 -07:00

66 lines
3.0 KiB
HTML

<!doctype html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8" />
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<!-- Placeholders. One image serves hanzo.chat, lux.chat and zoolabs.io, so
this document cannot know whose it is; `wear()` in src/brand.ts writes
the name and the mark from the host before the first render. Naming one
brand here is how the other two wore it until the bundle arrived. -->
<title>Chat</title>
<style>
/* The two things only the host document can answer: how tall the app is,
and that its one child is a flex item. @hanzo/ui's stylesheet resets and
paints everything else, and `Screen` fills its parent by growing — which
a block parent never asks it to do, so the whole app renders 0px tall.
`dvh` rather than `vh` so a phone's collapsing browser chrome cannot
crop the composer off the bottom of the conversation. */
#root {
display: flex;
height: 100dvh;
}
</style>
<!-- GA4, each brand host to its own stream: this one document serves every
brand, so a host with no stream here sends nothing. The first page view
queues before the bundle; gtag.js is fetched after `load`, since a script
in the head holds the load event until its host answers. Route changes
are GA4's own history listener. /auth/callback sends no page view of
its own: a first visit round-trips there through the issuer's silent
sign-in, and the visit has already been counted. Global Privacy Control
and Do Not Track opt out. -->
<script>
var tid = { 'hanzo.chat': 'G-GRQBMNDTT6' }[location.hostname];
if (tid && !navigator.globalPrivacyControl && navigator.doNotTrack !== '1') {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)}
gtag('js', new Date());
gtag('config', tid, {
send_page_view: location.pathname !== '/auth/callback',
linker: { domains: [location.hostname, 'hanzo.ai', 'hanzo.id', 'pay.hanzo.ai', 'cal.hanzo.ai'] },
});
addEventListener('load', function () {
var s = document.createElement('script');
s.async = true;
s.src = 'https://www.googletagmanager.com/gtag/js?id=' + tid;
document.head.appendChild(s);
}, { once: true });
}
</script>
</head>
<body>
<div id="root"></div>
<!-- A local cloud is its own issuer, so on loopback the brand's issuer is the
cloud you are running rather than hanzo.id. Same escape hatch the static
plane uses in production; scoped to loopback so no deployment sees it. -->
<script>
if (['localhost', '127.0.0.1'].includes(location.hostname)) {
window.__brand = Object.assign({}, window.__brand, {
issuer: 'http://localhost:18080',
})
}
</script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>