From c1875c31ed880d3dc58e73cb3651c36aa0cb3f30 Mon Sep 17 00:00:00 2001 From: Elon Gliksberg Date: Wed, 21 Jun 2023 17:05:31 +0300 Subject: [PATCH] Passing the correct 'anonymous_warehouse_id'. --- elementary/monitor/data_monitoring/data_monitoring.py | 8 +++----- .../data_monitoring/report/data_monitoring_report.py | 6 ++++-- elementary/tracking/anonymous_tracking.py | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/elementary/monitor/data_monitoring/data_monitoring.py b/elementary/monitor/data_monitoring/data_monitoring.py index faeb681d8..531171020 100644 --- a/elementary/monitor/data_monitoring/data_monitoring.py +++ b/elementary/monitor/data_monitoring/data_monitoring.py @@ -39,14 +39,12 @@ def __init__( latest_invocation = self.get_latest_invocation() self.project_name = latest_invocation.get("project_name") dbt_pkg_version = latest_invocation.get("elementary_version") - warehouse_info = self._get_warehouse_info( + self.warehouse_info = self._get_warehouse_info( hash_id=isinstance(tracking, AnonymousTracking) ) - if warehouse_info: - self.warehouse_type = warehouse_info.type if tracking: - if warehouse_info: - tracking.register_warehouse_group(warehouse_info) + if self.warehouse_info: + tracking.register_warehouse_group(self.warehouse_info) tracking.set_env("target_name", latest_invocation.get("target_name")) tracking.set_env("dbt_orchestrator", latest_invocation.get("orchestrator")) tracking.set_env("dbt_version", latest_invocation.get("dbt_version")) diff --git a/elementary/monitor/data_monitoring/report/data_monitoring_report.py b/elementary/monitor/data_monitoring/report/data_monitoring_report.py index e433ca428..75948e413 100644 --- a/elementary/monitor/data_monitoring/report/data_monitoring_report.py +++ b/elementary/monitor/data_monitoring/report/data_monitoring_report.py @@ -108,7 +108,7 @@ def get_report_data( project_name=project_name or self.project_name, filter=self.filter.get_filter(), env=self.config.env, - warehouse_type=self.warehouse_type, + warehouse_type=self.warehouse_info.type if self.warehouse_info else None, ) self._add_report_tracking(report_data, error) if error: @@ -148,7 +148,9 @@ def _add_report_tracking( report_data.tracking = dict( posthog_api_key=self.tracking.POSTHOG_PROJECT_API_KEY, report_generator_anonymous_user_id=self.tracking.anonymous_user_id, - anonymous_warehouse_id=self.tracking.anonymous_warehouse_id, + anonymous_warehouse_id=self.warehouse_info.id + if self.warehouse_info + else None, ) def send_report( diff --git a/elementary/tracking/anonymous_tracking.py b/elementary/tracking/anonymous_tracking.py index c2e41c657..e00db7e50 100644 --- a/elementary/tracking/anonymous_tracking.py +++ b/elementary/tracking/anonymous_tracking.py @@ -20,7 +20,6 @@ class AnonymousTracking(Tracking): def __init__(self, config: Config) -> None: super().__init__(config) self.anonymous_user_id = None - self.anonymous_warehouse_id = None self._do_not_track = config.anonymous_tracking_enabled is False self._run_id = str(uuid.uuid4())