MCPcopy
hub / github.com/wavetermdev/waveterm / RecordTEvent

Function RecordTEvent

pkg/telemetry/telemetry.go:273–305  ·  view source on GitHub ↗
(ctx context.Context, tevent *telemetrydata.TEvent)

Source from the content-addressed store, hash-verified

271}
272
273func RecordTEvent(ctx context.Context, tevent *telemetrydata.TEvent) error {
274 if tevent == nil {
275 return nil
276 }
277 if tevent.Uuid == "" {
278 tevent.Uuid = uuid.New().String()
279 }
280 err := tevent.Validate(true)
281 if err != nil {
282 return err
283 }
284 tevent.EnsureTimestamps()
285
286 // Set AppFirstDay if on same calendar day as TOS agreement
287 tosAgreedTs := GetTosAgreedTs()
288 if tosAgreedTs == 0 {
289 tevent.Props.AppFirstDay = true
290 } else {
291 tosYear, tosMonth, tosDay := time.UnixMilli(tosAgreedTs).Date()
292 nowYear, nowMonth, nowDay := time.Now().Date()
293 if tosYear == nowYear && tosMonth == nowMonth && tosDay == nowDay {
294 tevent.Props.AppFirstDay = true
295 }
296 }
297
298 if tevent.Event == ActivityEventName {
299 return updateActivityTEvent(ctx, tevent)
300 }
301 if tevent.Event == WshRunEventName {
302 return updateWshRunTEvent(ctx, tevent)
303 }
304 return insertTEvent(ctx, tevent)
305}
306
307func CleanOldTEvents(ctx context.Context) error {
308 daysToKeep := 7

Callers 9

RecordTEventCommandMethod · 0.92
sendAIMetricsTelemetryFunction · 0.92
panicTelemetryHandlerFunction · 0.92
updateTelemetryCountsFunction · 0.92
startupActivityUpdateFunction · 0.92
shutdownActivityUpdateFunction · 0.92
GoRecordTEventWrapFunction · 0.85

Calls 7

GetTosAgreedTsFunction · 0.85
updateActivityTEventFunction · 0.85
updateWshRunTEventFunction · 0.85
insertTEventFunction · 0.85
EnsureTimestampsMethod · 0.80
StringMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected