feat(api): implement event-driven audit logging and activity streaming (fixes #699) - #706
Conversation
|
@Diwakar-odds is attempting to deploy a commit to the vishnukothakapu's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 7 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
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 |
|
Hello maintainers, this PR has been submitted for review! Technical AnalysisThis PR implements an Event-Driven Audit Logging system using CQRS-lite principles as requested in Issue #699.
ECSoC26 Label RequestGiven that this PR involves core architectural abstractions (Event Bus), introduces a CQRS-lite paradigm for logging, changes the database schema, and significantly affects backend request flows across multiple critical routes, it firmly satisfies the Level 3 criteria (Core/Architecture/Performance). Therefore, I kindly request the following labels for this PR:
Please review and let me know if any further changes are required. Thank you! |
|
please resolve the merge conflicts @Diwakar-odds . |
Summary
Closes #699
This PR introduces an Event-Driven Audit Logging system using CQRS-lite principles. It adds an
AuditLogPrisma model and a lightweightEventBusto asynchronously track state-mutating actions without blocking the primary request-response cycle.Motivation
LinkID's direct CRUD operations previously lacked a historical audit trail, violating zero-trust architecture principles and limiting our ability to implement webhook triggers or security dashboards. This PR provides a foundational event-streaming abstraction that tracks
Create,Update, andDeleteoperations on key entities.Changes
prisma/schema.prisma: AddedAuditLogmodel to storeactorId,actionType,resourceId,oldState,newState, andipAddress.lib/event-bus.ts: Added apublish()method that executes non-blockingAuditLoginsertions (fire-and-forget promise with catch).app/api/links/route.ts: DispatchesCREATE_LINKandCREATE_GROUPevents.app/api/links/[id]/route.ts: DispatchesUPDATE_LINK/UPDATE_GROUPandDELETE_LINK/DELETE_GROUPevents.app/api/profile/update/route.ts: DispatchesUPDATE_PROFILE_DRAFTevents with state deltas.app/api/analytics/audit-trail/route.ts: Added a paginatedGETendpoint for users to retrieve their account activity history.Acceptance Criteria
AuditLogmodel is successfully migrated to the DB.Impact & Side Effects
Promise.resolve().then()), so there is negligible impact on API response latency. However, database write load will slightly increase per mutation.How to Test
/api/linksor update your profile via/api/profile/update./api/analytics/audit-trail?page=1&limit=10.Quality Checklist
npx tsc --noEmit/ skipped due tonpm installrestrictions)npm run lint/ skipped due tonpm installrestrictions)