Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Run the `.github/scripts/setup-hooks.sh` script from the root of the repository
These connectors are ready to use out of the box, requiring minimal modifications to get started.

- [apache_hbase](https://github.com/fivetran/fivetran_connector_sdk/tree/main/connectors/apache_hbase) - This is an example of how we can connect and sync data from Apache HBase by using Connector SDK. It uses happybase and thrift libraries to connect to HBase and fetch data.
- [admob](https://github.com/fivetran/fivetran_connector_sdk/tree/main/connectors/admob) - This example shows how to sync advertising data from Google AdMob API including publisher accounts, network reports.The connector supports incremental synchronization using date-based cursors and handles OAuth2 authentication with automatic token refresh.
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after period. The text should read: "...network reports. The connector supports..." instead of "...network reports.The connector supports..."

Suggested change
- [admob](https://github.com/fivetran/fivetran_connector_sdk/tree/main/connectors/admob) - This example shows how to sync advertising data from Google AdMob API including publisher accounts, network reports.The connector supports incremental synchronization using date-based cursors and handles OAuth2 authentication with automatic token refresh.
- [admob](https://github.com/fivetran/fivetran_connector_sdk/tree/main/connectors/admob) - This example shows how to sync advertising data from Google AdMob API including publisher accounts, network reports. The connector supports incremental synchronization using date-based cursors and handles OAuth2 authentication with automatic token refresh.

Copilot uses AI. Check for mistakes.
- [apache_hive/using_pyhive](https://github.com/fivetran/fivetran_connector_sdk/tree/main/connectors/apache_hive/using_pyhive) - This example shows how you can sync data from Apache Hive by using Connector SDK and PyHive.
- [apache_hive/using_sqlalchemy](https://github.com/fivetran/fivetran_connector_sdk/tree/main/connectors/apache_hive/using_sqlalchemy) - This example shows how you can sync data from Apache Hive by using Connector SDK and SQLAlchemy with PyHive.
- [aws_athena/using_boto3](https://github.com/fivetran/fivetran_connector_sdk/tree/main/connectors/aws_athena/using_boto3) - This is an example of how we can sync data from AWS Athena by using Connector SDK using Boto3.
Expand Down
103 changes: 103 additions & 0 deletions connectors/admob/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# AdMob API Connector Example

## Connector overview
This connector syncs advertising data from Google AdMob API including publisher accounts, network reports, and mediation analytics. It fetches ad performance metrics such as estimated earnings, ad requests, impressions, clicks, and detailed breakdowns by app, ad unit, country, platform, and ad type. The connector supports incremental synchronization using date-based cursors and handles OAuth2 authentication with automatic token refresh.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This connector syncs advertising data from Google AdMob API including publisher accounts, network reports, and mediation analytics. It fetches ad performance metrics such as estimated earnings, ad requests, impressions, clicks, and detailed breakdowns by app, ad unit, country, platform, and ad type. The connector supports incremental synchronization using date-based cursors and handles OAuth2 authentication with automatic token refresh.
This connector syncs advertising data from the Google AdMob API, including publisher accounts, network reports, and mediation analytics. It fetches ad performance metrics, including estimated earnings, ad requests, impressions, and clicks, along with detailed breakdowns by app, ad unit, country, platform, and ad type. The connector supports incremental synchronization using date-based cursors and handles OAuth2 authentication with automatic token refresh.


## Requirements
- [Supported Python versions](https://github.com/fivetran/fivetran_connector_sdk/blob/main/README.md#requirements): **3.9-3.13**
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Requirements section specifies Python 3.9-3.13, but the official template states that supported Python versions should link to the SDK's README requirements page without specifying exact versions. According to the template, this should be:

## Requirements
- [Supported Python versions](https://github.com/fivetran/fivetran_connector_sdk/blob/main/README.md#requirements)
- Operating system:
  - Windows: 10 or later (64-bit only)
  - macOS: 13 (Ventura) or later (Apple Silicon [arm64] or Intel [x86_64])
  - Linux: Distributions such as Ubuntu 20.04 or later, Debian 10 or later, or Amazon Linux 2 or later (arm64 or x86_64)

Remove the specific version numbers (3.9-3.13) and let the link define the supported versions.

Copilot generated this review using guidance from repository custom instructions.
- Operating system:
- Windows: 10 or later (64-bit only)
- macOS: 13 (Ventura) or later (Apple Silicon [arm64] or Intel [x86_64])
- Linux: Distributions such as Ubuntu 20.04 or later, Debian 10 or later, or Amazon Linux 2 or later (arm64 or x86_64)

## Getting started
Refer to the [Connector SDK Setup Guide](https://fivetran.com/docs/connectors/connector-sdk/setup-guide) to get started.

## Features
- Syncs publisher account information and advertising performance data from AdMob APIs
- OAuth2 authentication with automatic token refresh handling (refer to `__refresh_oauth_token` function)
- Memory-efficient streaming prevents data accumulation for large report datasets (refer to `get_network_reports` function)
- Incremental synchronization using date-based cursors for efficient data updates (refer to `get_time_range` function)
- Comprehensive error handling with exponential backoff retry logic (refer to `execute_api_request` function)
- Support for multiple publisher accounts and cross-account reporting
- Configurable date ranges for historical data sync and rate limiting management

## Configuration file
```json
{
"client_id": "<YOUR_ADMOB_OAUTH_CLIENT_ID>",
"client_secret": "<YOUR_ADMOB_OAUTH_CLIENT_SECRET>",
"refresh_token": "<YOUR_ADMOB_OAUTH_REFRESH_TOKEN>",
"sync_frequency_hours": "<YOUR_ADMOB_API_SYNC_FREQUENCY_HOURS>",
"initial_sync_days": "<YOUR_ADMOB_API_INITIAL_SYNC_DAYS>",
"max_records_per_page": "<YOUR_ADMOB_API_MAX_RECORDS_PER_PAGE>",
"request_timeout_seconds": "<YOUR_ADMOB_API_REQUEST_TIMEOUT_SECONDS>",
"retry_attempts": "<YOUR_ADMOB_API_RETRY_ATTEMPTS>",
"enable_incremental_sync": "<YOUR_ADMOB_API_ENABLE_INCREMENTAL_SYNC>",
"enable_debug_logging": "<YOUR_ADMOB_API_ENABLE_DEBUG_LOGGING>"
}
```
Comment on lines +25 to +39
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Configuration file section is missing the required statement about not checking configuration.json into version control. According to the template, this section must end with:

Note: Ensure that the `configuration.json` file is not checked into version control to protect sensitive information.

This should be added after the JSON code block and before the "Configuration parameters" section.

Copilot generated this review using guidance from repository custom instructions.

### Configuration parameters
- `client_id` (required): OAuth2 client identifier from Google Cloud Console
- `client_secret` (required): OAuth2 client secret from Google Cloud Console
- `refresh_token` (required): OAuth2 refresh token for automatic access token renewal
- `sync_frequency_hours`: How often to run incremental syncs (default: 4 hours)
- `initial_sync_days`: Number of days of historical data for initial sync (default: 90 days)
- `max_records_per_page`: Maximum records per API request for memory management (default: 100)
- `request_timeout_seconds`: HTTP request timeout in seconds (default: 30)
- `retry_attempts`: Number of retry attempts for failed requests (default: 3)
- `enable_incremental_sync`: Enable date-based incremental synchronization (default: true)
- `enable_debug_logging`: Enable detailed logging for troubleshooting (default: false)
Comment on lines +41 to +51
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configuration parameters section documents parameters that don't exist or aren't used in the connector:

  • sync_frequency_hours - not used in connector.py
  • enable_incremental_sync - not used in connector.py
  • enable_debug_logging - not used in connector.py

These should be removed from both the configuration.json file and this documentation to avoid confusion. Only document the parameters that are actually used by the connector.

Copilot uses AI. Check for mistakes.

## Requirements file
This connector does not require any additional packages beyond those provided by the Fivetran environment.

Note: The `fivetran_connector_sdk:latest` and `requests:latest` packages are pre-installed in the Fivetran environment. To avoid dependency conflicts, do not declare them in your `requirements.txt`.

## Authentication
1. Log in to the [Google Cloud Console](https://console.cloud.google.com/).
2. Create a new project or select an existing project with AdMob API access.
3. Enable the AdMob Reporting API and AdMob Management API for your project.
4. Create OAuth2 credentials (Web application type) in the Credentials section.
5. Make a note of the `client_id` and `client_secret` from your OAuth2 credentials.
6. Generate a refresh token using the OAuth2 flow with the following scopes:
- `https://www.googleapis.com/auth/admob.readonly`
- `https://www.googleapis.com/auth/admob.report`
7. Use the refresh token for long-term authentication without manual intervention.

Note: The connector automatically handles OAuth2 token refresh (1-hour expiration). Credentials are never logged or exposed in plain text.

## Pagination
AdMob API uses report-based data retrieval with streaming response handling (refer to `get_network_reports` function). The connector processes report data as it's received from the API without accumulating large datasets in memory. Generator-based processing prevents memory accumulation for large advertising datasets.
Comment on lines +71 to +72

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Pagination
AdMob API uses report-based data retrieval with streaming response handling (refer to `get_network_reports` function). The connector processes report data as it's received from the API without accumulating large datasets in memory. Generator-based processing prevents memory accumulation for large advertising datasets.
## Pagination
The AdMob API uses report-based data retrieval with streaming response handling (refer to the `get_network_reports` function). The connector processes report data as it's received from the API without accumulating large datasets in memory. Generator-based processing prevents memory accumulation for large advertising datasets.


## Data handling
Advertising data is mapped from AdMob's API format to normalized database columns (refer to the `__map_network_report_data` function). Nested metric objects are flattened, monetary values are converted from micro-units to decimal format, and all timestamps are converted to UTC format for consistency.

Supports date-based incremental synchronization using the `last_sync_time` state parameter (refer to the `get_time_range` function). Initial sync can be configured to fetch historical advertising data up to 365 days. The connector handles multiple publisher accounts automatically.

## Error handling
- 429 Rate Limited: Automatic retry with Retry-After header support (refer to the `__handle_rate_limit` function)
- OAuth token expiration: Automatic token refresh using refresh token (refer to the `__refresh_oauth_token` function)
- Timeout handling with configurable retry attempts (refer to the `__handle_request_error` function)
- Exponential backoff with jitter prevents multiple clients from making requests at the same time
- Parameter validation with descriptive error messages provides clear guidance for fixing OAuth setup issues

## Tables created
| Table | Primary Key | Description |
|-------|-------------|-------------|
| ACCOUNTS | `publisher_id` | AdMob publisher account information and settings |
| NETWORK_REPORTS | `id` | Daily advertising performance metrics and breakdowns |

Column types are automatically inferred by Fivetran. Sample columns include `estimated_earnings`, `ad_requests`, `impressions`, `clicks`, `show_rate`, `match_rate`, `ad_unit_name`, `app_name`, `country`, `platform`, `ad_type`, `date`.

## Additional files
The connector includes several additional files to support functionality, testing, and deployment:

- `requirements.txt` – Python dependency specification for AdMob API integration and connector requirements including faker for mock testing.

- `configuration.json` – Configuration template for API credentials and connector parameters (should be excluded from version control).


Comment on lines +94 to +101
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Additional files" section also mentions configuration.json, but according to the SDK guidelines, this section should only list additional Python files beyond connector.py. Configuration files like configuration.json and requirements.txt are standard files and shouldn't be listed here unless they contain something unusual worth explaining.

If there are no additional Python files (like helper modules), the "Additional files" section should be removed entirely.

Suggested change
## Additional files
The connector includes several additional files to support functionality, testing, and deployment:
- `requirements.txt` – Python dependency specification for AdMob API integration and connector requirements including faker for mock testing.
- `configuration.json` – Configuration template for API credentials and connector parameters (should be excluded from version control).

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +101
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Additional files" section mentions requirements.txt with dependencies including "faker for mock testing", but there is no requirements.txt file in this PR. According to the README.md content (line 54), this connector doesn't require any additional packages.

Either:

  1. Remove the "Additional files" section entirely if there are no additional Python files beyond connector.py, OR
  2. If requirements.txt exists, update the description to match the actual contents

The current description is inconsistent with the "Requirements file" section which states no additional packages are needed.

Suggested change
## Additional files
The connector includes several additional files to support functionality, testing, and deployment:
- `requirements.txt` – Python dependency specification for AdMob API integration and connector requirements including faker for mock testing.
- `configuration.json` – Configuration template for API credentials and connector parameters (should be excluded from version control).

Copilot uses AI. Check for mistakes.
## Additional considerations
The examples provided are intended to help you effectively use Fivetran's Connector SDK. While we've tested the code, Fivetran cannot be held responsible for any unexpected or negative consequences that may arise from using these examples. For inquiries, please reach out to our Support team.
12 changes: 12 additions & 0 deletions connectors/admob/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"client_id": "<YOUR_ADMOB_OAUTH_CLIENT_ID>",
"client_secret": "<YOUR_ADMOB_OAUTH_CLIENT_SECRET>",
"refresh_token": "<YOUR_ADMOB_OAUTH_REFRESH_TOKEN>",
"sync_frequency_hours": "<YOUR_ADMOB_API_SYNC_FREQUENCY_HOURS>",
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sync_frequency_hours field is defined in the configuration but is never used in connector.py. This is an unused configuration parameter that should be removed to avoid confusion. The connector doesn't implement any sync frequency logic - it runs whenever triggered by Fivetran.

Copilot generated this review using guidance from repository custom instructions.
"initial_sync_days": "<YOUR_ADMOB_API_INITIAL_SYNC_DAYS>",
"max_records_per_page": "<YOUR_ADMOB_API_MAX_RECORDS_PER_PAGE>",
"request_timeout_seconds": "<YOUR_ADMOB_API_REQUEST_TIMEOUT_SECONDS>",
"retry_attempts": "<YOUR_ADMOB_API_RETRY_ATTEMPTS>",
"enable_incremental_sync": "<YOUR_ADMOB_API_ENABLE_INCREMENTAL_SYNC>",
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enable_incremental_sync field is defined in the configuration but is never used in connector.py. This is an unused configuration parameter that should be removed to avoid confusion. The connector always performs incremental sync based on the presence of last_sync_time in the state.

Copilot generated this review using guidance from repository custom instructions.
"enable_debug_logging": "<YOUR_ADMOB_API_ENABLE_DEBUG_LOGGING>"
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enable_debug_logging field is defined in the configuration but is never used in connector.py. This is an unused configuration parameter that should be removed to avoid confusion. The connector doesn't implement conditional debug logging based on this parameter.

Copilot generated this review using guidance from repository custom instructions.
}
Loading
Loading