-
Notifications
You must be signed in to change notification settings - Fork 12
server: add analytics and reports #432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughNew analytics functionality is introduced for the admin interface, including a router and an HTTP handler to provide user analytics data. The admin route setup is updated to mount the analytics routes. User creation now handles duplicate email errors from the identity provider, and user listing supports a report mode to filter users by creation date with date range validation. Changes
Sequence Diagram(s)sequenceDiagram
participant Admin as Admin Client
participant Router as Analytics Router
participant Handler as details Handler
participant DB as Database
Admin->>Router: GET /analytics/users?from=YYYY-MM-DD&to=YYYY-MM-DD
Router->>Handler: Invoke details(w, r)
Handler->>DB: Query total user count
alt With date range
Handler->>DB: Query user counts grouped by day/month
DB-->>Handler: Aggregated user data
Handler-->>Admin: JSON { total_users, analytics }
else Without date range
Handler-->>Admin: JSON { total_users }
end
sequenceDiagram
participant Admin as Admin Client
participant Router as Admin Router
participant Handler as User Create Handler
participant Kratos as Kratos Admin API
participant DB as Database
Admin->>Router: POST /admin/user/create
Router->>Handler: Invoke user creation logic
Handler->>Kratos: Create identity
alt Status 201 Created
Handler->>DB: Create user in DB
Handler-->>Admin: Success response
else Status 409 Conflict
Handler-->>Admin: Error "email already exists"
else Other error
Handler-->>Admin: Internal server error
end
sequenceDiagram
participant Admin as Admin Client
participant Router as Admin Router
participant Handler as User List Handler
participant DB as Database
Admin->>Router: GET /admin/user/list?is_report=true&from=YYYY-MM-DD&to=YYYY-MM-DD
Router->>Handler: Invoke list logic
Handler->>DB: Query users by created_at in date range
Handler-->>Admin: JSON user list (all results, no paging)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🔇 Additional comments (13)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Summary by CodeRabbit
New Features
Bug Fixes