mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 07:08:58 +08:00
chore: changes in user api (#430)
This commit is contained in:
parent
6b6070fd45
commit
5b691d26e4
@ -627,20 +627,18 @@ func (aH *APIHandler) queryMetrics(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func (aH *APIHandler) user(w http.ResponseWriter, r *http.Request) {
|
||||
email := r.URL.Query().Get("email")
|
||||
|
||||
var err error
|
||||
if len(email) == 0 {
|
||||
err = fmt.Errorf("Email param is missing")
|
||||
}
|
||||
if aH.handleError(w, err, http.StatusBadRequest) {
|
||||
return
|
||||
user, err := parseUser(r)
|
||||
if err != nil {
|
||||
if aH.handleError(w, err, http.StatusBadRequest) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
(*aH.pc).Enqueue(posthog.Identify{
|
||||
DistinctId: aH.distinctId,
|
||||
Properties: posthog.NewProperties().
|
||||
Set("email", email),
|
||||
Set("email", user.Email).Set("name", user.Name),
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,20 @@ var allowedAggregations = map[string][]string{
|
||||
"duration": {"avg", "p50", "p95", "p99"},
|
||||
}
|
||||
|
||||
func parseUser(r *http.Request) (*model.User, error) {
|
||||
|
||||
var user model.User
|
||||
err := json.NewDecoder(r.Body).Decode(&user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(user.Email) == 0 {
|
||||
return nil, fmt.Errorf("email field not found")
|
||||
}
|
||||
|
||||
return &user, nil
|
||||
}
|
||||
|
||||
func parseGetTopEndpointsRequest(r *http.Request) (*model.GetTopEndpointsParams, error) {
|
||||
startTime, err := parseTime("start", r)
|
||||
if err != nil {
|
||||
|
@ -5,6 +5,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
type InstantQueryMetricsParams struct {
|
||||
Time time.Time
|
||||
Query string
|
||||
|
Loading…
x
Reference in New Issue
Block a user