diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py index 1c852a68649..748d643f7f2 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 # type: ignore 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", + ) # type: ignore class User: