mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 05:19:04 +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) {
|
func (aH *APIHandler) user(w http.ResponseWriter, r *http.Request) {
|
||||||
email := r.URL.Query().Get("email")
|
|
||||||
|
|
||||||
var err error
|
user, err := parseUser(r)
|
||||||
if len(email) == 0 {
|
if err != nil {
|
||||||
err = fmt.Errorf("Email param is missing")
|
|
||||||
}
|
|
||||||
if aH.handleError(w, err, http.StatusBadRequest) {
|
if aH.handleError(w, err, http.StatusBadRequest) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(*aH.pc).Enqueue(posthog.Identify{
|
(*aH.pc).Enqueue(posthog.Identify{
|
||||||
DistinctId: aH.distinctId,
|
DistinctId: aH.distinctId,
|
||||||
Properties: posthog.NewProperties().
|
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"},
|
"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) {
|
func parseGetTopEndpointsRequest(r *http.Request) (*model.GetTopEndpointsParams, error) {
|
||||||
startTime, err := parseTime("start", r)
|
startTime, err := parseTime("start", r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -5,6 +5,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
}
|
||||||
|
|
||||||
type InstantQueryMetricsParams struct {
|
type InstantQueryMetricsParams struct {
|
||||||
Time time.Time
|
Time time.Time
|
||||||
Query string
|
Query string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user