diff --git a/middlewares/sentry.go b/middlewares/sentry.go index 17f62964..f21b8a64 100644 --- a/middlewares/sentry.go +++ b/middlewares/sentry.go @@ -7,6 +7,7 @@ import ( "github.com/getsentry/sentry-go" sentryhttp "github.com/getsentry/sentry-go/http" + "github.com/hackclub/hackatime/utils" ) // SentryMiddleware is a wrapper around sentryhttp to include user information to traces @@ -30,6 +31,13 @@ func (h *SentryMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) { hub.Scope().SetUser(sentry.User{ID: user.ID}) } + // Parse user agent + userAgent := r.Header.Get("User-Agent") + _, editor, err := utils.ParseUserAgent(userAgent) + if err == nil && editor != "" { + hub.Scope().SetTag("editor", editor) + } + // Attach request body if available if r.Body != nil { if body, err := io.ReadAll(r.Body); err == nil {