Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
123456789101112131415161718192021222324252627import type { WebConfig } from "#lib/server/config.ts";
// best-effort: resolves either way, and does nothing without an api keyexport const capture = async ( config: WebConfig, event: string, distinctId: string, properties: Record<string, unknown> = {}): Promise<void> => { if (!config.posthogApiKey) return; try { await fetch(`${config.posthogHost}/capture/`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ api_key: config.posthogApiKey, event, distinct_id: distinctId, properties: { ...properties, environment: config.posthogEnv }, timestamp: new Date().toISOString() }) }); } catch { // analytics never breaks the request it rides on }};