feat(cli): validate API key upfront via ping and unify telemetry identity resolution (#4701)

This commit is contained in:
Saket Aryan
2026-04-04 23:03:27 +05:30
committed by GitHub
parent 686d5e987d
commit 4642a1d6e3
6 changed files with 160 additions and 37 deletions
+6 -1
View File
@@ -53,16 +53,21 @@ function getDistinctId(): string {
/**
* Fire a PostHog event (non-blocking, returns void, never throws).
* Spawns telemetry-sender.cjs as a detached subprocess.
*
* When `preResolvedEmail` is provided (e.g. from an upfront ping
* validation), it is used directly as the PostHog distinct ID and the
* subprocess skips its own `/v1/ping/` call.
*/
export function captureEvent(
eventName: string,
properties: Record<string, unknown> = {},
preResolvedEmail?: string,
): void {
if (!isTelemetryEnabled()) return;
try {
const config = loadConfig();
const distinctId = getDistinctId();
const distinctId = preResolvedEmail || getDistinctId();
const payload = {
api_key: POSTHOG_API_KEY,