🌷 the cutsie hackatime helper

feat: mess with wakatime heartbeat sending to be more consistent

dunkirk.sh 0d8e88d9 45f6aaec

verified
+15 -9
+10 -8
handler/main.go
··· 6 6 "os" 7 7 "runtime" 8 8 "strings" 9 + "time" 9 10 10 11 "github.com/spf13/cobra" 11 12 "github.com/taciturnaxolotl/akami/styles" ··· 105 106 c.Println("\nSending one quick heartbeat to make sure everything is ship shape and then you should be good to go!") 106 107 107 108 err = client.SendHeartbeat(wakatime.Heartbeat{ 108 - Entity: "/home/kierank/Projects/akami/wakatime/main.go", 109 - Type: "file", 110 - Project: "akami", 111 - Language: "Go", 112 109 Branch: "main", 113 110 Category: "coding", 111 + CursorPos: 1, 112 + Entity: user_dir + "/akami.txt", 113 + Type: "file", 114 114 IsWrite: true, 115 - LineCount: 197, 116 - ProjectRootCount: 5, 117 - Dependencies: []string{"bytes", "encoding/base64", "encoding/json", "net/http", "runtime", "time"}, 118 - Time: 1750643351, 115 + Language: "Go", 116 + LineNo: 1, 117 + LineCount: 4, 118 + Project: "example", 119 + ProjectRootCount: 3, 120 + Time: float64(time.Now().Unix()), 119 121 }) 120 122 if err != nil { 121 123 return errors.New("oh dear; looks like something went wrong when sending that heartbeat. " + styles.Bad.Render("Full error: \""+strings.TrimSpace(err.Error())+"\""))
+5 -1
wakatime/main.go
··· 87 87 Category string `json:"category,omitempty"` 88 88 // LineCount is the optional number of lines in the file 89 89 LineCount int `json:"lines,omitempty"` 90 + // LineNo is the current line number 91 + LineNo int `json:"lineno,omitempty"` 92 + // CursorPos is the current column of text the cursor is on 93 + CursorPos int `json:"cursorpos,omitempty"` 90 94 // UserAgent is the optional user agent string 91 95 UserAgent string `json:"user_agent,omitempty"` 92 96 // EntityType is the optional entity type (usually redundant with Type) ··· 127 131 return fmt.Errorf("%w: %v", ErrMarshalingHeartbeat, err) 128 132 } 129 133 130 - req, err := http.NewRequest("POST", c.APIURL+"/users/current/heartbeats", bytes.NewBuffer(data)) 134 + req, err := http.NewRequest("GET", fmt.Sprintf("%s/users/current/statusbar/today", c.APIURL), bytes.NewBuffer(data)) 131 135 if err != nil { 132 136 return fmt.Errorf("%w: %v", ErrCreatingRequest, err) 133 137 }