Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 5295252

Browse files
committed
add a one time message about vscode extension
1 parent f80dc58 commit 5295252

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

data_diff/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def _get_log_handlers(is_dbt: Optional[bool] = False) -> Dict[str, logging.Handl
4848
rich_handler.setLevel(logging.WARN)
4949
handlers["rich_handler"] = rich_handler
5050

51-
# only use log_status_handler in a terminal
52-
if rich_handler.console.is_terminal and is_dbt:
51+
# only use log_status_handler in an interactive terminal session
52+
if rich_handler.console.is_interactive and is_dbt:
5353
log_status_handler = LogStatusHandler()
5454
log_status_handler.setFormatter(logging.Formatter(log_format_status, datefmt=date_format))
5555
log_status_handler.setLevel(logging.DEBUG)

data_diff/dbt.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .format import jsonify, jsonify_error
2424
from .tracking import (
2525
bool_ask_for_email,
26+
bool_notify_about_extension,
2627
create_email_signup_event_json,
2728
set_entrypoint_name,
2829
set_dbt_user_id,
@@ -48,6 +49,7 @@
4849

4950
logger = getLogger(__name__)
5051
CLOUD_DOC_URL = "https://docs.datafold.com/development_testing/cloud"
52+
EXTENSION_INSTALL_URL = "https://marketplace.visualstudio.com/items?itemName=Datafold.datafold-vscode"
5153

5254

5355
class TDiffVars(pydantic.BaseModel):
@@ -155,6 +157,7 @@ def dbt_diff(
155157
for thread in diff_threads:
156158
thread.join()
157159

160+
_extension_notification()
158161

159162
def _get_diff_vars(
160163
dbt_parser: "DbtParser",
@@ -517,3 +520,7 @@ def _email_signup() -> None:
517520
if email:
518521
event_json = create_email_signup_event_json(email)
519522
run_as_daemon(send_event_json, event_json)
523+
524+
def _extension_notification() -> None:
525+
if bool_notify_about_extension():
526+
rich.print(f"\n\n:heart_eyes-emoji: Love diffs?\n:eyes-emoji: Check out the :party_popper-emoji: [bold] new VSCode extension [/bold] :party_popper-emoji::\n{EXTENSION_INSTALL_URL}")

data_diff/tracking.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import urllib.request
1212
from uuid import uuid4
1313
import toml
14+
from rich import get_console
1415

1516
from .version import __version__
1617

@@ -61,6 +62,16 @@ def bool_ask_for_email() -> bool:
6162
return False
6263

6364

65+
def bool_notify_about_extension() -> bool:
66+
profile = _load_profile()
67+
console = get_console()
68+
if "notified_about_extension" not in profile and console.is_interactive:
69+
profile["notified_about_extension"] = ""
70+
with open(DEFAULT_PROFILE, "w") as conf:
71+
toml.dump(profile, conf)
72+
return True
73+
return False
74+
6475
g_tracking_enabled = True
6576
g_anonymous_id = None
6677

0 commit comments

Comments
 (0)