Google data analytics#210
Merged
PatrickCmd merged 5 commits intomainfrom Apr 19, 2026
Merged
Conversation
Design doc for surfacing GA4 analytics for Sunflower (506611499) and Sunbird Speech (448469065) properties on a new /admin/google-analytics page, with impersonated service account auth and in-memory caching. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…quirements - Added a new script `setup_ga_access.sh` to configure Google Analytics Data API access for the admin dashboard, including service account creation and IAM policy bindings. - Updated `requirements.txt` to include the `google-analytics-data` package version 0.18.0 or higher.
- Introduced a new Google Analytics page with routing. - Added components for displaying traffic charts, top pages, platform breakdown, geographic data, and events. - Integrated Google Analytics data fetching using custom hooks. - Updated layout to include a link to the new Google Analytics section in the admin navigation. - Enhanced the main application with new analytics features for better insights.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new Google Analytics Data API integration for admin analytics, including configuration, API endpoints, service layer, and a pluggable cache backend. The changes enable secure, cached retrieval of Google Analytics data for admin users, with support for impersonated service accounts and future extensibility for cache backends.
Google Analytics Integration
GoogleAnalyticsClientinapp/integrations/google_analytics.pyto securely connect to the Google Analytics Data API using impersonated service account credentials. Provides an asyncrun_reportmethod for data retrieval.GoogleAnalyticsService) and dependency injection for it, along with related dependency changes inapp/deps.py. [1] [2] [3] [4]Admin API Endpoints
/api/admin/google-analyticsinapp/routers/google_analytics.pyfor listing properties, fetching property overviews, and refreshing cached data. These endpoints are protected and require configuration to be enabled. [1] [2] [3]app/schemas/google_analytics.py, including traffic time series, top pages, platforms, geography, and events breakdowns.Configuration and Settings
Settingsinapp/core/config.pyto support Google Analytics integration, including impersonation target, properties, cache TTL, request timeout, and cache backend selection. Added parsing logic for property configuration and a flag to check if GA is enabled. [1] [2]Caching Layer
CacheBackend) inapp/services/cache/__init__.pywith a default in-memory implementation (InMemoryTTLCacheinapp/services/cache/in_memory.py). This cache is used to store Google Analytics report payloads and can be swapped for a shared backend (e.g., Upstash Redis) as documented. [1] [2] [3]Documentation
app/services/cache/README.md) explaining the cache backend design, default behavior, and steps for migrating to a shared Redis backend if needed.