message: feat: added status code of api calls
diff: @@ -159,18 +159,36 @@ func loggingMiddleware(next http.Handler) http.Handler {
  })
  }
  +type loggingResponseWriter struct {
  + http.ResponseWriter
  + statusCode int
  +}
  +
  +func NewLoggingResponseWriter(w http.ResponseWriter) *loggingResponseWriter {
  + // WriteHeader(int) is not called if our response implicitly returns 200 OK, so
  + // we default to that status code.
  + return &loggingResponseWriter{w, http.StatusOK}
  +}
  +
  +func (lrw *loggingResponseWriter) WriteHeader(code int) {
  + lrw.statusCode = code
  + lrw.ResponseWriter.WriteHeader(code)
  +}
  +
  func (s *Server) analyticsMiddleware(next http.Handler) http.Handler {
  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  route := mux.CurrentRoute(r)
  path, _ := route.GetPathTemplate()
  - data := map[string]interface{}{"path": path}
  + lrw := NewLoggingResponseWriter(w)
  + next.ServeHTTP(lrw, r)
  +
  + data := map[string]interface{}{"path": path, "statusCode": lrw.statusCode}
  if _, ok := telemetry.IgnoredPaths()[path]; !ok {
  telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_PATH, data)
  }
  - next.ServeHTTP(w, r)
  })
  }
  