Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Source Google Analytics Data API: Add spec parameter to convert conversions:purchase to float #34907

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 3cc2eafd-84aa-4dca-93af-322d9dfeec1a
dockerImageTag: 2.2.2
dockerImageTag: 2.3.0
dockerRepository: airbyte/source-google-analytics-data-api
documentationUrl: https://docs.airbyte.com/integrations/sources/google-analytics-data-api
githubIssueLabel: source-google-analytics-data-api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ def get_json_schema(self) -> Mapping[str, Any]:
}
)

# change the type of `conversions:purchase` metric from int to float: https://github.com/airbytehq/oncall/issues/4130
if self.config.get("convert_conversions_purchase", False) and "conversions:purchase" in schema["properties"]:
schema["properties"]["conversions:purchase"]["type"] = ["null", "float"]

return schema

def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
Expand Down Expand Up @@ -251,6 +255,10 @@ def parse_response(
metrics = [h.get("name") for h in r.get("metricHeaders", [{}])]
metrics_type_map = {h.get("name"): h.get("type") for h in r.get("metricHeaders", [{}]) if "name" in h}

# change the type of `conversions:purchase` metric from int to float: https://github.com/airbytehq/oncall/issues/4130
if self.config.get("convert_conversions_purchase", False) and "conversions:purchase" in metrics_type_map:
metrics_type_map["conversions:purchase"] = "TYPE_FLOAT"

for row in r.get("rows", []):
record = {
"property_id": self.config["property_id"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,13 @@
"description": "If false, each row with all metrics equal to 0 will not be returned. If true, these rows will be returned if they are not separately removed by a filter. More information is available in <a href=\"https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport#request-body\">the documentation</a>.",
"default": false,
"order": 6
},
"convert_conversions_purchase": {
"type": "boolean",
"title": "Convert `conversions:purchase` Metric to Float",
"description": "Determines whether the `conversions:purchase` metric, typically returned as an integer, should be converted to a float to prevent rounding. This option is useful if you're encountering issues with the API returning float values for the `conversions:purchase` field.",
"default": false,
"order": 7
}
}
},
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/google-analytics-data-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ The Google Analytics connector is subject to Google Analytics Data API quotas. P

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:--------------------------------------------------------------------------------|
| 2.3.0 | 2024-02-06 | [34907](https://github.com/airbytehq/airbyte/pull/34907) | Add new parameter to spec to convert `conversions:purchase` field to float |
| 2.2.2 | 2024-02-01 | [34708](https://github.com/airbytehq/airbyte/pull/34708) | Add rounding integer values that may be float |
| 2.2.1 | 2024-01-18 | [34352](https://github.com/airbytehq/airbyte/pull/34352) | Add incorrect custom reports config handling |
| 2.2.0 | 2024-01-10 | [34176](https://github.com/airbytehq/airbyte/pull/34176) | Add a report option keepEmptyRows |
Expand Down
Loading