Conversation
Adds a lastLoginAt field to the User model and updates it on login. The workspace members page now displays the last active date for each user. The zod schema and relevant UI components were updated to support this new field.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis pull request introduces last login tracking by adding a Changes
Sequence DiagramsequenceDiagram
actor User
participant Client as Web Client
participant Auth as Auth Handler
participant DB as Database
participant UI as Dashboard UI
User->>Client: Sign in
Client->>Auth: Submit credentials
Auth->>DB: Verify user
DB-->>Auth: User authenticated
rect rgba(76, 175, 80, 0.2)
Auth->>+DB: Background: Update lastLoginAt
DB-->>-Auth: Update queued (waitUntil)
end
Auth-->>Client: Return session
Client->>DB: Fetch members list
DB-->>Client: Return members with lastLoginAt
rect rgba(33, 150, 243, 0.2)
Client->>UI: Render members table
UI->>UI: Format lastLoginAt or show "-"
UI-->>User: Display "Last active" column
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/members/page-client.tsx (1)
166-188: Consider internationalization for date formatting.The "Last active" column implementation correctly handles edge cases (invited users and missing data). However, the date formatting uses a hardcoded
"en-US"locale.🌍 Optional: Support international date formats
Consider using the user's browser locale or a workspace-level locale preference:
<span className="text-sm text-neutral-500"> - {new Date(user.lastLoginAt).toLocaleDateString("en-US", { + {new Date(user.lastLoginAt).toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric", })} </span>Passing
undefinedas the locale uses the user's browser locale automatically.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/members/page-client.tsxapps/web/lib/auth/options.tsapps/web/lib/zod/schemas/workspaces.tspackages/prisma/schema/schema.prisma
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-15T01:05:43.266Z
Learnt from: steven-tey
Repo: dubinc/dub PR: 2958
File: apps/web/app/app.dub.co/(dashboard)/[slug]/settings/members/page-client.tsx:432-457
Timestamp: 2025-10-15T01:05:43.266Z
Learning: In apps/web/app/app.dub.co/(dashboard)/[slug]/settings/members/page-client.tsx, defer refactoring the custom MenuItem component (lines 432-457) to use the shared dub/ui MenuItem component to a future PR, as requested by steven-tey.
Applied to files:
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/members/page-client.tsx
🧬 Code graph analysis (1)
apps/web/lib/auth/options.ts (1)
packages/prisma/index.ts (1)
prisma(3-9)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (4)
packages/prisma/schema/schema.prisma (1)
24-24: LGTM!The nullable
lastLoginAtfield is correctly positioned and typed. The nullable constraint is appropriate since existing users won't have login data until their next authentication.apps/web/lib/zod/schemas/workspaces.ts (1)
216-216: LGTM!The schema validation for
lastLoginAtcorrectly usesz.date().nullish()which is the proper Zod 4 syntax for nullable/optional date fields.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/members/page-client.tsx (1)
140-140: LGTM!The column width adjustment accommodates the new "Last active" column appropriately.
apps/web/lib/auth/options.ts (1)
578-585: LGTM!The background update to
lastLoginAtis well-implemented:
- Uses
waitUntilto avoid blocking the sign-in response- Correctly placed in the
events.signInhandler to capture all authentication flows- Captures the timestamp at sign-in time with
new Date()
Adds a lastLoginAt field to the User model and updates it on login. The workspace members page now displays the last active date for each user. The zod schema and relevant UI components were updated to support this new field.
-Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.