🌷 the cutsie hackatime helper

feat: mess with wakatime heartbeat sending to be more consistent

dunkirk.sh 0d8e88d9 45f6aaec

verified
Changed files
+15 -9
handler
wakatime
+10 -8
handler/main.go
···
"os"
"runtime"
"strings"
+
"time"
"github.com/spf13/cobra"
"github.com/taciturnaxolotl/akami/styles"
···
c.Println("\nSending one quick heartbeat to make sure everything is ship shape and then you should be good to go!")
err = client.SendHeartbeat(wakatime.Heartbeat{
-
Entity: "/home/kierank/Projects/akami/wakatime/main.go",
-
Type: "file",
-
Project: "akami",
-
Language: "Go",
Branch: "main",
Category: "coding",
+
CursorPos: 1,
+
Entity: user_dir + "/akami.txt",
+
Type: "file",
IsWrite: true,
-
LineCount: 197,
-
ProjectRootCount: 5,
-
Dependencies: []string{"bytes", "encoding/base64", "encoding/json", "net/http", "runtime", "time"},
-
Time: 1750643351,
+
Language: "Go",
+
LineNo: 1,
+
LineCount: 4,
+
Project: "example",
+
ProjectRootCount: 3,
+
Time: float64(time.Now().Unix()),
})
if err != nil {
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
···
Category string `json:"category,omitempty"`
// LineCount is the optional number of lines in the file
LineCount int `json:"lines,omitempty"`
+
// LineNo is the current line number
+
LineNo int `json:"lineno,omitempty"`
+
// CursorPos is the current column of text the cursor is on
+
CursorPos int `json:"cursorpos,omitempty"`
// UserAgent is the optional user agent string
UserAgent string `json:"user_agent,omitempty"`
// EntityType is the optional entity type (usually redundant with Type)
···
return fmt.Errorf("%w: %v", ErrMarshalingHeartbeat, err)
}
-
req, err := http.NewRequest("POST", c.APIURL+"/users/current/heartbeats", bytes.NewBuffer(data))
+
req, err := http.NewRequest("GET", fmt.Sprintf("%s/users/current/statusbar/today", c.APIURL), bytes.NewBuffer(data))
if err != nil {
return fmt.Errorf("%w: %v", ErrCreatingRequest, err)
}