(
event: string,
properties: EventProperties = {},
distinctId?: string,
)
| 64 | * Queue a telemetry event. Non-blocking, fail-silent. |
| 65 | */ |
| 66 | export function trackEvent( |
| 67 | event: string, |
| 68 | properties: EventProperties = {}, |
| 69 | distinctId?: string, |
| 70 | ): void { |
| 71 | if (!shouldTrack()) return; |
| 72 | |
| 73 | const sys = getSystemMeta(); |
| 74 | eventQueue.push({ |
| 75 | event, |
| 76 | distinctId, |
| 77 | properties: { |
| 78 | ...properties, |
| 79 | cli_version: VERSION, |
| 80 | os: process.platform, |
| 81 | arch: process.arch, |
| 82 | node_version: process.version, |
| 83 | os_release: sys.os_release, |
| 84 | cpu_count: sys.cpu_count, |
| 85 | cpu_model: sys.cpu_model ?? undefined, |
| 86 | cpu_speed: sys.cpu_speed ?? undefined, |
| 87 | memory_total_mb: sys.memory_total_mb, |
| 88 | is_docker: sys.is_docker, |
| 89 | is_ci: sys.is_ci, |
| 90 | ci_name: sys.ci_name ?? undefined, |
| 91 | is_wsl: sys.is_wsl, |
| 92 | is_tty: sys.is_tty, |
| 93 | sandbox_runtime: sys.sandbox_runtime ?? undefined, |
| 94 | agent_runtime: sys.agent_runtime ?? undefined, |
| 95 | }, |
| 96 | timestamp: new Date().toISOString(), |
| 97 | }); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Drain the in-memory queue into a PostHog `/batch/` payload string. |
no test coverage detected