-
Notifications
You must be signed in to change notification settings - Fork 2
feat(analytics): Implement session-based view tracking for events #318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add session-based deduplication for event view tracking - Create new `useViewTracking` hook with session management logic - Refactor event view tracking API route to use `AnalyticsService` - Implement client-side session tracking to prevent duplicate views - Add logging and error handling for view tracking process - Improve analytics tracking reliability and performance Enhances event view tracking by preventing multiple view counts from the same user session and providing more robust tracking mechanisms.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughSession-based view deduplication is introduced across analytics tracking. The API route now uses AnalyticsService instead of direct database queries. New view tracking hooks manage per-session deduplication via sessionStorage. The analytics service includes RPC fallback mechanisms and refined error handling to gracefully degrade. Changes
Sequence Diagram(s)sequenceDiagram
participant Page as EventPage
participant Hook as useViewTracking
participant Storage as sessionStorage
participant API as /track-view API
participant Service as AnalyticsService
participant DB as Database
Page->>Hook: Mount with eventSlug
Hook->>Storage: Get/Generate sessionId
Hook->>Storage: Check viewed_events list
alt Already viewed in session
Hook->>Hook: Mark as tracked, exit
else First view this session
Note over Hook: Wait 2 seconds
Hook->>API: POST /api/events/{slug}/track-view<br/>(with sessionId)
API->>Service: trackEventView(slug, sessionId)
Service->>DB: Filter events by approved status
Service->>DB: Call RPC increment_event_views
alt RPC succeeds
Service-->>API: ✓ Success
else RPC fails
Service->>DB: Fallback: Direct update views
Service-->>API: ✓ Success
end
API-->>Hook: 200 OK
Hook->>Storage: Add eventSlug to viewed_events
Hook->>Hook: Set hasTracked = true
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
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 |
useViewTrackinghook with session management logicAnalyticsServiceSummary by CodeRabbit
New Features
Improvements