11import { type ChildProcess , spawn } from 'node:child_process'
22import { childProcessEnv , proxyExecArgv } from '../environment'
33
4- /**
5- * Where events go. The key is a PostHog project token — a public, write-only
6- * value — baked into the published build by `bun build --env='SIM_CLI_TELEMETRY_*'`
7- * the way the Supabase CLI injects its own at link time. A checkout built
8- * without one has no destination and reports nothing, and a self-hosted
9- * deployment can point its own build at its own project.
10- *
11- * These two reads must stay literal `process.env.<NAME>` expressions: that is
12- * the only form the bundler substitutes.
13- */
14- const BUILT_IN_KEY = process . env . SIM_CLI_TELEMETRY_KEY
15- const BUILT_IN_HOST = process . env . SIM_CLI_TELEMETRY_HOST
16-
174export const DEFAULT_INGEST_HOST = 'https://us.i.posthog.com'
185
196/** The single-event capture endpoint, relative to the ingest host. */
@@ -33,10 +20,22 @@ export interface IngestTarget {
3320 host : string
3421}
3522
36- /** The destination this build was made with, if any. */
23+ /**
24+ * The destination this build was made with, if any. The key is a PostHog
25+ * project token — a public, write-only value — baked into the published build
26+ * by `bun build --env='SIM_CLI_TELEMETRY_*'` the way the Supabase CLI injects
27+ * its own at link time. A checkout built without one has no destination and
28+ * reports nothing, and a self-hosted deployment can point its own build at its
29+ * own project.
30+ *
31+ * Both reads must stay literal `process.env.<NAME>` expressions, the only form
32+ * the bundler substitutes. They are made on each call rather than at module
33+ * load so that, unbundled, the answer follows the environment a caller set.
34+ */
3735export function builtInIngestTarget ( ) : IngestTarget | undefined {
38- if ( ! BUILT_IN_KEY ) return undefined
39- return { key : BUILT_IN_KEY , host : BUILT_IN_HOST || DEFAULT_INGEST_HOST }
36+ const key = process . env . SIM_CLI_TELEMETRY_KEY
37+ if ( ! key ) return undefined
38+ return { key, host : process . env . SIM_CLI_TELEMETRY_HOST || DEFAULT_INGEST_HOST }
4039}
4140
4241/** One event in the shape PostHog's capture endpoint accepts. */
0 commit comments