-
Notifications
You must be signed in to change notification settings - Fork 2
Fix/companyhackathons — Improve Hackathon Tracking, RLS Handling & Dashboard Analytics #340
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
…board metrics - Add trackHackathonRegistration method to AnalyticsService to increment company registration counts - Integrate analytics tracking into hackathon registration endpoint with error handling - Fetch hackathons data in CompanyDashboard to calculate accurate approved hackathon count - Calculate total registrations from both events and hackathons instead of relying on stored metric - Update dashboard stats to use computed values for more accurate real-time metrics - Add error handling to prevent analytics failures from blocking registration flow
…le bypass - Use service role client to bypass RLS when updating hackathon registered count - Change `.single()` to `.maybeSingle()` for safer query handling in registration checks - Add comprehensive logging for registration/unregistration operations with count tracking - Implement fallback to direct delete if master registrations service fails - Add `updated_at` timestamp when incrementing/decrementing registered count - Fix registration status check to properly handle missing registrations - Improve error handling to not fail registration if count update fails - Add error code checking (PGRST116) to distinguish "not found" from actual errors - Update registration UI state immediately after successful registration - Ensure `setIsRegistered(false)` is called when user is not authenticated
- Replace user-authenticated Supabase client with service role client to bypass RLS policies for click and view tracking - Add detailed logging for tracking operations including current and new counts - Update `updated_at` timestamp when incrementing click and view counts - Return updated click/view counts from database operations using `.select().single()` - Mark unused `request` parameter as `_request` to follow code conventions - Ensures analytics tracking works reliably regardless of user permissions
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. WalkthroughThe PR enhances hackathon registration and analytics tracking by introducing service-role Supabase clients to bypass RLS for admin updates on registration and click/view counts, adding comprehensive analytics tracking for hackathon registrations, improving the dashboard to display combined event and hackathon statistics, and strengthening registration state management with defensive error handling and detailed logging. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Page as Hackathon Page
participant RegisterAPI as /register Route
participant AnalyticsService
participant MasterRegService as Master Registrations Service
participant Supabase as Supabase (Admin)
Note over Client,Supabase: Registration Flow
Client->>Page: Click Register
Page->>RegisterAPI: POST request
RegisterAPI->>Supabase: Check existing registration (maybeSingle)
alt User Already Registered
RegisterAPI-->>Page: Error Response
else New Registration
RegisterAPI->>MasterRegService: Create registration
MasterRegService->>Supabase: Insert into master_registrations
RegisterAPI->>Supabase: Update hackathon registered count (via admin client)
RegisterAPI->>AnalyticsService: trackHackathonRegistration
AnalyticsService->>Supabase: Fetch hackathon & company
AnalyticsService->>Supabase: Increment company total_registrations
RegisterAPI-->>Page: Success Response
Page->>Page: Set isRegistered to true, Update UI
end
Note over Client,Supabase: Unregistration Flow
Client->>Page: Click Unregister
Page->>RegisterAPI: DELETE request
RegisterAPI->>MasterRegService: Unregister
alt Service Success
MasterRegService->>Supabase: Delete from master_registrations
else Service Fails
RegisterAPI->>Supabase: Fallback direct deletion
end
RegisterAPI->>Supabase: Update hackathon registered count (via admin client)
RegisterAPI-->>Page: Success Response
Page->>Page: Set isRegistered to false, Update UI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 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 |
This PR enhances the reliability of the hackathon registration system, improves analytics tracking, fixes RLS-related issues, and ensures that click/view events are processed securely using the correct client.
✨ What’s Included
1. Analytics: Registration Tracking + Dashboard Improvements
2. Fix: Correct RLS (Row-Level Security) Handling for Registrations
3. Fix: Use Service Role Client for Click & View Tracking
Replaced the regular client with a service role client for:
Guarantees system-level logging bypasses RLS and records analytics reliably.
📁 Code Changes
Changes include:
🧪 Testing
🚀 Impact
This PR improves:
Authored by: @akshay0611
Summary by CodeRabbit
New Features
Bug Fixes