backend requirements onthe xustomer app

This commit is contained in:
2026-09-07 10:55:11 +05:30
parent 35675d8a9b
commit 1b2690b21a
56 changed files with 13342 additions and 1071 deletions

View File

@@ -19,21 +19,33 @@ func ZapLogger() fiber.Handler {
method := c.Method()
path := c.Path()
// Client identity and the request id travel with every log line.
//
// X-Client / X-Platform are what the customer app sends
// ("doormile-cx/1.0.0+12", "android"), and they are the only way to
// answer "is this failing on one build or everywhere" — which is the
// first question asked when an app-side report arrives. The request id
// is what correlates a customer saying "it failed" with the line that
// recorded the real error behind the customer-safe message.
//
// Recorded as empty rather than omitted when absent, so a caller that
// sends nothing is visibly a caller that sends nothing.
fields := []interface{}{
"method", method,
"path", path,
"status", status,
"latency", latency,
"client", c.Get("X-Client"),
"platform", c.Get("X-Platform"),
}
if id, ok := c.Locals("requestid").(string); ok && id != "" {
fields = append(fields, "requestid", id)
}
if err != nil {
utils.Error("API request error",
"method", method,
"path", path,
"status", status,
"latency", latency,
"error", err.Error(),
)
utils.Error("API request error", append(fields, "error", err.Error())...)
} else {
utils.Info("API request success",
"method", method,
"path", path,
"status", status,
"latency", latency,
)
utils.Info("API request success", fields...)
}
return err