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:
@@ -93,3 +93,24 @@ export type AdminBlockUserInput = z.infer<typeof adminBlockUserSchema>
|
||||
export type AdminGlobalStats = z.infer<typeof adminGlobalStatsSchema>
|
||||
export type AdminPaymentStatus = z.infer<typeof adminPaymentStatusSchema>
|
||||
export type AdminUserSession = z.infer<typeof adminUserSessionSchema>
|
||||
|
||||
export const adminGeoCitySchema = z.object({
|
||||
city: z.string(),
|
||||
userCount: z.number().int().nonnegative(),
|
||||
})
|
||||
|
||||
export const adminGeoCountrySchema = z.object({
|
||||
country: z.string(),
|
||||
countryCode: z.string(),
|
||||
totalUsers: z.number().int().nonnegative(),
|
||||
cities: z.array(adminGeoCitySchema),
|
||||
})
|
||||
|
||||
export const adminGeoStatsSchema = z.object({
|
||||
countries: z.array(adminGeoCountrySchema),
|
||||
totalUniqueCountries: z.number().int().nonnegative(),
|
||||
})
|
||||
|
||||
export type AdminGeoCity = z.infer<typeof adminGeoCitySchema>
|
||||
export type AdminGeoCountry = z.infer<typeof adminGeoCountrySchema>
|
||||
export type AdminGeoStats = z.infer<typeof adminGeoStatsSchema>
|
||||
|
||||
Reference in New Issue
Block a user