| 1 | #!/usr/bin/env bun |
| 2 | |
| 3 | async function sendToPostHog(event: string, properties: Record<string, any>) { |
| 4 | const key = process.env["POSTHOG_KEY"] |
| 5 | |
| 6 | if (!key) { |
| 7 | console.warn("POSTHOG_API_KEY not set, skipping PostHog event") |
| 8 | return |
| 9 | } |
| 10 | |
| 11 | const response = await fetch("https://us.i.posthog.com/i/v0/e/", { |
| 12 | method: "POST", |
| 13 | headers: { |
| 14 | "Content-Type": "application/json", |
| 15 | }, |
| 16 | body: JSON.stringify({ |
| 17 | distinct_id: "download", |
| 18 | api_key: key, |
| 19 | event, |
| 20 | properties: { |
| 21 | ...properties, |
| 22 | }, |
| 23 | }), |
| 24 | }).catch(() => null) |
| 25 | |
| 26 | if (response && !response.ok) { |
| 27 | console.warn(`PostHog API error: ${response.status}`) |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | interface Asset { |
| 32 | name: string |