Add LastSeenAt tracking for user activity metrics #824
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.



Summary & Motivation
Add a dedicated
LastSeenAtproperty to the User entity to accurately track when users were last active, replacing the unreliableModifiedAtfield which changes on any user update (role changes, profile edits, etc.). This provides meaningful activity data for the "Active users" dashboard metric, which now correctly counts users with activity within the last 30 days.LastSeenAtnullable property to User entity, updated during login, token refresh, tenant switch, and signup completionLastSeenAtcolumnIDataMigrationto populate existing confirmed users with theirModifiedAtorCreatedAtvaluesGetUserSummaryquery to useLastSeenAtfor calculating active users instead ofModifiedAtLastSeenAtLastSeenAtis preserved during role changes and user restore operationsThis is the first usage of
IDataMigrationin PlatformPlatform. Unlike schema migrations which run during CI/CD before code deployment (requiring old code to work with the new schema), data migrations run when the Worker starts after deployment. Since API and Worker deploy in parallel with independent rolling updates, old API instances may still write data after the data migration completes, so data migrations should be designed to handle this timing window.Checklist