From 6b446ff1a134693b36709d052d9eab53c3d3209e Mon Sep 17 00:00:00 2001 From: shaun Date: Sun, 9 Oct 2016 22:49:46 +1100 Subject: [PATCH] add setting to disable analytic logging --- resources/language/English/strings.xml | 1 + resources/lib/ga_client.py | 12 +++++++++--- resources/settings.xml | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 383cbc57..9e6bf4b4 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -232,6 +232,7 @@ Username or email Enable database locked fix (will slow syncing process) Enable server offline message + Enable analytic metric logging Sign in with Emby Connect diff --git a/resources/lib/ga_client.py b/resources/lib/ga_client.py index e2c4c3dc..d9a831ee 100644 --- a/resources/lib/ga_client.py +++ b/resources/lib/ga_client.py @@ -27,6 +27,9 @@ class GoogleAnalytics(): def sendEventData(self, eventCategory, eventAction): + if(settings('metricLogging') == "false"): + return + # for info on the metrics that can be sent to Google Analytics # https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#events @@ -52,15 +55,18 @@ class GoogleAnalytics(): data['ea'] = eventAction # Event Action #data['el'] = 'Play' # Event Label - log.info("GOOGLEANALYTICS : " + str(data)) + log.info("GA: " + str(data)) if(self.testing): url = "https://www.google-analytics.com/debug/collect" # test URL else: url = "https://www.google-analytics.com/collect" # prod URL - r = requests.post(url, data) + try: + r = requests.post(url, data) + except Exception as error: + log.error(error) if(self.testing): - log.error("GOOGLEANALYTICS : " + r.text.encode('utf-8')) + log.error("GA: " + r.text.encode('utf-8')) \ No newline at end of file diff --git a/resources/settings.xml b/resources/settings.xml index 6a7ede0a..1d71a99a 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -76,6 +76,7 @@ +