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

Function updateTelemetryCounts

cmd/server/main-server.go:231–272  ·  view source on GitHub ↗
(lastCounts telemetrydata.TEventProps)

Source from the content-addressed store, hash-verified

229}
230
231func updateTelemetryCounts(lastCounts telemetrydata.TEventProps) telemetrydata.TEventProps {
232 ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
233 defer cancelFn()
234 var props telemetrydata.TEventProps
235 props.CountBlocks, _ = wstore.DBGetCount[*waveobj.Block](ctx)
236 props.CountTabs, _ = wstore.DBGetCount[*waveobj.Tab](ctx)
237 props.CountWindows, _ = wstore.DBGetCount[*waveobj.Window](ctx)
238 props.CountWorkspaces, _, _ = wstore.DBGetWSCounts(ctx)
239 props.CountSSHConn = conncontroller.GetNumSSHHasConnected()
240 props.CountWSLConn = wslconn.GetNumWSLHasConnected()
241 props.CountJobs = jobcontroller.GetNumJobsRunning()
242 props.CountJobsConnected = jobcontroller.GetNumJobsConnected()
243 props.CountViews, _ = wstore.DBGetBlockViewCounts(ctx)
244
245 fullConfig := wconfig.GetWatcher().GetFullConfig()
246 customWidgets := fullConfig.CountCustomWidgets()
247 customAIPresets := fullConfig.CountCustomAIPresets()
248 customSettings := wconfig.CountCustomSettings()
249 customAIModes := fullConfig.CountCustomAIModes()
250
251 props.UserSet = &telemetrydata.TEventUserProps{
252 SettingsCustomWidgets: customWidgets,
253 SettingsCustomAIPresets: customAIPresets,
254 SettingsCustomSettings: customSettings,
255 SettingsCustomAIModes: customAIModes,
256 }
257
258 secretsCount, err := secretstore.CountSecrets()
259 if err == nil {
260 props.UserSet.SettingsSecretsCount = secretsCount
261 }
262
263 if utilfn.CompareAsMarshaledJson(props, lastCounts) {
264 return lastCounts
265 }
266 tevent := telemetrydata.MakeTEvent("app:counts", props)
267 err = telemetry.RecordTEvent(ctx, tevent)
268 if err != nil {
269 log.Printf("error recording counts tevent: %v\n", err)
270 }
271 return props
272}
273
274func updateTelemetryCountsLoop() {
275 defer func() {

Callers 1

Calls 15

DBGetWSCountsFunction · 0.92
GetNumSSHHasConnectedFunction · 0.92
GetNumWSLHasConnectedFunction · 0.92
GetNumJobsRunningFunction · 0.92
GetNumJobsConnectedFunction · 0.92
DBGetBlockViewCountsFunction · 0.92
GetWatcherFunction · 0.92
CountCustomSettingsFunction · 0.92
CountSecretsFunction · 0.92
CompareAsMarshaledJsonFunction · 0.92
MakeTEventFunction · 0.92
RecordTEventFunction · 0.92

Tested by

no test coverage detected