Skip to content

Commit ddd9742

Browse files
committed
update activity, see custom counts
1 parent c54f5f9 commit ddd9742

4 files changed

Lines changed: 75 additions & 4 deletions

File tree

frontend/types/gotypes.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,9 @@ declare global {
824824
"autoupdate:enabled"?: boolean;
825825
"loc:countrycode"?: string;
826826
"loc:regioncode"?: string;
827+
"settings:customwidgets"?: number;
828+
"settings:customaipresets"?: number;
829+
"settings:customsettings"?: number;
827830
"activity:activeminutes"?: number;
828831
"activity:fgminutes"?: number;
829832
"activity:openminutes"?: number;
@@ -863,6 +866,9 @@ declare global {
863866
"autoupdate:enabled"?: boolean;
864867
"loc:countrycode"?: string;
865868
"loc:regioncode"?: string;
869+
"settings:customwidgets"?: number;
870+
"settings:customaipresets"?: number;
871+
"settings:customsettings"?: number;
866872
};
867873

868874
// waveobj.Tab

pkg/telemetry/telemetry.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ func updateActivityTEvent(ctx context.Context, tevent *telemetrydata.TEvent) err
136136
eventTs := time.Now()
137137
// compute to hour boundary, and round up to next hour
138138
eventTs = eventTs.Truncate(time.Hour).Add(time.Hour)
139+
140+
fullConfig := wconfig.GetWatcher().GetFullConfig()
141+
customWidgets := fullConfig.CountCustomWidgets()
142+
customAIPresets := fullConfig.CountCustomAIPresets()
143+
customSettings := wconfig.CountCustomSettings()
144+
139145
return wstore.WithTx(ctx, func(tx *wstore.TxWrap) error {
140146
// find event that matches this timestamp with event name "app:activity"
141147
var hasRow bool
@@ -151,6 +157,14 @@ func updateActivityTEvent(ctx context.Context, tevent *telemetrydata.TEvent) err
151157
}
152158
}
153159
mergeActivity(&curActivity, tevent.Props)
160+
161+
if curActivity.UserSet == nil {
162+
curActivity.UserSet = &telemetrydata.TEventUserProps{}
163+
}
164+
curActivity.UserSet.SettingsCustomWidgets = customWidgets
165+
curActivity.UserSet.SettingsCustomAIPresets = customAIPresets
166+
curActivity.UserSet.SettingsCustomSettings = customSettings
167+
154168
if hasRow {
155169
query := `UPDATE db_tevent SET props = ? WHERE uuid = ?`
156170
tx.Exec(query, dbutil.QuickJson(curActivity), uuidStr)

pkg/telemetry/telemetrydata/telemetrydata.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ type TEventUserProps struct {
5151
ClientBuildTime string `json:"client:buildtime,omitempty"`
5252
ClientOSRelease string `json:"client:osrelease,omitempty"`
5353
ClientIsDev bool `json:"client:isdev,omitempty"`
54-
AutoUpdateChannel string `json:"autoupdate:channel,omitempty"`
55-
AutoUpdateEnabled bool `json:"autoupdate:enabled,omitempty"`
56-
LocCountryCode string `json:"loc:countrycode,omitempty"`
57-
LocRegionCode string `json:"loc:regioncode,omitempty"`
54+
55+
AutoUpdateChannel string `json:"autoupdate:channel,omitempty"`
56+
AutoUpdateEnabled bool `json:"autoupdate:enabled,omitempty"`
57+
58+
LocCountryCode string `json:"loc:countrycode,omitempty"`
59+
LocRegionCode string `json:"loc:regioncode,omitempty"`
60+
61+
SettingsCustomWidgets int `json:"settings:customwidgets,omitempty"`
62+
SettingsCustomAIPresets int `json:"settings:customaipresets,omitempty"`
63+
SettingsCustomSettings int `json:"settings:customsettings,omitempty"`
5864
}
5965

6066
type TEventProps struct {

pkg/wconfig/settingsconfig.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,3 +741,48 @@ type TermThemeType struct {
741741
Background string `json:"background"`
742742
Cursor string `json:"cursor"`
743743
}
744+
745+
// CountCustomWidgets returns the number of custom widgets the user has defined.
746+
// Custom widgets are identified as widgets whose ID doesn't start with "defwidget@".
747+
func (fc *FullConfigType) CountCustomWidgets() int {
748+
count := 0
749+
for widgetID := range fc.Widgets {
750+
if !strings.HasPrefix(widgetID, "defwidget@") {
751+
count++
752+
}
753+
}
754+
return count
755+
}
756+
757+
// CountCustomAIPresets returns the number of custom AI presets the user has defined.
758+
// Custom AI presets are identified as presets that start with "ai@" but aren't "ai@global" or "ai@wave".
759+
func (fc *FullConfigType) CountCustomAIPresets() int {
760+
count := 0
761+
for presetID := range fc.Presets {
762+
if strings.HasPrefix(presetID, "ai@") && presetID != "ai@global" && presetID != "ai@wave" {
763+
count++
764+
}
765+
}
766+
return count
767+
}
768+
769+
// CountCustomSettings returns the number of settings the user has customized from the defaults.
770+
// This excludes telemetry:enabled which doesn't count as a customization.
771+
func CountCustomSettings() int {
772+
// Load user settings
773+
userSettings, _ := ReadWaveHomeConfigFile("settings.json")
774+
if userSettings == nil {
775+
return 0
776+
}
777+
778+
// Count all keys except telemetry:enabled
779+
count := 0
780+
for key := range userSettings {
781+
if key == "telemetry:enabled" {
782+
continue
783+
}
784+
count++
785+
}
786+
787+
return count
788+
}

0 commit comments

Comments
 (0)