summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2023-09-08 17:08:00 -0400
committermorpheus65535 <[email protected]>2023-09-08 17:08:00 -0400
commit3694254c79d29498bda53335fbf45c841ba3400d (patch)
tree525011fffc4a5d2fe39a5c5177469f9efc7da024
parent85d300f94ef60ef60416786a80db2d89917b8266 (diff)
downloadbazarr-3694254c79d29498bda53335fbf45c841ba3400d.tar.gz
bazarr-3694254c79d29498bda53335fbf45c841ba3400d.zip
Added analytics tracking of throttled providers
-rw-r--r--bazarr/app/get_providers.py3
-rw-r--r--bazarr/subtitles/processing.py2
-rw-r--r--bazarr/utilities/analytics.py19
3 files changed, 22 insertions, 2 deletions
diff --git a/bazarr/app/get_providers.py b/bazarr/app/get_providers.py
index f1fef1d33..ad34027d0 100644
--- a/bazarr/app/get_providers.py
+++ b/bazarr/app/get_providers.py
@@ -25,6 +25,7 @@ from app.event_handler import event_stream
from utilities.binaries import get_binary
from radarr.blacklist import blacklist_log_movie
from sonarr.blacklist import blacklist_log
+from utilities.analytics import event_tracker
def time_until_midnight(timezone):
@@ -344,6 +345,8 @@ def provider_throttle(name, exception):
logging.info("Throttling %s for %s, until %s, because of: %s. Exception info: %r", name,
throttle_description, throttle_until.strftime("%y/%m/%d %H:%M"), cls_name, exception.args[0]
if exception.args else None)
+ event_tracker.track_throttling(provider=name, exception_name=cls_name, exception_info=exception.args[0]
+ if exception.args else None)
update_throttled_provider()
diff --git a/bazarr/subtitles/processing.py b/bazarr/subtitles/processing.py
index 49c039281..aa423285b 100644
--- a/bazarr/subtitles/processing.py
+++ b/bazarr/subtitles/processing.py
@@ -137,7 +137,7 @@ def process_subtitle(subtitle, media_type, audio_language, path, max_score, is_u
notify_radarr(movie_metadata.radarrId)
event_stream(type='movie-wanted', action='delete', payload=movie_metadata.radarrId)
- event_tracker.track(provider=downloaded_provider, action=action, language=downloaded_language)
+ event_tracker.track_subtitles(provider=downloaded_provider, action=action, language=downloaded_language)
return ProcessSubtitlesResult(message=message,
reversed_path=reversed_path,
diff --git a/bazarr/utilities/analytics.py b/bazarr/utilities/analytics.py
index 948f0fcca..87ee46af0 100644
--- a/bazarr/utilities/analytics.py
+++ b/bazarr/utilities/analytics.py
@@ -47,7 +47,7 @@ class EventTracker:
self.tracker.store.save()
- def track(self, provider, action, language):
+ def track_subtitles(self, provider, action, language):
if not settings.analytics.getboolean('enabled'):
return
@@ -64,5 +64,22 @@ class EventTracker:
else:
self.tracker.store.save()
+ def track_throttling(self, provider, exception_name, exception_info):
+ if not settings.analytics.getboolean('enabled'):
+ return
+
+ throttling_event = self.tracker.create_new_event(name="throttling")
+
+ throttling_event.set_event_param(name="provider", value=provider)
+ throttling_event.set_event_param(name="exception_name", value=exception_name)
+ throttling_event.set_event_param(name="exception_info", value=exception_info)
+
+ try:
+ self.tracker.send(events=[throttling_event])
+ except Exception:
+ logging.debug("BAZARR unable to track event.")
+ else:
+ self.tracker.store.save()
+
event_tracker = EventTracker()