Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

chore: changes in user api (#430)

Ankit Nayan5b691d26e478
diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go
index aaeab745a3..e9f6e84423 100644
--- a/pkg/query-service/app/http_handler.go
+++ b/pkg/query-service/app/http_handler.go
@@ -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),
})
}
diff --git a/pkg/query-service/app/parser.go b/pkg/query-service/app/parser.go
index 9db12840f6..99ce336f5f 100644
--- a/pkg/query-service/app/parser.go
+++ b/pkg/query-service/app/parser.go
@@ -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 {
diff --git a/pkg/query-service/model/queryParams.go b/pkg/query-service/model/queryParams.go
index a082277b51..bacb8b328a 100644
--- a/pkg/query-service/model/queryParams.go
+++ b/pkg/query-service/model/queryParams.go
@@ -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