Conversation
Introduces a new `login_history` table to track successful OAuth token issuances, enabling detailed user activity monitoring and application usage analytics. Key changes: - Added `login_history` table to track user, application, session, IP, and user agent for every login event. - Implemented `recordLogin` service to capture login events during the OAuth flow. - Denormalized `last_login_at` on the `user` table for efficient "last seen" lookups in admin listings. - Added new admin API endpoints for retrieving application activity statistics, login series data, and paginated user login history. - Enhanced frontend with new UI components: `Sparkline` for activity trends, `AppIconStack` for application visualization, and a refactored `DataTable` with improved sorting and density controls. - Updated admin views (Dashboard, Applications, Users, Sessions) to display real-time activity, login history, and enriched user/session metadata.
…apping Update the `/active-users` endpoint to return a `count` property instead of `online` to align with standard naming conventions. Refactor the application statistics response to map sparkline data points to a simple array of numbers, improving the API's data structure for client-side consumption.
Convert Date objects to ISO strings and cast to timestamptz in SQL queries to ensure consistent date handling and prevent potential type mismatches during database execution.
Add support for displaying the most recent IP address and user agent information in the Application Detail and Dashboard views. This includes updating i18n translations, extending TypeScript interfaces, and refactoring the admin API to fetch and return login metadata using `selectDistinctOn`.
…tory Implement a `databaseHooks` listener on session creation to automatically populate the login history table. This ensures that all direct session creations (including admin logins and social provider callbacks) are captured with their associated IP address and user agent. The hook is designed to be non-blocking and "fire-and-forget" to ensure that any failures in recording the history do not prevent the user from successfully creating a session.
Implement advanced features for the `DataTable` component, including built-in search functionality, server-driven pagination, and improved responsive column handling. - Add `searchable` and `pagination` props to `DataTable` component. - Implement debounced search in `DashboardView` to optimize API calls. - Update `sessions` and `users` admin routes to support filtering and searching via database queries. - Refactor responsive column logic to use explicit Tailwind classes, ensuring compatibility with JIT compilation. - Add internationalization support for new table controls. - Update user and session APIs to return enriched data including `lastLoginAt` and application details.
Refactor the `AppIconStack` component to use a Teleport-based popover with manual positioning and global event listeners to prevent overflow and clipping issues. Enhance `DataTable` by adding a `clickableRows` prop for better user interaction. - Implement `Teleport` and `fixed` positioning for `AppIconStack` popovers. - Add `clickableRows` prop to `DataTable` to toggle `cursor-pointer`. - Update user administration to display human-readable subscription plan names instead of UUIDs. - Add left-join to `subscriptionPlans` in the user routes API to enrich application data. - Update `UserDetailView` and `UsersView` to utilize new plan name fields and row click navigation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces new functionality for tracking and displaying user login activity, as well as improvements to session and application data handling. The most significant changes include the introduction of a new
login_historytable in the database, new API endpoints and types for fetching login and activity statistics, and a new UI component for displaying application icons associated with users. Additionally, the sessions API now supports searching, and user and application data structures have been updated to include relevant login information.Database and Backend Enhancements:
login_historytable to track user logins, including fields foruser_id,application_id,session_id, timestamp, IP address, and user agent. Also added alast_login_atcolumn to theusertable, and created indexes and a foreign key for efficient queries.API Additions and Improvements:
frontend/src/api/stats.tsfor retrieving active user counts, login series data, and application activity statistics, supporting both real and mock data.getUserLoginHistoryfunction tofrontend/src/api/applications.tsto fetch paginated login history for a specific user and application.listSessionsAPI infrontend/src/api/sessions.tsto support searching sessions by user name, email, or IP address.Frontend/UI Components:
AppIconStack.vuecomponent to display application icons associated with a user, with support for popover display and overflow handling.Data Structure Updates:
lastLoginAtandsubscriptionPlanNamefields for richer user detail responses.LoginHistoryResponse.