MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / flush

Function flush

packages/cli/src/telemetry/client.ts:125–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123 * Called before normal process exit via `beforeExit`.
124 */
125export async function flush(): Promise<void> {
126 const payload = drainQueueToPayload();
127 if (payload == null) return;
128
129 const controller = new AbortController();
130 const timeout = setTimeout(() => controller.abort(), FLUSH_TIMEOUT_MS);
131
132 try {
133 await fetch(`${POSTHOG_HOST}/batch/`, {
134 method: "POST",
135 headers: { "Content-Type": "application/json", Connection: "close" },
136 body: payload,
137 signal: controller.signal,
138 });
139 } catch {
140 // Silently ignore — telemetry must never break the CLI
141 } finally {
142 clearTimeout(timeout);
143 }
144}
145
146/**
147 * Fire-and-forget flush for use in the `exit` event handler.

Callers

nothing calls this directly

Calls 2

drainQueueToPayloadFunction · 0.85
fetchFunction · 0.85

Tested by

no test coverage detected