Skip to content

Commit

Permalink
✨ Source Google Analytics v4: Add End date option (#34353)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem1205 committed Jan 19, 2024
1 parent 168440f commit 3242d6d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: eff3616a-f9c3-11eb-9a03-0242ac130003
dockerImageTag: 0.2.2
dockerImageTag: 0.2.3
dockerRepository: airbyte/source-google-analytics-v4
documentationUrl: https://docs.airbyte.com/integrations/sources/google-analytics-v4
githubIssueLabel: source-google-analytics-v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class GoogleAnalyticsV4Stream(HttpStream, ABC):
def __init__(self, config: MutableMapping):
super().__init__(authenticator=config["authenticator"])
self.start_date = config["start_date"]
self.end_date = config.get("end_date")
self.window_in_days: int = config.get("window_in_days", 1)
self.view_id = config["view_id"]
self.metrics = config["metrics"]
Expand Down Expand Up @@ -255,7 +256,7 @@ def stream_slices(self, stream_state: Mapping[str, Any] = None, **kwargs: Any) -
...]
"""

end_date = pendulum.now().date()
end_date = (pendulum.parse(self.end_date) if self.end_date else pendulum.now()).date()
start_date = pendulum.parse(self.start_date).date()
if stream_state:
prev_end_date = pendulum.parse(stream_state.get(self.cursor_field)).date()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,18 @@
"title": "View ID",
"description": "The ID for the Google Analytics View you want to fetch data from. This can be found from the <a href=\"https://ga-dev-tools.appspot.com/account-explorer/\">Google Analytics Account Explorer</a>."
},
"custom_reports": {
"end_date": {
"order": 3,
"type": "string",
"title": "Replication End Date",
"description": "The date in the format YYYY-MM-DD. Any data after this date will not be replicated.",
"examples": ["2020-06-01"],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$|^$|[\\s\\S]+$",
"format": "date"
},
"custom_reports": {
"order": 4,
"type": "string",
"title": "Custom Reports",
"description": "A JSON array describing the custom reports you want to sync from Google Analytics. See <a href=\"https://docs.airbyte.com/integrations/sources/google-analytics-v4#data-processing-latency\">the docs</a> for more information about the exact format you can use to fill out this field."
},
Expand All @@ -103,7 +112,7 @@
"description": "The time increment used by the connector when requesting data from the Google Analytics API. More information is available in the <a href=\"https://docs.airbyte.com/integrations/sources/google-analytics-v4/#sampling-in-reports\">the docs</a>. The bigger this value is, the faster the sync will be, but the more likely that sampling will be applied to your data, potentially causing inaccuracies in the returned results. We recommend setting this to 1 unless you have a hard requirement to make the sync faster at the expense of accuracy. The minimum allowed value for this field is 1, and the maximum is 364. ",
"examples": [30, 60, 90, 120, 200, 364],
"default": 1,
"order": 4
"order": 5
}
}
},
Expand Down
7 changes: 4 additions & 3 deletions docs/integrations/sources/google-analytics-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ You need to add the service account email address on the account level, not the
The Google Analytics (Universal Analytics) source connector can sync the following tables:

| Stream name | Schema |
| :----------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|:-------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| website_overview | `{"ga_date":"2021-02-11","ga_users":1,"ga_newUsers":0,"ga_sessions":9,"ga_sessionsPerUser":9.0,"ga_avgSessionDuration":28.77777777777778,"ga_pageviews":63,"ga_pageviewsPerSession":7.0,"ga_avgTimeOnPage":4.685185185185185,"ga_bounceRate":0.0,"ga_exitRate":14.285714285714285,"view_id":"211669975"}` |
| traffic_sources | `{"ga_date":"2021-02-11","ga_source":"(direct)","ga_medium":"(none)","ga_socialNetwork":"(not set)","ga_users":1,"ga_newUsers":0,"ga_sessions":9,"ga_sessionsPerUser":9.0,"ga_avgSessionDuration":28.77777777777778,"ga_pageviews":63,"ga_pageviewsPerSession":7.0,"ga_avgTimeOnPage":4.685185185185185,"ga_bounceRate":0.0,"ga_exitRate":14.285714285714285,"view_id":"211669975"}` |
| pages | `{"ga_date":"2021-02-11","ga_hostname":"mydemo.com","ga_pagePath":"/home5","ga_pageviews":63,"ga_uniquePageviews":9,"ga_avgTimeOnPage":4.685185185185185,"ga_entrances":9,"ga_entranceRate":14.285714285714285,"ga_bounceRate":0.0,"ga_exits":9,"ga_exitRate":14.285714285714285,"view_id":"211669975"}` |
Expand Down Expand Up @@ -282,8 +282,9 @@ The Google Analytics connector should not run into the "requests per 100 seconds
## Changelog

| Version | Date | Pull Request | Subject |
| :------ | :--------- | :------------------------------------------------------- | :------------------------------------------------------------------------------------------- |
| 0.2.2 | 2023-10-19 | [31599](https://github.com/airbytehq/airbyte/pull/31599) | Base image migration: remove Dockerfile and use the python-connector-base image |
|:--------|:-----------|:---------------------------------------------------------|:---------------------------------------------------------------------------------------------|
| 0.2.3 | 2024-01-18 | [34353](https://github.com/airbytehq/airbyte/pull/34353) | Add End date option |
| 0.2.2 | 2023-10-19 | [31599](https://github.com/airbytehq/airbyte/pull/31599) | Base image migration: remove Dockerfile and use the python-connector-base image |
| 0.2.1 | 2023-07-11 | [28149](https://github.com/airbytehq/airbyte/pull/28149) | Specify date format to support datepicker in UI |
| 0.2.0 | 2023-06-26 | [27738](https://github.com/airbytehq/airbyte/pull/27738) | License Update: Elv2 |
| 0.1.36 | 2023-04-13 | [22223](https://github.com/airbytehq/airbyte/pull/22223) | Fix custom report with Segments dimensions |
Expand Down

0 comments on commit 3242d6d

Please sign in to comment.