Skip to content

Commit 33f0b4f

Browse files
committed
telemetry for customaimodes and secrets
1 parent 31ece9f commit 33f0b4f

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

cmd/server/main-server.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/wavetermdev/waveterm/pkg/panichandler"
2323
"github.com/wavetermdev/waveterm/pkg/remote/conncontroller"
2424
"github.com/wavetermdev/waveterm/pkg/remote/fileshare/wshfs"
25+
"github.com/wavetermdev/waveterm/pkg/secretstore"
2526
"github.com/wavetermdev/waveterm/pkg/service"
2627
"github.com/wavetermdev/waveterm/pkg/telemetry"
2728
"github.com/wavetermdev/waveterm/pkg/telemetry/telemetrydata"
@@ -224,18 +225,25 @@ func updateTelemetryCounts(lastCounts telemetrydata.TEventProps) telemetrydata.T
224225
customWidgets := fullConfig.CountCustomWidgets()
225226
customAIPresets := fullConfig.CountCustomAIPresets()
226227
customSettings := wconfig.CountCustomSettings()
228+
customAIModes := fullConfig.CountCustomAIModes()
227229

228230
props.UserSet = &telemetrydata.TEventUserProps{
229231
SettingsCustomWidgets: customWidgets,
230232
SettingsCustomAIPresets: customAIPresets,
231233
SettingsCustomSettings: customSettings,
234+
SettingsCustomAIModes: customAIModes,
235+
}
236+
237+
secretsCount, err := secretstore.CountSecrets()
238+
if err == nil {
239+
props.UserSet.SettingsSecretsCount = secretsCount
232240
}
233241

234242
if utilfn.CompareAsMarshaledJson(props, lastCounts) {
235243
return lastCounts
236244
}
237245
tevent := telemetrydata.MakeTEvent("app:counts", props)
238-
err := telemetry.RecordTEvent(ctx, tevent)
246+
err = telemetry.RecordTEvent(ctx, tevent)
239247
if err != nil {
240248
log.Printf("error recording counts tevent: %v\n", err)
241249
}

pkg/secretstore/secretstore.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,24 @@ func GetSecretNames() ([]string, error) {
279279
return names, nil
280280
}
281281

282+
func CountSecrets() (int, error) {
283+
lock.Lock()
284+
defer lock.Unlock()
285+
286+
if !initialized {
287+
return 0, fmt.Errorf("secret store not initialized")
288+
}
289+
290+
count := 0
291+
for name := range secrets {
292+
if name == WriteTsKey {
293+
continue
294+
}
295+
count++
296+
}
297+
return count, nil
298+
}
299+
282300
func GetLinuxStorageBackend() (string, error) {
283301
if runtime.GOOS != "linux" {
284302
return "", nil

pkg/telemetry/telemetrydata/telemetrydata.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ type TEventUserProps struct {
8484
SettingsCustomWidgets int `json:"settings:customwidgets,omitempty"`
8585
SettingsCustomAIPresets int `json:"settings:customaipresets,omitempty"`
8686
SettingsCustomSettings int `json:"settings:customsettings,omitempty"`
87+
SettingsCustomAIModes int `json:"settings:customaimodes,omitempty"`
88+
SettingsSecretsCount int `json:"settings:secretscount,omitempty"`
8789
}
8890

8991
type TEventProps struct {

pkg/wconfig/settingsconfig.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,18 @@ func (fc *FullConfigType) CountCustomAIPresets() int {
887887
return count
888888
}
889889

890+
// CountCustomAIModes returns the number of custom AI modes the user has defined.
891+
// Custom AI modes are identified as modes that don't start with "waveai@".
892+
func (fc *FullConfigType) CountCustomAIModes() int {
893+
count := 0
894+
for modeID := range fc.WaveAIModes {
895+
if !strings.HasPrefix(modeID, "waveai@") {
896+
count++
897+
}
898+
}
899+
return count
900+
}
901+
890902
// CountCustomSettings returns the number of settings in the user's settings file.
891903
// This excludes telemetry:enabled and autoupdate:channel which don't count as customizations.
892904
func CountCustomSettings() int {

0 commit comments

Comments
 (0)