feat: add persisted page insight platform
This commit is contained in:
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"git.amiirkhl.ir/starcoach-hackathon/zarinpal-analytics-backend/internal/analytics"
|
||||
"git.amiirkhl.ir/starcoach-hackathon/zarinpal-analytics-backend/internal/identity"
|
||||
"git.amiirkhl.ir/starcoach-hackathon/zarinpal-analytics-backend/internal/insight"
|
||||
)
|
||||
|
||||
const maxExportBytes = 50 << 20
|
||||
@@ -37,6 +38,7 @@ type Server struct {
|
||||
identity *identity.Service
|
||||
analytics *analytics.Service
|
||||
growth growthReportService
|
||||
insights insightService
|
||||
logger *slog.Logger
|
||||
frontendOrigin string
|
||||
cookieSecure bool
|
||||
@@ -45,6 +47,11 @@ type Server struct {
|
||||
growthSSEPollInterval time.Duration
|
||||
}
|
||||
|
||||
func (s *Server) WithInsights(service *insight.Service) *Server {
|
||||
s.insights = service
|
||||
return s
|
||||
}
|
||||
|
||||
type sessionKey struct{}
|
||||
type tokenKey struct{}
|
||||
|
||||
@@ -74,6 +81,10 @@ func (s *Server) Handler() http.Handler {
|
||||
mux.Handle("GET /api/v1/analytics/growth-reports/latest", s.authenticate(http.HandlerFunc(s.latestGrowthReport)))
|
||||
mux.Handle("GET /api/v1/analytics/growth-reports/{reportId}", s.authenticate(http.HandlerFunc(s.getGrowthReport)))
|
||||
mux.Handle("GET /api/v1/analytics/growth-reports/{reportId}/events", s.authenticate(http.HandlerFunc(s.growthReportEvents)))
|
||||
mux.Handle("GET /api/v1/analytics/ai-insights/{module}", s.authenticate(http.HandlerFunc(s.latestAIInsight)))
|
||||
mux.Handle("POST /api/v1/analytics/ai-insights/{module}/refreshes", s.authenticate(s.csrf(http.HandlerFunc(s.refreshAIInsight))))
|
||||
mux.Handle("GET /api/v1/analytics/ai-insight-refreshes/{jobId}", s.authenticate(http.HandlerFunc(s.getAIInsightJob)))
|
||||
mux.Handle("GET /api/v1/analytics/ai-insight-refreshes/{jobId}/events", s.authenticate(http.HandlerFunc(s.aiInsightEvents)))
|
||||
return s.boundary(mux)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user