(lastCounts telemetrydata.TEventProps)
| 229 | } |
| 230 | |
| 231 | func 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 | |
| 274 | func updateTelemetryCountsLoop() { |
| 275 | defer func() { |
no test coverage detected