()
| 149 | * so the parent process exits immediately without waiting. |
| 150 | */ |
| 151 | export function flushSync(): void { |
| 152 | const payload = drainQueueToPayload(); |
| 153 | if (payload == null) return; |
| 154 | |
| 155 | try { |
| 156 | const { spawn } = require("node:child_process") as typeof import("node:child_process"); |
| 157 | const child = spawn( |
| 158 | process.execPath, |
| 159 | [ |
| 160 | "-e", |
| 161 | `fetch(${JSON.stringify(`${POSTHOG_HOST}/batch/`)},{method:"POST",headers:{"Content-Type":"application/json"},body:${JSON.stringify(payload)},signal:AbortSignal.timeout(${FLUSH_TIMEOUT_MS})}).catch(()=>{})`, |
| 162 | ], |
| 163 | { detached: true, stdio: "ignore" }, |
| 164 | ); |
| 165 | // Let the parent exit without waiting for the child |
| 166 | child.unref(); |
| 167 | } catch { |
| 168 | // Silently ignore |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Show the first-run telemetry notice if it hasn't been shown yet. |
nothing calls this directly
no test coverage detected