FEAT: Application Analytics (ProgramApplicationEvent)#3763
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughIntroduces application event tracking and analytics for partner programs, spanning database models for recording application lifecycle stages (visited, started, submitted, approved, rejected), API endpoints for event ingestion and analytics retrieval, client-side tracking components and hooks, comprehensive analytics UI components with filtering and visualization, and updates to existing approval/rejection flows to emit events. Changes
Sequence DiagramsequenceDiagram
participant Client as Client Browser
participant AnalyticsComp as ApplicationAnalytics<br/>Component
participant TrackAPI as POST<br/>/api/track/application
participant Prisma as Prisma<br/>Database
participant RateLimiter as Rate Limiter<br/>& Bot Detection
Client->>AnalyticsComp: Route change (pathname)
AnalyticsComp->>TrackAPI: POST { eventName: "visit", url, referrer }
TrackAPI->>RateLimiter: Check IP rate limit (10/10s)
alt Rate limit exceeded
TrackAPI-->>AnalyticsComp: 429 Error
else Rate limit OK
RateLimiter->>TrackAPI: Allow
TrackAPI->>Prisma: Insert ProgramApplicationEvent<br/>(visited_at=now)
Prisma-->>TrackAPI: Event created
TrackAPI->>TrackAPI: Set HTTP-only cookie<br/>(event ID, program-scoped)
TrackAPI-->>AnalyticsComp: 202 OK
end
sequenceDiagram
participant Dashboard as Analytics<br/>Dashboard
participant AnalyticsAPI as GET<br/>/api/applications/analytics
participant Prisma as Prisma<br/>Query
participant Dashboard2 as Render<br/>UI
Dashboard->>AnalyticsAPI: Fetch with groupBy=timeseries<br/>(start, end, timezone)
AnalyticsAPI->>Prisma: Query ProgramApplicationEvent<br/>aggregate counts by time bucket
Prisma-->>AnalyticsAPI: Aggregated rows per bucket
AnalyticsAPI->>AnalyticsAPI: Fill missing buckets<br/>with zero values
AnalyticsAPI-->>Dashboard: JSON [ { bucket, count } ]
Dashboard->>Dashboard2: Render TimeSeriesChart<br/>with data points
Dashboard->>AnalyticsAPI: Fetch with groupBy=partner
AnalyticsAPI->>Prisma: GROUP BY partnerId,<br/>count stages
Prisma-->>AnalyticsAPI: Partner aggregate rows
AnalyticsAPI->>AnalyticsAPI: Join partner metadata
AnalyticsAPI-->>Dashboard: JSON [ { partner, stages } ]
Dashboard->>Dashboard2: Render ApplicationsPartnersTable
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 👉 Get your free trial and get 200 agent minutes per Slack user (a $50 value). 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 |
…schema with username validation
…alytics components. Update schema and API integration for improved event handling.
…ctoring event submission logic. Update event handling to include partner ID and submitted timestamp, and improve URL slug identification for program tracking.
|
@coderabbitai final review, any breaking changes, security issues? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me pull the key files to do a thorough security and breaking-change analysis. 🏁 Script executed: Length of output: 14067 🏁 Script executed: Length of output: 20450 🏁 Script executed: Length of output: 6506
🔐 Security Issues1. Missing
|
| Issue | Severity | Type |
|---|---|---|
Missing sameSite/path on cookie |
Medium | Security |
| Unauthenticated fake event injection | Medium | Security |
APPLICATION_EVENT_STAGES missing "rejected" |
Medium | Breaking/Correctness |
@@unique migration risk on existing data |
Medium | Breaking |
| Wildcard CORS | Low | Security |
via username enumeration |
Low | Security |
Silent catch {} blocks |
Low | Observability |
groupId absent from sharedFilterSchema |
Low | Correctness |
identityProgramSlug typo (should be identify...) |
Trivial | Code quality |
Summary by CodeRabbit
New Features
Refactor