MCPcopy Create free account
hub / github.com/anomalyco/opencode / sendToPostHog

Function sendToPostHog

script/stats.ts:3–29  ·  view source on GitHub ↗
(event: string, properties: Record<string, any>)

Source from the content-addressed store, hash-verified

1#!/usr/bin/env bun
2
3async 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
31interface Asset {
32 name: string

Callers 1

stats.tsFile · 0.85

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected