This commit is contained in:
ponzischeme89
2026-08-24 22:56:46 +12:00
parent 4f95767e2f
commit 396d35e2f5
48 changed files with 1541 additions and 672 deletions
+11 -3
View File
@@ -40,6 +40,8 @@ func (s *Server) adminRoutes() http.Handler {
mux.Handle("PUT /admin/api/accounts/{userID}/preferences", s.adminAuth(s.handleAdminPushPreferences))
mux.Handle("DELETE /admin/api/accounts/{userID}/preferences", s.adminAuth(s.handleAdminResetPreferences))
mux.Handle("PUT /admin/api/accounts/{userID}/notifications", s.adminAuth(s.handleAdminNotificationPreferences))
mux.Handle("POST /admin/api/accounts/{userID}/force-update", s.adminAuth(s.handleAdminForceUpdate))
mux.Handle("PUT /admin/api/accounts/{userID}/enabled", s.adminAuth(s.handleAdminUserEnabled))
mux.Handle("GET /admin/api/accounts/{userID}/preferences/history", s.adminAuth(s.handleAdminPreferenceHistory))
mux.Handle("POST /admin/api/accounts/{userID}/preferences/revisions/{revision}/restore",
s.adminAuth(s.handleAdminRestorePreferences))
@@ -857,16 +859,22 @@ func (s *Server) handleAdminJourneys(w http.ResponseWriter, r *http.Request) {
}
stats, statsErr := s.store.JourneyStats(r.Context(), userID, since)
features, featureErr := s.store.UserFeatureStats(r.Context(), userID, since)
featureUsage, usageErr := s.store.JourneyFeatureUsage(r.Context(), userID, since)
featureBreakdown, breakdownErr := s.store.JourneyFeatureBreakdown(r.Context(), userID, since)
paths, pathErr := s.store.UserPaths(r.Context(), userID, since)
actions, actionErr := s.store.JourneyActionStats(r.Context(), userID, since)
if statsErr != nil || featureErr != nil || pathErr != nil || actionErr != nil {
s.loggerFor(r.Context()).Error("journey analytics read failed", "user_id", userID)
if statsErr != nil || featureErr != nil || usageErr != nil || breakdownErr != nil || pathErr != nil || actionErr != nil {
s.loggerFor(r.Context()).Error("journey analytics read failed", "user_id", userID,
"stats_error", statsErr, "feature_error", featureErr,
"feature_usage_error", usageErr, "feature_breakdown_error", breakdownErr,
"paths_error", pathErr, "actions_error", actionErr)
writeError(w, http.StatusInternalServerError, "could not read journeys")
return
}
payload := map[string]any{
"days": days, "retentionDays": int(s.cfg.AnalyticsRetention / (24 * time.Hour)),
"users": users, "stats": stats, "features": features, "paths": paths, "actions": actions,
"users": users, "stats": stats, "features": features, "featureUsage": featureUsage,
"featureBreakdown": featureBreakdown, "paths": paths, "actions": actions,
}
if userID != "" {
events, eventErr := s.store.UserJourneyEvents(r.Context(), userID, since, 1000)