Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Nov 14, 2025

  • Add trackEventRegistration method to AnalyticsService for event registration tracking
  • Implement fallback mechanism for incrementing company analytics when RPC fails
  • Update master registrations service to simplify database query and reduce schema complexity
  • Add error handling for analytics tracking in event registration route
  • Improve robustness of company analytics data insertion and update process Ensures comprehensive tracking of event registrations and provides more flexible analytics data management.

Summary by CodeRabbit

  • Improvements
    • Added analytics tracking for event registrations to monitor user engagement metrics
    • Enhanced analytics service with automatic fallback mechanisms to ensure data collection reliability
    • Optimized registration query performance

- Add trackEventRegistration method to AnalyticsService for event registration tracking
- Implement fallback mechanism for incrementing company analytics when RPC fails
- Update master registrations service to simplify database query and reduce schema complexity
- Add error handling for analytics tracking in event registration route
- Improve robustness of company analytics data insertion and update process
Ensures comprehensive tracking of event registrations and provides more flexible analytics data management.
@vercel
Copy link

vercel bot commented Nov 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
codeunia Ready Ready Preview Comment Nov 14, 2025 6:48am

@codeunia-dev codeunia-dev merged commit 23a6679 into main Nov 14, 2025
3 of 4 checks passed
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request adds event registration analytics tracking by introducing a new trackEventRegistration method to AnalyticsService that captures registration events for companies. The AnalyticsService also gains RPC-first with fallback logic for analytics increments. Query simplifications are made to master-registrations by removing profile joins.

Changes

Cohort / File(s) Summary
Event Registration Analytics Integration
app/api/events/[slug]/register/route.ts, lib/services/analytics-service.ts
Adds trackEventRegistration(eventId) method that fetches events and increments company analytics on successful registration. Route handler dynamically imports and calls the new method with try/catch wrapping. Enhanced incrementCompanyAnalytics implements RPC-first pattern with manual upsert fallback for robustness.
Database Query Optimization
lib/services/master-registrations.ts
Removes profile inner joins from register and getUserRegistrations methods, replacing them with plain select('*') to simplify queries and reduce schema-related issues.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Route as Register Route
    participant Reg as MasterRegistrations
    participant Analytics as AnalyticsService
    participant RPC as Analytics RPC
    participant DB as Database

    Client->>Route: POST register event
    activate Route
    Route->>Reg: register(...)
    activate Reg
    Reg->>DB: insert registration
    Reg-->>Route: registration data
    deactivate Reg
    
    rect rgba(76, 175, 80, 0.2)
    Note over Route,Analytics: Analytics Tracking (async)
    Route->>Analytics: trackEventRegistration(eventId)
    activate Analytics
    Analytics->>DB: fetch event by id
    activate DB
    DB-->>Analytics: event + company_id
    deactivate DB
    
    Analytics->>RPC: incrementCompanyAnalytics(RPC call)
    activate RPC
    RPC-->>Analytics: success or failure
    deactivate RPC
    
    alt RPC Success
        Analytics-->>Route: tracking complete
    else RPC Fails
        Analytics->>DB: fetch today's company_analytics
        activate DB
        DB-->>Analytics: existing record or null
        deactivate DB
        alt Record Exists
            Analytics->>DB: update field value
        else Record Not Found
            Analytics->>DB: insert new record
        end
        Analytics-->>Route: tracking complete (fallback)
    end
    deactivate Analytics
    end
    
    Route-->>Client: registration response
    deactivate Route
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus on the RPC-first with manual upsert fallback logic in incrementCompanyAnalytics—ensure error handling preserves registration flow and doesn't create race conditions between RPC and fallback paths
  • Verify that trackEventRegistration correctly handles edge cases (missing event, missing company_id) and that async failures don't leak errors back to the registration response
  • Confirm that removing profile joins from master-registrations methods doesn't break downstream code expecting profile fields

Possibly related PRs

Poem

🐰 A hop through the data we go, tracking each sign-up below,
With RPC first, then fallback's might, we log the registrations right,
No profiles joined, the queries sing clean—analytics now intervene! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/session-based-view-tracking

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83780df and 927f93d.

📒 Files selected for processing (3)
  • app/api/events/[slug]/register/route.ts (1 hunks)
  • lib/services/analytics-service.ts (2 hunks)
  • lib/services/master-registrations.ts (3 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants