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

🎉 Google Analytics connector is failing #3648

Merged
merged 21 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
Empty file modified airbyte-integrations/bases/base-python/base_python/__init__.py
100644 → 100755
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from pathlib import Path
from typing import List

from airbyte_protocol import ConfiguredAirbyteCatalog
from base_singer import AirbyteLogger, BaseSingerSource
from jsonschema.validators import Draft4Validator
from tap_google_analytics import GAClient
Expand All @@ -42,6 +43,7 @@ class GoogleAnalyticsSingerSource(BaseSingerSource):
tap_cmd = "tap-google-analytics"
tap_name = "Google Analytics API"
api_error = Exception
reports_to_read = None

# can be overridden to change an input config
def configure(self, raw_config: json, temp_dir: str) -> json:
Expand All @@ -59,19 +61,28 @@ def _validate_custom_reports(self, custom_reports_data: List[dict]):
error_messages.append(error.message)
raise Exception("An error occurred during custom_reports data validation: " + "; ".join(error_messages))

def read_catalog(self, catalog_path: str) -> ConfiguredAirbyteCatalog:
Copy link
Contributor

Choose a reason for hiding this comment

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

this method is not called anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is called when performing read operation, I redefined this function from a base class to save and then filter out streams we want to use

Copy link
Contributor

Choose a reason for hiding this comment

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

@po3na4skld, This method is called during the Read method, and when the Discover method is launched, no one stream will found, so we will get zero streams and we will not be able to read the data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yevhenii-ldv for now it works as before

catalog = ConfiguredAirbyteCatalog.parse_obj(self.read_config(catalog_path))
if not self.reports_to_read:
self.reports_to_read = [i.stream.name for i in catalog.streams]
return catalog_path

def _get_reports_file_path(self, temp_dir: str, custom_reports_data: List[dict]) -> str:
report_definition = (
json.loads(pkgutil.get_data("tap_google_analytics", "defaults/default_report_definition.json")) + custom_reports_data
)
if self.reports_to_read:
report_definition = [i for i in report_definition if i["name"] in self.reports_to_read]

custom_reports = os.path.join(temp_dir, "custom_reports.json")
with open(custom_reports, "w") as file:
file.write(json.dumps(report_definition))

return custom_reports

def _check_custom_reports(self, config: dict = None, config_path: str = None):
if config_path:
config = self.read_config(config_path)

custom_reports = config.pop("custom_reports")
if custom_reports.strip() and json.loads(custom_reports):
custom_reports_data = json.loads(custom_reports)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"custom_reports": {
"title": "Custom Reports",
"type": "string",
"title": "Custom Reports",
"description": "A JSON array describing the custom reports you want to sync from GA. Check out the <a href=\"https://docs.airbyte.io/integrations/sources/googleanalytics\">docs</a> to get more information about this field."
}
}
Expand Down
Empty file.