MCPcopy Create free account
hub / github.com/arctic-cli/interface / flush

Function flush

packages/arctic/src/telemetry/index.ts:91–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89 }
90
91 export async function flush(): Promise<void> {
92 if (queue.length === 0) return
93 if (!(await isEnabled())) return
94
95 const events = queue.splice(0, queue.length)
96 const context = await getContext()
97
98 const payload = {
99 events,
100 context,
101 }
102
103 log.debug("flushing", { count: events.length })
104
105 await fetch(TELEMETRY_ENDPOINT, {
106 method: "POST",
107 headers: { "Content-Type": "application/json" },
108 body: JSON.stringify(payload),
109 signal: AbortSignal.timeout(5000),
110 }).catch((err) => {
111 log.debug("flush failed", { error: err.message })
112 queue.unshift(...events.slice(0, MAX_QUEUE_SIZE - queue.length))
113 })
114 }
115
116 export async function dailyHeartbeat(): Promise<void> {
117 if (!(await isEnabled())) return

Callers 1

trackFunction · 0.70

Calls 3

getContextFunction · 0.85
isEnabledFunction · 0.70
fetchFunction · 0.50

Tested by

no test coverage detected