Merge remote-tracking branch 'refs/remotes/origin/master' into develop

This commit is contained in:
angelblue05 2016-11-02 21:19:30 -05:00
commit 80a554a91b
4 changed files with 21 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import md5
import xbmc
import platform
import xbmcgui
import time
from utils import window, settings, language as lang
log = logging.getLogger("EMBY."+__name__)
@ -15,6 +16,8 @@ log = logging.getLogger("EMBY."+__name__)
# for info on the metrics that can be sent to Google Analytics
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events
logEventHistory = {}
class GoogleAnalytics():
testing = False
@ -128,7 +131,18 @@ class GoogleAnalytics():
self.sendData(data)
def sendEventData(self, eventCategory, eventAction, eventLabel=None):
def sendEventData(self, eventCategory, eventAction, eventLabel=None, throttle=False):
# if throttling is enabled then only log the same event every 5 min
if(throttle):
throttleKey = eventCategory + "-" + eventAction + "-" + str(eventLabel)
lastLogged = logEventHistory.get(throttleKey)
if(lastLogged != None):
timeSinceLastLog = time.time() - lastLogged
if(timeSinceLastLog < 300):
log.info("SKIPPING_LOG_EVENT : " + str(timeSinceLastLog) + " " + throttleKey)
return
logEventHistory[throttleKey] = time.time()
data = self.getBaseData()
data['t'] = 'event' # action type

View file

@ -30,7 +30,7 @@ def catch_except(errors=(Exception, )):
return func(*args, **kwargs)
except errors as error:
errStrings = ga.formatException()
ga.sendEventData("Exception", errStrings[0], errStrings[1])
ga.sendEventData("Exception", errStrings[0], errStrings[1], True)
log.exception(error)
log.error("function: %s \n args: %s \n kwargs: %s",
func.__name__, args, kwargs)