Skip to content

Google data analytics#210

Merged
PatrickCmd merged 5 commits intomainfrom
google_data_analytics
Apr 19, 2026
Merged

Google data analytics#210
PatrickCmd merged 5 commits intomainfrom
google_data_analytics

Conversation

@PatrickCmd
Copy link
Copy Markdown
Contributor

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

  • Added a new GoogleAnalyticsClient in app/integrations/google_analytics.py to securely connect to the Google Analytics Data API using impersonated service account credentials. Provides an async run_report method for data retrieval.
  • Introduced a service layer (GoogleAnalyticsService) and dependency injection for it, along with related dependency changes in app/deps.py. [1] [2] [3] [4]

Admin API Endpoints

  • Added new admin routes under /api/admin/google-analytics in app/routers/google_analytics.py for listing properties, fetching property overviews, and refreshing cached data. These endpoints are protected and require configuration to be enabled. [1] [2] [3]
  • Defined Pydantic schemas for API responses in app/schemas/google_analytics.py, including traffic time series, top pages, platforms, geography, and events breakdowns.

Configuration and Settings

  • Extended Settings in app/core/config.py to 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

  • Added a pluggable cache backend interface (CacheBackend) in app/services/cache/__init__.py with a default in-memory implementation (InMemoryTTLCache in app/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

  • Included a README (app/services/cache/README.md) explaining the cache backend design, default behavior, and steps for migrating to a shared Redis backend if needed.

PatrickCmd and others added 5 commits April 19, 2026 14:08
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.
@PatrickCmd PatrickCmd merged commit 3112103 into main Apr 19, 2026
1 check passed
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.

1 participant