mirror of
https://github.com/hanzoai/site.git
synced 2026-11-21 01:07:08 +00:00
One @hanzo/event client posts to api.hanzo.ai/v1/event under the host's own key: a pageview per route, product_viewed off a page's structured data, interaction capture (@hanzo/observe), errors that are the site's, session replay once analytics is allowed, and the funnel's checkout_started and sales_contacted on the links that start them. startTags loads GA4 and the Meta pixels from the host's tag set as the visitor's region and choice allow, and a link to another Hanzo host carries the visitor and first touch with it. lib/track.js is the one call pages fire their own moments through. Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
18 lines
1.1 KiB
JavaScript
18 lines
1.1 KiB
JavaScript
/* The funnel's one call, from anywhere on the site (hanzo-inc/app @hanzo/app lib/tags + app/providers.tsx `Stream`).
|
|
`track` sends a moment to our stream (POST /v1/event) and to every browser tag the visitor's consent and region allow,
|
|
under one event_id; `capture` sends a plain event to our stream alone. Both go out on the page's one @hanzo/event
|
|
client, which components/Telemetry.jsx attaches; a moment fired before that waits on the stream and goes out with it. */
|
|
import { Analytics, track as fire } from '@hanzo/event';
|
|
|
|
class Stream extends Analytics {
|
|
capture(...args) { this.client?.capture(...args); }
|
|
link(url) { return this.client ? this.client.link(url) : url; }
|
|
authorize(url) { return this.client ? this.client.authorize(url) : url; }
|
|
}
|
|
const stream = new Stream({ product: 'site', enabled: false });
|
|
|
|
/** Points the stream at the provider's client (Telemetry). */
|
|
export const attach = (client) => { stream.client = client; };
|
|
export const track = (name, params = {}) => fire(stream, name, params);
|
|
export const capture = (name, props = {}) => stream.capture(name, props);
|