mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-27 15:32:21 +02:00
Use queryReason parameter to properly record query interactions
This commit is contained in:
parent
cd69973939
commit
690b969fe3
@ -96,12 +96,16 @@ func (s *Server) apiQueryHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
ctx := r.Context()
|
ctx := r.Context()
|
||||||
userId := getRequiredQueryParam(r, "user_id")
|
userId := getRequiredQueryParam(r, "user_id")
|
||||||
deviceId := getRequiredQueryParam(r, "device_id")
|
deviceId := getRequiredQueryParam(r, "device_id")
|
||||||
|
queryReason := getOptionalQueryParam(r, "queryReason", s.isTestEnvironment)
|
||||||
|
isBackgroundQuery := queryReason == "preload" || queryReason == "newclient"
|
||||||
|
|
||||||
// TODO: add these to the context in a middleware
|
// TODO: add these to the context in a middleware
|
||||||
version := getHishtoryVersion(r)
|
version := getHishtoryVersion(r)
|
||||||
remoteIPAddr := getRemoteAddr(r)
|
remoteIPAddr := getRemoteAddr(r)
|
||||||
|
|
||||||
s.handleNonCriticalError(s.updateUsageData(r.Context(), version, remoteIPAddr, userId, deviceId, 0, true))
|
if !isBackgroundQuery {
|
||||||
|
s.handleNonCriticalError(s.updateUsageData(r.Context(), version, remoteIPAddr, userId, deviceId, 0, true))
|
||||||
|
}
|
||||||
|
|
||||||
// Delete any entries that match a pending deletion request
|
// Delete any entries that match a pending deletion request
|
||||||
deletionRequests, err := s.db.DeletionRequestsForUserAndDevice(r.Context(), userId, deviceId)
|
deletionRequests, err := s.db.DeletionRequestsForUserAndDevice(r.Context(), userId, deviceId)
|
||||||
@ -136,7 +140,7 @@ func (s *Server) apiQueryHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.statsd != nil {
|
if s.statsd != nil {
|
||||||
s.statsd.Incr("hishtory.query", []string{}, 1.0)
|
s.statsd.Incr("hishtory.query", []string{"query_reason:" + queryReason}, 1.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user