mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add usercount, session count and complete rate
This commit is contained in:
1 parent
add6bfd100
commit
cc95bb195b
7 files changed
+131
-5
No files matched your search
@@ -0,0 +1,59 @@
|
||||
# Analytics
|
||||
|
||||
## Information provided
|
||||
|
||||
### 1. **Dashboard Overview**:
|
||||
|
||||
- **Total Users**: Display the total number of registered users.
|
||||
- **Active Users**: Count of users who've been active in the past day, week, or month.
|
||||
- **Completed Quests**: Total quests or challenges completed by all users.
|
||||
- **Average Time Usage**: Average time a user spends on the platform or on challenges.
|
||||
|
||||
### 2. **User Analytics**:
|
||||
|
||||
- **User Growth**: A graph showing user registrations over time (daily, weekly, monthly).
|
||||
- **Retention Rate**: Percentage of users who return after their first visit.
|
||||
- **User Segmentation**: Group users based on criteria like their progress level, frequency of usage, or other custom metrics.
|
||||
|
||||
### 3. **Quest/Challenge Analytics**:
|
||||
|
||||
- **Quest Popularity**: Rank quests by the number of completions or engagements.
|
||||
- **Average Completion Time**: The average time taken by users to complete each quest.
|
||||
- **Drop-Off Points**: Identify quests where users abandon or fail frequently.
|
||||
|
||||
### 4. **Error Analysis**:
|
||||
|
||||
- **Common Errors**: List frequently mistyped or erroneous commands.
|
||||
- **Quest-specific Errors**: Identify challenges where users make the most mistakes.
|
||||
|
||||
### 5. **Feedback & Survey Results**:
|
||||
|
||||
- **Feedback Overview**: Display recent feedback or suggestions.
|
||||
- **Survey Analysis**: If you've integrated a survey, show aggregated results or key insights.
|
||||
|
||||
### 6. **System Health & Usage**:
|
||||
|
||||
- **Server Load**: Monitor server performance metrics like CPU usage, memory usage, etc.
|
||||
- **Error Logs**: View any system errors, glitches, or issues.
|
||||
|
||||
### 7. **User Details**:
|
||||
|
||||
- **Search & View**: Ability to search for specific users and view their profile, progress, and activity logs.
|
||||
- **User Behavior**: For selected users, see a detailed path of their activity, including the quests they've engaged with, time spent, errors made, etc.
|
||||
|
||||
### 8. **Notifications & Alerts**:
|
||||
|
||||
- **System Alerts**: Notifications about server downtimes, high error rates, or other critical issues.
|
||||
- **User Activity Alerts**: Set alerts for specific user activities, e.g., when a user completes all challenges.
|
||||
|
||||
### 9. **Engagement Metrics**:
|
||||
|
||||
- **Daily Active Users**: Users who engage with the platform daily.
|
||||
- **Top Users**: Identify power users or those with high engagement rates.
|
||||
|
||||
### 10. **Export & Reports**:
|
||||
|
||||
- **Data Export**: Option to export user data, analytics, or other metrics.
|
||||
- **Generate Reports**: Create detailed reports based on selected metrics, useful for team meetings or strategy planning.
|
||||
|
||||
When designing this admin dashboard, focus on clarity and ease of use. Utilize visual aids like graphs, charts, and heatmaps to make data interpretation straightforward. Since your backend is built with NodeJS and ExpressJS and you use MongoDB for data storage, you can utilize various NPM packages to aid in data visualization and dashboard creation. Ensure the dashboard is secure and accessible only to authorized personnel.
|
||||
@@ -0,0 +1,15 @@
|
||||
import { userCount } from '../models/users.js'
|
||||
import { sessionCount, sessionCompleted } from '../models/quests.js'
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export async function homeController(req, res) {
|
||||
const payload = {
|
||||
title: 'Linux Odyssey Admin',
|
||||
userCount: await userCount(),
|
||||
sessionCount: await sessionCount(),
|
||||
sessionCompleted: await sessionCompleted(),
|
||||
}
|
||||
payload.completedRate =
|
||||
Math.round((payload.sessionCompleted / payload.sessionCount) * 10000) / 100
|
||||
res.render('home', payload)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import connectDB from '@linux-odyssey/models'
|
||||
import express from 'express'
|
||||
import { engine } from 'express-handlebars'
|
||||
import config from './config.js'
|
||||
import { homeController } from './controllers/index.js'
|
||||
|
||||
async function main() {
|
||||
await connectDB(config.db)
|
||||
@@ -12,9 +13,7 @@ async function main() {
|
||||
app.set('view engine', 'handlebars')
|
||||
app.set('views', './views')
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.render('home', { title: 'Linux Odyssey Admin' })
|
||||
})
|
||||
app.get('/', homeController)
|
||||
|
||||
app.listen(3001, () => {
|
||||
console.log('Server started on http://localhost:3001')
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Session } from '@linux-odyssey/models'
|
||||
|
||||
export function sessionCount() {
|
||||
return Session.find().count()
|
||||
}
|
||||
|
||||
export function sessionCompleted() {
|
||||
return Session.find({ status: 'finished' }).count()
|
||||
}
|
||||
|
||||
export function averageTimeUsage() {
|
||||
return Session.aggregate([
|
||||
{
|
||||
$group: {
|
||||
_id: '$quest',
|
||||
average: {
|
||||
$avg: {
|
||||
$subtract: ['$finishedAt', '$createdAt'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
])
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { User } from '@linux-odyssey/models'
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export function userCount() {
|
||||
return User.find().count()
|
||||
}
|
||||
@@ -1,2 +1,23 @@
|
||||
<h1>Welcome to {{title}}</h1>
|
||||
<p>This is the content of the homepage.</p>
|
||||
<p>This is the content of the homepage.</p>
|
||||
<div>
|
||||
<h2>Users</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Registered Users</th>
|
||||
<td>{{userCount}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Session Count</th>
|
||||
<td>{{sessionCount}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Completed Session</th>
|
||||
<td>{{sessionCompleted}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Completed Rate</th>
|
||||
<td>{{completedRate}}%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -16,7 +16,9 @@ export async function removeExpired() {
|
||||
sessions.map(async (session) => {
|
||||
console.log('Expiring session: ', session._id, session.containerId)
|
||||
await deleteContainer(session.containerId)
|
||||
session.status = 'inactive'
|
||||
if (session.status === 'active') {
|
||||
session.status = 'inactive'
|
||||
}
|
||||
session.containerId = null
|
||||
await session.save()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user