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

Function startupActivityUpdate

cmd/server/main-server.go:305–364  ·  view source on GitHub ↗
(firstLaunch bool)

Source from the content-addressed store, hash-verified

303}
304
305func startupActivityUpdate(firstLaunch bool) {
306 defer func() {
307 panichandler.PanicHandler("startupActivityUpdate", recover())
308 }()
309 ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
310 defer cancelFn()
311 activity := wshrpc.ActivityUpdate{Startup: 1}
312 err := telemetry.UpdateActivity(ctx, activity) // set at least one record into activity (don't use go routine wrap here)
313 if err != nil {
314 log.Printf("error updating startup activity: %v\n", err)
315 }
316 autoUpdateChannel := telemetry.AutoUpdateChannel()
317 autoUpdateEnabled := telemetry.IsAutoUpdateEnabled()
318 shellType, shellVersion, shellErr := shellutil.DetectShellTypeAndVersion()
319 if shellErr != nil {
320 shellType = "error"
321 shellVersion = ""
322 }
323 userSetOnce := &telemetrydata.TEventUserProps{
324 ClientInitialVersion: "v" + WaveVersion,
325 }
326 tosTs := telemetry.GetTosAgreedTs()
327 var cohortTime time.Time
328 if tosTs > 0 {
329 cohortTime = time.UnixMilli(tosTs)
330 } else {
331 cohortTime = time.Now()
332 }
333 cohortMonth := cohortTime.Format("2006-01")
334 year, week := cohortTime.ISOWeek()
335 cohortISOWeek := fmt.Sprintf("%04d-W%02d", year, week)
336 userSetOnce.CohortMonth = cohortMonth
337 userSetOnce.CohortISOWeek = cohortISOWeek
338 fullConfig := wconfig.GetWatcher().GetFullConfig()
339 props := telemetrydata.TEventProps{
340 UserSet: &telemetrydata.TEventUserProps{
341 ClientVersion: "v" + wavebase.WaveVersion,
342 ClientBuildTime: wavebase.BuildTime,
343 ClientArch: wavebase.ClientArch(),
344 ClientOSRelease: wavebase.UnameKernelRelease(),
345 ClientIsDev: wavebase.IsDevMode(),
346 ClientPackageType: wavebase.ClientPackageType(),
347 ClientMacOSVersion: wavebase.ClientMacOSVersion(),
348 AutoUpdateChannel: autoUpdateChannel,
349 AutoUpdateEnabled: autoUpdateEnabled,
350 LocalShellType: shellType,
351 LocalShellVersion: shellVersion,
352 SettingsTransparent: fullConfig.Settings.WindowTransparent,
353 },
354 UserSetOnce: userSetOnce,
355 }
356 if firstLaunch {
357 props.AppFirstLaunch = true
358 }
359 tevent := telemetrydata.MakeTEvent("app:startup", props)
360 err = telemetry.RecordTEvent(ctx, tevent)
361 if err != nil {
362 log.Printf("error recording startup event: %v\n", err)

Callers 1

mainFunction · 0.85

Calls 15

PanicHandlerFunction · 0.92
UpdateActivityFunction · 0.92
AutoUpdateChannelFunction · 0.92
IsAutoUpdateEnabledFunction · 0.92
GetTosAgreedTsFunction · 0.92
GetWatcherFunction · 0.92
ClientArchFunction · 0.92
UnameKernelReleaseFunction · 0.92
IsDevModeFunction · 0.92
ClientPackageTypeFunction · 0.92
ClientMacOSVersionFunction · 0.92

Tested by

no test coverage detected