Skip to content

Commit

Permalink
Fix screen resolution reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaharagon committed Apr 2, 2024
1 parent cb34ed4 commit 572a8b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions umami.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ func (p Umami) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.
// Send visitor information to the Umami Events REST API endpoint
go func() {
payload := map[string]interface{}{
"referrer": r.Referer(),
"url": requestPath,
"website": p.WebsiteUUID,
"url": requestPath,
"website": p.WebsiteUUID,
}

hostname, _, err := net.SplitHostPort(r.Host)
Expand All @@ -87,6 +86,10 @@ func (p Umami) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.

payload["language"] = strings.Split(r.Header.Get("Accept-Language"), ",")[0]

if r.Referer() != "" {
payload["referrer"] = r.Referer()
}

visitorIP, _, err := net.SplitHostPort(r.RemoteAddr)
if err != nil {
visitorIP = r.RemoteAddr
Expand Down Expand Up @@ -115,7 +118,7 @@ func (p Umami) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.
Value: "",
}
}
payload["resolution"] = cookie.Value
payload["screen"] = cookie.Value
}

visitorInfo := map[string]interface{}{
Expand Down

0 comments on commit 572a8b7

Please sign in to comment.