Skip to content

Commit

Permalink
Merge pull request #830 from spectacles-ci/remove-segment
Browse files Browse the repository at this point in the history
Remove tracking.
  • Loading branch information
DylanBaker authored Dec 3, 2024
2 parents 37b5a52 + 969a7bb commit f821009
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 238 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spectacles"
version = "2.4.10"
version = "2.4.11"
description = "A command-line, continuous integration tool for Looker and LookML."
authors = ["Spectacles <[email protected]>"]
license = "MIT"
Expand Down
18 changes: 1 addition & 17 deletions spectacles/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from yaml.parser import ParserError

import spectacles.printer as printer
import spectacles.tracking as tracking
from spectacles.client import (
DEFAULT_API_VERSION,
LOOKML_VALIDATION_TIMEOUT,
Expand Down Expand Up @@ -292,13 +291,6 @@ def main() -> None:

set_file_handler(args.log_dir)

if not args.do_not_track:
invocation_id = tracking.track_invocation_start(
args.base_url,
args.command,
project=args.project if args.command != "connect" else None,
)

if args.command == "connect":
asyncio.run(
run_connect(
Expand Down Expand Up @@ -389,14 +381,6 @@ def main() -> None:
)
)

if not args.do_not_track:
tracking.track_invocation_end(
args.base_url,
args.command,
invocation_id, # pyright: ignore[reportUnboundVariable, reportPossiblyUnboundVariable]
args.project if args.command != "connect" else None,
)


def create_parser() -> ArgumentParser:
"""Creates the top-level argument parser.
Expand Down Expand Up @@ -490,7 +474,7 @@ def _build_base_subparser() -> ArgumentParser:
"--do-not-track",
action=EnvVarStoreTrueAction,
env_var="SPECTACLES_DO_NOT_TRACK",
help="Disables anonymised event tracking.",
help="[DEPRECATED] Tracking is disabled by default, this argument is unused.",
)

return base_subparser
Expand Down
50 changes: 0 additions & 50 deletions spectacles/tracking.py

This file was deleted.

55 changes: 1 addition & 54 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,7 @@ def test_parse_args_with_mutually_exclusive_args_commit_ref(
@patch("sys.argv", new=["spectacles", "sql"])
@patch("spectacles.cli.Runner")
@patch("spectacles.cli.LookerClient", autospec=True)
@patch("spectacles.cli.tracking")
def test_main_with_sql_validator(
mock_tracking: MagicMock,
mock_client: MagicMock,
mock_runner: MagicMock,
env: None,
Expand All @@ -355,11 +353,6 @@ def test_main_with_sql_validator(
mock_runner.return_value.validate_sql = AsyncMock(return_value=validation)
with pytest.raises(SystemExit):
main()
mock_tracking.track_invocation_start.assert_called_once_with(
"BASE_URL_ENV_VAR", "sql", project="PROJECT_ENV_VAR"
)
# TODO: Uncomment the below assertion once #262 is fixed
# mock_tracking.track_invocation_end.assert_called_once()
mock_runner.assert_called_once()
assert "ecommerce.orders passed" in caplog.text
assert "ecommerce.sessions passed" in caplog.text
Expand All @@ -369,9 +362,7 @@ def test_main_with_sql_validator(
@patch("sys.argv", new=["spectacles", "content"])
@patch("spectacles.cli.Runner")
@patch("spectacles.cli.LookerClient", autospec=True)
@patch("spectacles.cli.tracking")
def test_main_with_content_validator(
mock_tracking: MagicMock,
mock_client: MagicMock,
mock_runner: MagicMock,
env: None,
Expand All @@ -381,11 +372,6 @@ def test_main_with_content_validator(
mock_runner.return_value.validate_content = AsyncMock(return_value=validation)
with pytest.raises(SystemExit):
main()
mock_tracking.track_invocation_start.assert_called_once_with(
"BASE_URL_ENV_VAR", "content", project="PROJECT_ENV_VAR"
)
# TODO: Uncomment the below assertion once #262 is fixed
# mock_tracking.track_invocation_end.assert_called_once()
mock_runner.assert_called_once()
assert "ecommerce.orders passed" in caplog.text
assert "ecommerce.sessions passed" in caplog.text
Expand All @@ -395,9 +381,7 @@ def test_main_with_content_validator(
@patch("sys.argv", new=["spectacles", "assert"])
@patch("spectacles.cli.Runner", autospec=True)
@patch("spectacles.cli.LookerClient", autospec=True)
@patch("spectacles.cli.tracking")
def test_main_with_assert_validator(
mock_tracking: MagicMock,
mock_client: MagicMock,
mock_runner: MagicMock,
env: None,
Expand All @@ -407,11 +391,6 @@ def test_main_with_assert_validator(
mock_runner.return_value.validate_data_tests = AsyncMock(return_value=validation)
with pytest.raises(SystemExit):
main()
mock_tracking.track_invocation_start.assert_called_once_with(
"BASE_URL_ENV_VAR", "assert", project="PROJECT_ENV_VAR"
)
# TODO: Uncomment the below assertion once #262 is fixed
# mock_tracking.track_invocation_end.assert_called_once()
mock_runner.assert_called_once()
assert "ecommerce.orders passed" in caplog.text
assert "ecommerce.sessions passed" in caplog.text
Expand All @@ -421,9 +400,7 @@ def test_main_with_assert_validator(
@patch("sys.argv", new=["spectacles", "lookml"])
@patch("spectacles.cli.Runner", autospec=True)
@patch("spectacles.cli.LookerClient", autospec=True)
@patch("spectacles.cli.tracking")
def test_main_with_lookml_validator(
mock_tracking: MagicMock,
mock_client: MagicMock,
mock_runner: MagicMock,
env: None,
Expand All @@ -433,45 +410,15 @@ def test_main_with_lookml_validator(
mock_runner.return_value.validate_lookml = AsyncMock(return_value=validation)
with pytest.raises(SystemExit):
main()
mock_tracking.track_invocation_start.assert_called_once_with(
"BASE_URL_ENV_VAR", "lookml", project="PROJECT_ENV_VAR"
)
# TODO: Uncomment the below assertion once #262 is fixed
# mock_tracking.track_invocation_end.assert_called_once()
mock_runner.assert_called_once()
assert "eye_exam/eye_exam.model.lkml" in caplog.text
assert "Could not find a field named 'users__fail.first_name'" in caplog.text


@patch("sys.argv", new=["spectacles", "connect"])
@patch("spectacles.cli.run_connect")
@patch("spectacles.cli.tracking")
def test_main_with_connect(
mock_tracking: MagicMock, mock_run_connect: AsyncMock, env: None
) -> None:
main()
mock_tracking.track_invocation_start.assert_called_once_with(
"BASE_URL_ENV_VAR", "connect", project=None
)
mock_tracking.track_invocation_end.assert_called_once()
mock_run_connect.assert_called_once_with(
base_url="BASE_URL_ENV_VAR",
client_id="CLIENT_ID_ENV_VAR",
client_secret="CLIENT_SECRET_ENV_VAR",
port=8080,
api_version=4.0,
)


@patch("sys.argv", new=["spectacles", "connect", "--do-not-track"])
@patch("spectacles.cli.run_connect")
@patch("spectacles.cli.tracking")
def test_main_with_do_not_track(
mock_tracking: MagicMock, mock_run_connect: AsyncMock, env: None
) -> None:
def test_main_with_connect(mock_run_connect: AsyncMock, env: None) -> None:
main()
mock_tracking.track_invocation_start.assert_not_called()
mock_tracking.track_invocation_end.assert_not_called()
mock_run_connect.assert_called_once_with(
base_url="BASE_URL_ENV_VAR",
client_id="CLIENT_ID_ENV_VAR",
Expand Down
116 changes: 0 additions & 116 deletions tests/unit/test_tracking.py

This file was deleted.

0 comments on commit f821009

Please sign in to comment.