mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-23 02:51:26 +01:00
telemetry updates
This commit is contained in:
parent
33af77b88c
commit
8e1f34b93b
@ -180,6 +180,7 @@ func HandleLogActiveState(w http.ResponseWriter, r *http.Request) {
|
||||
if activeState.Open {
|
||||
activity.OpenMinutes = 1
|
||||
}
|
||||
activity.NumConns = remote.NumRemotes()
|
||||
err = sstore.UpdateCurrentActivity(r.Context(), activity)
|
||||
if err != nil {
|
||||
WriteJsonError(w, fmt.Errorf("error updating activity: %w", err))
|
||||
|
@ -126,6 +126,7 @@ func init() {
|
||||
registerCmdFn("session:archive", SessionArchiveCommand)
|
||||
registerCmdFn("session:showall", SessionShowAllCommand)
|
||||
registerCmdFn("session:show", SessionShowCommand)
|
||||
registerCmdFn("session:openshared", SessionOpenSharedCommand)
|
||||
|
||||
registerCmdFn("screen", ScreenCommand)
|
||||
registerCmdFn("screen:archive", ScreenArchiveCommand)
|
||||
@ -1497,6 +1498,15 @@ func validateRemoteColor(color string, typeStr string) error {
|
||||
return fmt.Errorf("invalid %s, valid colors are: %s", typeStr, formatStrs(RemoteColorNames, "or", false))
|
||||
}
|
||||
|
||||
func SessionOpenSharedCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||
activity := sstore.ActivityUpdate{ClickShared: 1}
|
||||
err := sstore.UpdateCurrentActivity(ctx, activity)
|
||||
if err != nil {
|
||||
log.Printf("error updating click-shared: %v\n", err)
|
||||
}
|
||||
return nil, fmt.Errorf("shared sessions are not available in this version of prompt (stay tuned)")
|
||||
}
|
||||
|
||||
func SessionOpenCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
|
||||
activate := resolveBool(pk.Kwargs["activate"], true)
|
||||
newName := pk.Kwargs["name"]
|
||||
@ -1803,6 +1813,12 @@ func HistoryCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ssto
|
||||
return nil, err
|
||||
}
|
||||
show := !resolveBool(pk.Kwargs["noshow"], false)
|
||||
if show {
|
||||
err = sstore.UpdateCurrentActivity(ctx, sstore.ActivityUpdate{HistoryView: 1})
|
||||
if err != nil {
|
||||
log.Printf("error updating current activity (history): %v\n", err)
|
||||
}
|
||||
}
|
||||
update := sstore.ModelUpdate{}
|
||||
update.History = &sstore.HistoryInfoType{
|
||||
HistoryType: htype,
|
||||
@ -1917,6 +1933,10 @@ func BookmarksShowCommand(ctx context.Context, pk *scpacket.FeCommandPacketType)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot retrieve bookmarks: %v", err)
|
||||
}
|
||||
err = sstore.UpdateCurrentActivity(ctx, sstore.ActivityUpdate{BookmarksView: 1})
|
||||
if err != nil {
|
||||
log.Printf("error updating current activity (bookmarks): %v\n", err)
|
||||
}
|
||||
update := sstore.ModelUpdate{
|
||||
BookmarksView: true,
|
||||
Bookmarks: bms,
|
||||
|
@ -349,6 +349,12 @@ func isPartialUUID(s string) bool {
|
||||
return partialUUIDRe.MatchString(s)
|
||||
}
|
||||
|
||||
func NumRemotes() int {
|
||||
GlobalStore.Lock.Lock()
|
||||
defer GlobalStore.Lock.Unlock()
|
||||
return len(GlobalStore.Map)
|
||||
}
|
||||
|
||||
func GetRemoteByArg(arg string) *MShellProc {
|
||||
GlobalStore.Lock.Lock()
|
||||
defer GlobalStore.Lock.Unlock()
|
||||
|
@ -1932,6 +1932,12 @@ func UpdateCurrentActivity(ctx context.Context, update ActivityUpdate) error {
|
||||
tdata.FgMinutes += update.FgMinutes
|
||||
tdata.ActiveMinutes += update.ActiveMinutes
|
||||
tdata.OpenMinutes += update.OpenMinutes
|
||||
tdata.ClickShared += update.ClickShared
|
||||
tdata.HistoryView += update.HistoryView
|
||||
tdata.BookmarksView += update.BookmarksView
|
||||
if update.NumConns > 0 {
|
||||
tdata.NumConns = update.NumConns
|
||||
}
|
||||
query = `UPDATE activity
|
||||
SET tdata = ?,
|
||||
clientversion = ?
|
||||
|
@ -118,6 +118,10 @@ type ActivityUpdate struct {
|
||||
ActiveMinutes int
|
||||
OpenMinutes int
|
||||
NumCommands int
|
||||
ClickShared int
|
||||
HistoryView int
|
||||
BookmarksView int
|
||||
NumConns int
|
||||
}
|
||||
|
||||
type ActivityType struct {
|
||||
@ -135,6 +139,10 @@ type TelemetryData struct {
|
||||
ActiveMinutes int `json:"activeminutes"`
|
||||
FgMinutes int `json:"fgminutes"`
|
||||
OpenMinutes int `json:"openminutes"`
|
||||
ClickShared int `json:"clickshared,omitempty"`
|
||||
HistoryView int `json:"historyview,omitempty"`
|
||||
BookmarksView int `json:"bookmarksview,omitempty"`
|
||||
NumConns int `json:"numconns"`
|
||||
}
|
||||
|
||||
func (tdata TelemetryData) Value() (driver.Value, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user