-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
bugdependenciesPull requests that update a dependency filePull requests that update a dependency filepremium
Description
Problem
The analytics controller is currently failing with a 404 error because it's using the deprecated Google Analytics Reporting API v4, which was sunset on July 1, 2024.
Error Details:
Error getting analytics GaxiosError: <!DOCTYPE html>
<title>Error 404 (Not Found)!!1</title>
The requested URL /v4/reports:batchGet was not found on this server.
Impact
- Analytics functionality is completely broken
- Unable to retrieve user analytics data
- Application features dependent on analytics are non-functional
Root Cause
Universal Analytics has been deprecated and replaced with Google Analytics 4 (GA4). The current implementation uses:
google.analyticsreporting('v4')
- DEPRECATED- Endpoint:
https://analyticsreporting.googleapis.com/v4/reports:batchGet
- NO LONGER EXISTS
Solution
Migrate to the GA4 Data API using the @google-analytics/data
package.
Tasks
Phase 1: Setup
- Install
@google-analytics/data
npm package - Remove deprecated
googleapis
analyticsreporting dependencies - Update service account permissions for GA4 properties
- Add GA4 property IDs to configuration
Phase 2: Code Migration
- Replace
analyticsreporting.reports.batchGet()
withBetaAnalyticsDataClient.runReport()
- Update dimension mappings (UA → GA4):
-
ga:totalEvents
→eventCount
-
ga:eventLabel
→eventName
or custom dimension -
ga:eventAction
→eventName
or custom dimension -
ga:clientId
→ custom dimension or user identifier
-
- Update filter structure for GA4 format
- Modify response handling to match new API format
Phase 3: Configuration
- Set up GA4 custom dimensions if needed for:
- Client ID tracking
- Event labels
- Event actions
- Update environment variables with GA4 property IDs
- Test service account access to GA4 properties
Phase 4: Testing
- Test
batchGet
function with sample data - Test
userActivity
function - Verify data accuracy compared to GA4 interface
- Test error handling and edge cases
Dependencies
- New:
@google-analytics/data
- Remove:
googleapis
analyticsreporting usage
Notes
- GA4 has different data models and limitations compared to Universal Analytics
- Client ID handling may require custom dimensions in GA4
- Some metrics/dimensions may not have direct equivalents
- Testing should verify data consistency
Acceptance Criteria
- Analytics endpoints return data without errors
- Data retrieved matches expectations from GA4 interface
- All existing functionality is preserved
- Error handling is robust
- No deprecated API calls remain
Priority
High - Critical functionality is broken
Metadata
Metadata
Assignees
Labels
bugdependenciesPull requests that update a dependency filePull requests that update a dependency filepremium