Skip to content

Commit

Permalink
Remove gauges from analytics abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Dec 11, 2024
1 parent 3fe797f commit 7f4c579
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 35 deletions.
2 changes: 0 additions & 2 deletions temba/channels/android/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ def register(request):
@csrf_exempt
@transaction.non_atomic_requests
def sync(request, channel_id):
start = time.time()

if request.method != "POST":
return HttpResponse(status=500, content="POST Required")

Expand Down
21 changes: 0 additions & 21 deletions temba/utils/analytics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ class AnalyticsBackend(metaclass=abc.ABCMeta):
slug: str = None
hook_templates = {}

def gauges(self, values: dict):
"""
Records gauge values
"""

def track(self, user, event: str, properties: dict):
"""
Tracks a user event
Expand Down Expand Up @@ -52,11 +47,6 @@ class ConsoleBackend(AnalyticsBackend):

slug = "console"

def gauges(self, values: dict):
if not settings.TESTING: # pragma: no cover
for name, value in values.items():
print(f"[analytics] gauge={name} value={value}")

def track(self, user, event: str, properties: dict):
if not settings.TESTING: # pragma: no cover
print(f"[analytics] event={event} user={user.email}")
Expand All @@ -68,17 +58,6 @@ def get_backends() -> list:
return list(backends.values())


def gauges(values: dict):
"""
Reports a gauge value
"""
for backend in get_backends():
try:
backend.gauges(values)
except Exception:
logger.exception(f"error reporting gauges on {backend.slug}")


def identify(user, brand, org):
"""
Creates and identifies a new user to our analytics backends
Expand Down
12 changes: 0 additions & 12 deletions temba/utils/analytics/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ class AnalyticsTest(TembaTest):
def setUp(self):
super().setUp()

@patch("temba.utils.analytics.base.get_backends")
def test_gauges(self, mock_get_backends):
good = MagicMock()
mock_get_backends.return_value = [BadBackend(), good]

analytics.gauges({"foo_level": 123})

good.gauges.assert_called_once_with({"foo_level": 123})

@patch("temba.utils.analytics.base.get_backends")
def test_track(self, mock_get_backends):
good = MagicMock()
Expand Down Expand Up @@ -92,9 +83,6 @@ class BadBackend(AnalyticsBackend):
slug = "bad"
hook_templates = {"frame-top": "bad/frame_top.html"}

def gauges(self, values: dict):
raise ValueError("boom")

def track(self, user, event: str, properties: dict):
raise ValueError("boom")

Expand Down

0 comments on commit 7f4c579

Please sign in to comment.