Skip to content

Commit

Permalink
Support disabling event tracking when using Cosmos profile mapping (a…
Browse files Browse the repository at this point in the history
…stronomer#768)

Since dbt by default tracks events by sending anonymous statistic usage
when dbt is invoked, users who currently use Cosmos profile mapping can
only opt-out by setting environment variables as described in
astronomer#724 (comment)

This PR adds a new arg to the profile mapping so that the [dbt
recommended config
block](https://docs.getdbt.com/reference/global-configs/usage-stats) can
be added in the generated `profiles.yml` file:

```yaml
config:
  send_anonymous_usage_stats: False
```

Closes: astronomer#724
  • Loading branch information
jbandoro authored and YuriyK90 committed Jan 11, 2024
1 parent a4bf9f7 commit 4b0b147
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cosmos/profiles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class BaseProfileMapping(ABC):

_conn: Connection | None = None

def __init__(self, conn_id: str, profile_args: dict[str, Any] | None = None):
def __init__(self, conn_id: str, profile_args: dict[str, Any] | None = None, disable_event_tracking: bool = False):
self.conn_id = conn_id
self.profile_args = profile_args or {}
self._validate_profile_args()
self.disable_event_tracking = disable_event_tracking

def _validate_profile_args(self) -> None:
"""
Expand Down Expand Up @@ -161,7 +162,7 @@ def get_profile_file_contents(
profile_name: str,
target_name: str = "cosmos_target",
use_mock_values: bool = False,
dbt_config_vars: dict[str, Any] | None = None
dbt_config_vars: dict[str, Any] | None = None,
) -> str:
"""
Translates the profile into a string that can be written to a profiles.yml file.
Expand Down

0 comments on commit 4b0b147

Please sign in to comment.