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

Function drainQueueToPayload

packages/cli/src/telemetry/client.ts:108–119  ·  view source on GitHub ↗

* Drain the in-memory queue into a PostHog `/batch/` payload string. * Returns null when there's nothing to send. Resets the queue as a side effect * so callers can fire-and-forget the resulting payload. * * $ip:null tells PostHog not to record the request IP for any of these events. * Server-s

()

Source from the content-addressed store, hash-verified

106 * Server-side "Discard client IP data" is also enabled in project settings.
107 */
108function drainQueueToPayload(): string | null {
109 if (eventQueue.length === 0) return null;
110 const config = readConfig();
111 const batch = eventQueue.map((e) => ({
112 event: e.event,
113 properties: { ...e.properties, $ip: null },
114 distinct_id: e.distinctId ?? config.anonymousId,
115 timestamp: e.timestamp,
116 }));
117 eventQueue = [];
118 return JSON.stringify({ api_key: POSTHOG_API_KEY, batch });
119}
120
121/**
122 * Flush all queued events to PostHog via async HTTP POST.

Callers 2

flushFunction · 0.85
flushSyncFunction · 0.85

Calls 1

readConfigFunction · 0.85

Tested by

no test coverage detected