only send successful responses to analytics
2 files changed, 3 insertions(+), 6 deletions(-)
changed files
M domain/analytics/middleware.go → domain/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.go → domain/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)