mirror of
https://github.com/hanzoai/site.git
synced 2026-11-20 21:14:28 +00:00
Describe the live catalog, the plan ladder, the open-source read, the Sigil maths, the tilt and the sound kit with real types. Sound is now off until the visitor sets localStorage hz-sound to "on". Claude-Session: https://claude.ai/code/session_015XYKLix9PSyn6Jw2HWKprk
19 lines
1.3 KiB
TypeScript
19 lines
1.3 KiB
TypeScript
/* 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 {
|
|
declare client?: Analytics | null;
|
|
capture(...args: Parameters<Analytics['capture']>) { this.client?.capture(...args); }
|
|
link(url: string) { return this.client ? this.client.link(url) : url; }
|
|
authorize(url: string) { 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: Analytics | null | undefined) => { stream.client = client; };
|
|
export const track = (name: string, params: Record<string, unknown> = {}) => fire(stream, name, params);
|
|
export const capture = (name: string, props: Record<string, unknown> = {}) => stream.capture(name, props);
|