From f575108038fb0004add306d7a2af67ffd387fbf9 Mon Sep 17 00:00:00 2001 From: Alik Kurdyukov Date: Wed, 20 Sep 2023 18:54:03 +0400 Subject: [PATCH 1/3] fix conflict for real not minimal snowplow tracker --- core/dbt/tracking.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py index 1c852a68649..a512776cc75 100644 --- a/core/dbt/tracking.py +++ b/core/dbt/tracking.py @@ -19,6 +19,7 @@ from dbt import version as dbt_version from dbt import flags from snowplow_tracker import Subject, Tracker, Emitter, logger as sp_logger +from snowplow_tracker import __version__ as snowplow_version from snowplow_tracker import SelfDescribingJson from datetime import datetime @@ -48,17 +49,20 @@ RUNNABLE_TIMING = "iglu:com.dbt/runnable/jsonschema/1-0-0" DBT_INVOCATION_ENV = "DBT_INVOCATION_ENV" +# workaround in case real snowplow tracker is in the env +INIT_KW_ARGS = {"buffer_size": 30} if snowplow_version == '0.0.2' else {"batch_size": 30} + class TimeoutEmitter(Emitter): def __init__(self): super().__init__( COLLECTOR_URL, protocol=COLLECTOR_PROTOCOL, - buffer_size=30, on_failure=self.handle_failure, method="post", # don't set this. byte_limit=None, + **INIT_KW_ARGS, ) @staticmethod @@ -102,11 +106,20 @@ def http_get(self, payload): emitter = TimeoutEmitter() -tracker = Tracker( - emitter, - namespace="cf", - app_id="dbt", -) + +# workaround in case real snowplow tracker is in the env +if snowplow_version == '0.0.2': + tracker = Tracker( + emitter, + namespace="cf", + app_id="dbt", + ) +else: + tracker = Tracker( + "cf", + emitters=emitter, + app_id="dbt", + ) class User: From 3e50abb9475db5ac1af8839b7f0c8b8d93ebf72f Mon Sep 17 00:00:00 2001 From: Alik Kurdyukov Date: Fri, 29 Sep 2023 15:04:06 +0400 Subject: [PATCH 2/3] fix mypy errors --- core/dbt/tracking.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py index a512776cc75..4fb7c7ef930 100644 --- a/core/dbt/tracking.py +++ b/core/dbt/tracking.py @@ -50,7 +50,7 @@ DBT_INVOCATION_ENV = "DBT_INVOCATION_ENV" # workaround in case real snowplow tracker is in the env -INIT_KW_ARGS = {"buffer_size": 30} if snowplow_version == '0.0.2' else {"batch_size": 30} +INIT_KW_ARGS = {"buffer_size": 30} if snowplow_version == "0.0.2" else {"batch_size": 30} class TimeoutEmitter(Emitter): @@ -108,7 +108,7 @@ def http_get(self, payload): emitter = TimeoutEmitter() # workaround in case real snowplow tracker is in the env -if snowplow_version == '0.0.2': +if snowplow_version == "0.0.2": tracker = Tracker( emitter, namespace="cf", From 463932ac7887663f461b1ceeafeaea09968db42e Mon Sep 17 00:00:00 2001 From: Alik Kurdyukov Date: Sat, 30 Sep 2023 12:13:27 +0400 Subject: [PATCH 3/3] fix mypy by ignoring --- core/dbt/tracking.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py index 4fb7c7ef930..748d643f7f2 100644 --- a/core/dbt/tracking.py +++ b/core/dbt/tracking.py @@ -19,7 +19,7 @@ from dbt import version as dbt_version from dbt import flags from snowplow_tracker import Subject, Tracker, Emitter, logger as sp_logger -from snowplow_tracker import __version__ as snowplow_version +from snowplow_tracker import __version__ as snowplow_version # type: ignore from snowplow_tracker import SelfDescribingJson from datetime import datetime @@ -119,7 +119,7 @@ def http_get(self, payload): "cf", emitters=emitter, app_id="dbt", - ) + ) # type: ignore class User: