Repository: dbt-labs/dbt-core

Issue:
[CT-2305] Add tracking for groups, contract, access, and version usage
As part of the multi-project phase 1 work, we'd like to track general adoption of new core constructs. This includes usage of `group`, `contract`, `access` and versioning. 

This could be tracked as part of `track_model_run` - https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/task/run.py#L111. 

Will also require a new `schemas/com.dbt/run_model/jsonschema/` version in the iglu repo - https://www.notion.so/dbtlabs/Tracking-a-new-event-in-dbt-Cloud-344430e7b7e547f4b2b5d3a506e2c2bd?pvs=4

Is blocked by:
- #6866


Discussion:

Resolving patch:
diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py
--- a/core/dbt/task/run.py
+++ b/core/dbt/task/run.py
@@ -108,6 +108,16 @@ def track_model_run(index, num_nodes, run_model_result):
     if tracking.active_user is None:
         raise DbtInternalError("cannot track model run with no active user")
     invocation_id = get_invocation_id()
+    node = run_model_result.node
+    has_group = True if hasattr(node, "group") and node.group else False
+    if node.resource_type == NodeType.Model:
+        access = node.access.value if node.access is not None else None
+        contract_enforced = node.contract.enforced
+        versioned = True if node.version else False
+    else:
+        access = None
+        contract_enforced = False
+        versioned = False
     tracking.track_model_run(
         {
             "invocation_id": invocation_id,
@@ -117,11 +127,15 @@ def track_model_run(index, num_nodes, run_model_result):
             "run_status": str(run_model_result.status).upper(),
             "run_skipped": run_model_result.status == NodeStatus.Skipped,
             "run_error": run_model_result.status == NodeStatus.Error,
-            "model_materialization": run_model_result.node.get_materialization(),
-            "model_id": utils.get_hash(run_model_result.node),
-            "hashed_contents": utils.get_hashed_contents(run_model_result.node),
+            "model_materialization": node.get_materialization(),
+            "model_id": utils.get_hash(node),
+            "hashed_contents": utils.get_hashed_contents(node),
             "timing": [t.to_dict(omit_none=True) for t in run_model_result.timing],
-            "language": str(run_model_result.node.language),
+            "language": str(node.language),
+            "has_group": has_group,
+            "contract_enforced": contract_enforced,
+            "access": access,
+            "versioned": versioned,
         }
     )
 
diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py
--- a/core/dbt/tracking.py
+++ b/core/dbt/tracking.py
@@ -42,10 +42,10 @@
 PARTIAL_PARSER = "iglu:com.dbt/partial_parser/jsonschema/1-0-1"
 PLATFORM_SPEC = "iglu:com.dbt/platform/jsonschema/1-0-0"
 PROJECT_ID_SPEC = "iglu:com.dbt/project_id/jsonschema/1-0-1"
-RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-0"
+RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-1"
 RPC_REQUEST_SPEC = "iglu:com.dbt/rpc_request/jsonschema/1-0-1"
 RUNNABLE_TIMING = "iglu:com.dbt/runnable/jsonschema/1-0-0"
-RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-2"
+RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-3"
 
 
 class TimeoutEmitter(Emitter):


Test patch: