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

Function toTrackableAnalyticsPayload

common/src/util/analytics-log.ts:42–78  ·  view source on GitHub ↗
({
  data,
  level,
  msg,
  fallbackUserId,
}: {
  data: unknown
  level: string
  msg: string
  fallbackUserId?: string
})

Source from the content-addressed store, hash-verified

40}
41
42export function toTrackableAnalyticsPayload({
43 data,
44 level,
45 msg,
46 fallbackUserId,
47}: {
48 data: unknown
49 level: string
50 msg: string
51 fallbackUserId?: string
52}): TrackableAnalyticsPayload | null {
53 if (!data || typeof data !== 'object') {
54 return null
55 }
56
57 const record = data as AnalyticsLogData
58 const eventId = getAnalyticsEventId(record)
59 if (!eventId) {
60 return null
61 }
62
63 const userId = getUserId(record, fallbackUserId)
64
65 if (!userId) {
66 return null
67 }
68
69 return {
70 event: eventId,
71 userId,
72 properties: {
73 ...record,
74 level,
75 msg,
76 },
77 }
78}

Callers 3

flushBufferWithUserFunction · 0.90
processFunction · 0.90

Calls 2

getAnalyticsEventIdFunction · 0.85
getUserIdFunction · 0.85

Tested by

no test coverage detected