Skip to content

Commit

Permalink
add generic snowplow tracker with file logger for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Sep 16, 2024
1 parent b3494cc commit 1e5a7be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
7 changes: 3 additions & 4 deletions dbt_common/events/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from dbt_common.events.event_manager_client import get_event_manager
from dbt_common.events.logger import LoggerConfig, LineFormat
from dbt_common.events.tracker import FileTracker, SnowplowTracker, Tracker, TrackerConfig
from dbt_common.events.types import DisableTracking, Note
from dbt_common.events.types import DisableTracking, Note, SendingEvent, SendEventFailure
from dbt_common.events.user import User
from dbt_common.exceptions import EventCompilationError, scrub_secrets, env_secrets
from dbt_common.utils.encoding import ForgivingJSONEncoder
Expand Down Expand Up @@ -266,9 +266,8 @@ def track(tracker: Tracker, user: User, msg: EventMsg) -> None:
if user.do_not_track:
return

# fire_event(SendingEvent(kwargs=str(**msg_to_dict(msg))))
fire_event(SendingEvent(kwargs=str(**msg_to_dict(msg))))
try:
tracker.track(msg)
except Exception:
# fire_event(SendEventFailure())
pass
fire_event(SendEventFailure())
16 changes: 16 additions & 0 deletions dbt_common/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ def message(self) -> str:
)


class SendingEvent(DebugLevel):
def code(self) -> str:
return "Z040"

def message(self) -> str:
return f"Sending event: {self.kwargs}"


class SendEventFailure(DebugLevel):
def code(self) -> str:
return "Z041"

def message(self) -> str:
return "An error was encountered while trying to send an event"


class Note(InfoLevel):
"""Unstructured events.
Expand Down

0 comments on commit 1e5a7be

Please sign in to comment.