feat: add geolocation fields to session and implement geo stats endpoint
- Added country, city, countryCode, latitude, and longitude fields to the Session model. - Updated geoip service to fetch and store geolocation data based on user IP. - Created a new admin endpoint to retrieve geolocation statistics, including user counts by country and city. - Enhanced admin page to display geolocation statistics with expandable city details. - Introduced caching for geolocation data to optimize performance.
This commit is contained in:
@@ -2,6 +2,7 @@ import type {
|
||||
AdminBlockUserInput,
|
||||
AdminComplexListItem,
|
||||
AdminCreatePlanInput,
|
||||
AdminGeoStats,
|
||||
AdminGlobalStats,
|
||||
AdminUpdatePlanInput,
|
||||
AdminUser,
|
||||
@@ -77,6 +78,11 @@ export async function getGlobalStats() {
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getGeoStats() {
|
||||
const response = await http.get<AdminGeoStats>('/api/admin/geo-stats');
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getUserSessions(userId: string) {
|
||||
const response = await http.get<AdminUserSession[]>(`/api/admin/users/${userId}/sessions`);
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user