diff --git a/cmd/server/main-server.go b/cmd/server/main-server.go index 1dfcf0d824..ddbd16889f 100644 --- a/cmd/server/main-server.go +++ b/cmd/server/main-server.go @@ -343,6 +343,8 @@ func startupActivityUpdate(firstLaunch bool) { ClientArch: wavebase.ClientArch(), ClientOSRelease: wavebase.UnameKernelRelease(), ClientIsDev: wavebase.IsDevMode(), + ClientPackageType: wavebase.ClientPackageType(), + ClientMacOSVersion: wavebase.ClientMacOSVersion(), AutoUpdateChannel: autoUpdateChannel, AutoUpdateEnabled: autoUpdateEnabled, LocalShellType: shellType, diff --git a/frontend/types/gotypes.d.ts b/frontend/types/gotypes.d.ts index 8b60d91dd2..2d155a919c 100644 --- a/frontend/types/gotypes.d.ts +++ b/frontend/types/gotypes.d.ts @@ -1442,6 +1442,8 @@ declare global { "client:buildtime"?: string; "client:osrelease"?: string; "client:isdev"?: boolean; + "client:packagetype"?: string; + "client:macos"?: string; "cohort:month"?: string; "cohort:isoweek"?: string; "autoupdate:channel"?: string; @@ -1540,6 +1542,8 @@ declare global { "client:buildtime"?: string; "client:osrelease"?: string; "client:isdev"?: boolean; + "client:packagetype"?: string; + "client:macos"?: string; "cohort:month"?: string; "cohort:isoweek"?: string; "autoupdate:channel"?: string; diff --git a/package-lock.json b/package-lock.json index c47b7dc114..269181d32a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "waveterm", - "version": "0.14.1-beta.0", + "version": "0.14.1-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "waveterm", - "version": "0.14.1-beta.0", + "version": "0.14.1-beta.1", "hasInstallScript": true, "license": "Apache-2.0", "workspaces": [ diff --git a/pkg/telemetry/telemetrydata/telemetrydata.go b/pkg/telemetry/telemetrydata/telemetrydata.go index 1c9269dc5c..222ebfbaed 100644 --- a/pkg/telemetry/telemetrydata/telemetrydata.go +++ b/pkg/telemetry/telemetrydata/telemetrydata.go @@ -76,6 +76,8 @@ type TEventUserProps struct { ClientBuildTime string `json:"client:buildtime,omitempty"` ClientOSRelease string `json:"client:osrelease,omitempty"` ClientIsDev bool `json:"client:isdev,omitempty"` + ClientPackageType string `json:"client:packagetype,omitempty"` + ClientMacOSVersion string `json:"client:macos,omitempty"` CohortMonth string `json:"cohort:month,omitempty"` CohortISOWeek string `json:"cohort:isoweek,omitempty"` diff --git a/pkg/wavebase/wavebase.go b/pkg/wavebase/wavebase.go index 822451ebb3..f24a226745 100644 --- a/pkg/wavebase/wavebase.go +++ b/pkg/wavebase/wavebase.go @@ -346,6 +346,46 @@ func ClientArch() string { return fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) } +func ClientPackageType() string { + if os.Getenv("SNAP") != "" { + return "snap" + } + if os.Getenv("APPIMAGE") != "" { + return "appimage" + } + return "" +} + +var macOSVersionOnce = &sync.Once{} +var cachedMacOSVersion string + +var macOSVersionRegex = regexp.MustCompile(`^(\d+\.\d+(?:\.\d+)?)`) + +func internalMacOSVersion() string { + ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second) + defer cancelFn() + out, err := exec.CommandContext(ctx, "sw_vers", "-productVersion").Output() + if err != nil { + return "" + } + versionStr := strings.TrimSpace(string(out)) + m := macOSVersionRegex.FindStringSubmatch(versionStr) + if len(m) < 2 { + return "" + } + return m[1] +} + +func ClientMacOSVersion() string { + if runtime.GOOS != "darwin" { + return "" + } + macOSVersionOnce.Do(func() { + cachedMacOSVersion = internalMacOSVersion() + }) + return cachedMacOSVersion +} + var releaseRegex = regexp.MustCompile(`^(\d+\.\d+\.\d+)`) var osReleaseOnce = &sync.Once{} var osRelease string