feat: decode user_id

This commit is contained in:
liuyuanchuang
2026-01-27 22:26:25 +08:00
parent 9e01ee79f1
commit be3e82fc2e
3 changed files with 294 additions and 1 deletions

View File

@@ -37,6 +37,14 @@ func (h *AnalyticsHandler) TrackEvent(c *gin.Context) {
return
}
userID, err := common.GetUserIDFromContext(c)
if err != nil {
log.Error(c.Request.Context(), "get user id failed", "error", err)
c.JSON(http.StatusOK, common.ErrorResponse(c, common.CodeUnauthorized, "unauthorized"))
return
}
req.UserID = userID
if err := h.analyticsService.TrackEvent(c.Request.Context(), &req); err != nil {
log.Error(c.Request.Context(), "track event failed", "error", err)
c.JSON(http.StatusOK, common.ErrorResponse(c, common.CodeSystemError, "failed to track event"))