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
from contextlib import contextmanager
from datetime import datetime
from typing import Optional
from typing import Optional, Dict, Any
import logbook
import pytz
@@ -212,6 +212,21 @@ def track(user, *args, **kwargs):
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):
assert active_user is not None, "Cannot track project_id when active user is None"
context = [SelfDescribingJson(PROJECT_ID_SPEC, options)]