all repos — homestead @ 7cc6162387db91d5be21121d8c6d232f06b513ad

Code for my website

only send successful responses to analytics

Alan Pearce
commit

7cc6162387db91d5be21121d8c6d232f06b513ad

parent

4bbbd38124322ce51bba65298c6143e0e6d1a746

2 files changed, 3 insertions(+), 6 deletions(-)

changed files
M domain/analytics/middleware.godomain/analytics/middleware.go
@@ -32,12 +32,12 @@ countKey, ok := GetCountKey(r)
if !ok { if rw.Status >= 201 { countKey = http.StatusText(rw.Status) - } else { - countKey = r.URL.Path } } - counter.Count(r, countKey) + if rw.Status <= 299 { + counter.Count(r, countKey) + } }) } }
M domain/web/mux.godomain/web/mux.go
@@ -35,7 +35,6 @@ urlPath = "/go" + r.URL.Path
} urlPath, shouldRedirect := website.reader.CanonicalisePath(urlPath) if shouldRedirect { - analytics.WithCountKey(r, "302") http.Redirect(w, r, urlPath, http.StatusFound) return nil
@@ -47,8 +46,6 @@
return ihttp.InternalServerError("Error reading file", err) } if file == nil { - analytics.WithCountKey(r, "404") - return ihttp.NotFound("File not found") } analytics.WithCountKey(r, file.Title)