Compare commits

...

1 Commits

Author SHA1 Message Date
Michelle Ark
e77bda7e80 add track_spec helper 2023-08-03 11:15:10 -04:00

View File

@@ -4,7 +4,7 @@ import traceback
import uuid import uuid
from contextlib import contextmanager from contextlib import contextmanager
from datetime import datetime from datetime import datetime
from typing import Optional from typing import Optional, Dict, Any
import logbook import logbook
import pytz import pytz
@@ -212,6 +212,21 @@ def track(user, *args, **kwargs):
fire_event(SendEventFailure()) fire_event(SendEventFailure())
def track_spec(action: str, spec: str, options: Dict[str, Any]):
assert (
active_user is not None
), f"Cannot track {action.replace('_', ' ')} when active user is None"
context = [SelfDescribingJson(spec, options)]
track(
active_user,
category="dbt",
action=action,
label=get_invocation_id(),
context=context,
)
def track_project_id(options): def track_project_id(options):
assert active_user is not None, "Cannot track project_id when active user is None" assert active_user is not None, "Cannot track project_id when active user is None"
context = [SelfDescribingJson(PROJECT_ID_SPEC, options)] context = [SelfDescribingJson(PROJECT_ID_SPEC, options)]