Feature/sc 75221/modificar integracao do google analytics#15
Conversation
…lities - Added ReportsTable, RealtimeReportsTable, and MetadataTable classes for querying GA4 data. - Updated GoogleAnalyticsHandler to support both Admin and Data APIs. - Enhanced README with detailed usage instructions for new tables. - Added tests for Data API queries and metadata retrieval. - Updated requirements to include google-analytics-data package.
- Implement methods to store and load service account credentials securely. - Update README to include security information regarding credential storage. - Introduce connection arguments for property ID and credentials in a new file. - Add tests to verify the functionality of credential storage methods.
…prove query handling in ConversionEventsTable
…ge examples - Introduced connection_args.py to define default connection parameters (URL, headers, timeout). - Updated __init__.py to include connection arguments in the exported module. - Enhanced README.md with detailed usage examples for different connection modes and authentication. - Modified multi_format_table.py to utilize connection-level URL and timeout settings.
…r for limiting response size
…imensions and metrics, enhancing performance and reducing API calls. Update ReportsTable and RealtimeReportsTable to utilize cached metadata for improved metric identification and column name mapping.
…s into view queries to reduce post-processing. Enhance metric value conversion to float for accurate sorting in ReportsTable and RealtimeReportsTable.
…ue pairs in filters, improving flexibility in query construction. Update dimension and metric filter handling for better compatibility and add detailed docstrings for clarity.
…arsing, improving text handling by stripping HTML tags and decoding entities.
…tent cleaning. Add _try_parse_date function for improved date handling.
…hods. Add support for OAuth2 and Service Account authentication, including detailed setup instructions and connection parameters. Update requirements to include necessary libraries.
…als initialization, as they are embedded in the refresh token.
…ement exponential backoff for retries on rate limit errors.
There was a problem hiding this comment.
Pull Request Overview
This pull request modifies the Google Analytics handler integration to support both the Admin API and the new Data API (GA4), adds OAuth2 authentication support, implements query optimization for view-based queries, and introduces a new multi-format API handler for fetching data from various web sources.
Key Changes:
- Extended Google Analytics handler with Data API support (reports, realtime reports, metadata tables)
- Added OAuth2 authentication alongside existing service account authentication
- Implemented query optimization to push filters, ordering, and limits down to handlers
- Created new multi-format API handler for XML, JSON, and CSV data sources
- Fixed DuckDB column aliasing issue in SQLAlchemy renderer
- Improved Gmail handler rate limiting with exponential backoff
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| mindsdb/utilities/render/sqlalchemy_render.py | Prevents redundant column aliasing that causes DuckDB errors |
| mindsdb/interfaces/database/projects.py | Adds query optimization for views with deep copying and clause merging |
| mindsdb/api/executor/planner/query_planner.py | Implements nested query optimization to push clauses to handlers |
| mindsdb/integrations/handlers/google_analytics_handler/* | Adds GA4 Data API support, OAuth2 authentication, and credentials storage |
| mindsdb/integrations/handlers/multi_format_api_handler/* | New handler for fetching multi-format data from web APIs |
| mindsdb/integrations/handlers/gmail_handler/gmail_handler.py | Improves rate limit handling with exponential backoff |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return info | ||
| elif 'credentials_json' in self.connection_args: | ||
| info = self.connection_args['credentials_json'] | ||
| info = json.loads(self.connection_args['credentials_json']) |
There was a problem hiding this comment.
The credentials_json is already expected to be a dictionary according to the connection_args definition (type: ARG_TYPE.DICT), but here it's being parsed as JSON string. This will fail if a dictionary is provided. Either update the connection_args type to STR or remove the json.loads() call and handle it as a dict directly.
| info = json.loads(self.connection_args['credentials_json']) | |
| info = self.connection_args['credentials_json'] |
…analytics_data_tables.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.