Skip to content

Commit

Permalink
(#23551) track project id for deps events
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbanin committed May 11, 2020
1 parent 8686ab9 commit cbdcc30
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
25 changes: 16 additions & 9 deletions core/dbt/task/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,23 @@ def __init__(self, args, config: UnsetProfileConfig):
def track_package_install(
self, package_name: str, source_type: str, version: str
) -> None:
version = 'local' if source_type == 'local' else version
# Hub packages do not need to be hashed, as they are public
# Use the string 'local' for local package versions
if source_type == 'local':
version = 'local'
elif source_type != 'hub':
package_name = dbt.utils.md5(package_name)
version = dbt.utils.md5(version)

h_package_name = dbt.utils.md5(package_name)
h_version = dbt.utils.md5(version)

dbt.tracking.track_package_install({
"name": h_package_name,
"source": source_type,
"version": h_version
})
dbt.tracking.track_package_install(
self.config,
self.config.args,
{
"name": package_name,
"source": source_type,
"version": version
}
)

def run(self):
system.make_directory(self.config.modules_path)
Expand Down
10 changes: 8 additions & 2 deletions core/dbt/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,17 @@ def track_rpc_request(options):
)


def track_package_install(options):
context = [SelfDescribingJson(PACKAGE_INSTALL_SPEC, options)]
def track_package_install(config, args, options):
assert active_user is not None, \
'Cannot track package installs when active user is None'

invocation_data = get_invocation_context(active_user, config, args)

context = [
SelfDescribingJson(INVOCATION_SPEC, invocation_data),
SelfDescribingJson(PACKAGE_INSTALL_SPEC, options)
]

track(
active_user,
category="dbt",
Expand Down

0 comments on commit cbdcc30

Please sign in to comment.