mirror of https://github.com/morpheus65535/bazarr
Added analytics tracking of throttled providers
This commit is contained in:
parent
85d300f94e
commit
3694254c79
|
@ -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()
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue