MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / flushAnalytics

Function flushAnalytics

common/src/analytics.ts:11–34  ·  view source on GitHub ↗
(logger?: Logger)

Source from the content-addressed store, hash-verified

9let client: AnalyticsClient | undefined
10
11export async function flushAnalytics(logger?: Logger) {
12 if (!client) {
13 return
14 }
15 try {
16 await client.flush()
17 } catch (error) {
18 // Log the error but don't throw - flushing is best-effort
19 logger?.warn({ error }, 'Failed to flush analytics')
20
21 // Track the flush failure event (will be queued for next successful flush)
22 try {
23 client.capture({
24 distinctId: 'system',
25 event: AnalyticsEvent.FLUSH_FAILED,
26 properties: {
27 error: error instanceof Error ? error.message : String(error),
28 },
29 })
30 } catch {
31 // Silently ignore if we can't even track the failure
32 }
33 }
34}
35
36export function withDefaultProperties(
37 trackEventFn: TrackEventFn,

Callers

nothing calls this directly

Calls 2

captureMethod · 0.80
flushMethod · 0.45

Tested by

no test coverage detected