add screen app size to GA

only ping GA if playing
dont send an app stopped message
This commit is contained in:
sfaulds 2016-10-14 14:35:34 +11:00
parent 9360843988
commit ab33ef5848
4 changed files with 21 additions and 10 deletions

View File

@ -5,6 +5,7 @@ import requests
import logging import logging
import clientinfo import clientinfo
import md5 import md5
import xbmcgui
from utils import window, settings, language as lang from utils import window, settings, language as lang
log = logging.getLogger("EMBY."+__name__) log = logging.getLogger("EMBY."+__name__)
@ -30,6 +31,10 @@ class GoogleAnalytics():
self.device_id = md5.new(self.device_id).hexdigest() self.device_id = md5.new(self.device_id).hexdigest()
self.user_name = md5.new(self.user_name).hexdigest() self.user_name = md5.new(self.user_name).hexdigest()
# resolution
self.height = xbmcgui.Window(10000).getHeight()
self.width = xbmcgui.Window(10000).getWidth()
def formatException(self): def formatException(self):
exc_type, exc_obj, exc_tb = sys.exc_info() exc_type, exc_obj, exc_tb = sys.exc_info()
@ -77,6 +82,9 @@ class GoogleAnalytics():
data['ec'] = eventCategory # Event Category data['ec'] = eventCategory # Event Category
data['ea'] = eventAction # Event Action data['ea'] = eventAction # Event Action
# add width and height
data['sr'] = str(self.width) + "x" + str(self.height)
if(eventLabel != None): if(eventLabel != None):
data['el'] = eventLabel # Event Label data['el'] = eventLabel # Event Label

View File

@ -81,9 +81,6 @@ class LibrarySync(threading.Thread):
# Run at start up - optional to use the server plugin # Run at start up - optional to use the server plugin
if settings('SyncInstallRunDone') == "true": if settings('SyncInstallRunDone') == "true":
ga.sendEventData("SyncAction", "FastSync")
# Validate views # Validate views
self.refreshViews() self.refreshViews()
completed = False completed = False
@ -97,11 +94,13 @@ class LibrarySync(threading.Thread):
if plugin['Name'] == "Emby.Kodi Sync Queue": if plugin['Name'] == "Emby.Kodi Sync Queue":
log.debug("Found server plugin.") log.debug("Found server plugin.")
self.isFastSync = True self.isFastSync = True
ga.sendEventData("SyncAction", "FastSync")
completed = self.fastSync() completed = self.fastSync()
break break
if not completed: if not completed:
# Fast sync failed or server plugin is not found # Fast sync failed or server plugin is not found
ga.sendEventData("SyncAction", "Sync")
completed = ManualSync().sync() completed = ManualSync().sync()
else: else:
# Install sync is not completed # Install sync is not completed

View File

@ -477,6 +477,9 @@ class Player(xbmc.Player):
self.played_info.clear() self.played_info.clear()
ga = GoogleAnalytics()
ga.sendEventData("PlayAction", "Stopped")
def stopPlayback(self, data): def stopPlayback(self, data):
log.debug("stopPlayback called") log.debug("stopPlayback called")

View File

@ -140,13 +140,14 @@ class Service(object):
# or Kodi is shut down. # or Kodi is shut down.
self._server_online_check() self._server_online_check()
# ping metrics server to keep sessions alive # ping metrics server to keep sessions alive while playing
# ping every 3 min # ping every 5 min
timeSinceLastPing = time.time() - self.lastMetricPing timeSinceLastPing = time.time() - self.lastMetricPing
if(timeSinceLastPing > 180): if(timeSinceLastPing > 300):
self.lastMetricPing = time.time() self.lastMetricPing = time.time()
if self.kodi_player.isPlaying():
ga = GoogleAnalytics() ga = GoogleAnalytics()
ga.sendEventData("Application", "Ping") ga.sendEventData("PlayAction", "PlayPing")
if self.monitor.waitForAbort(1): if self.monitor.waitForAbort(1):
# Abort was requested while waiting. We should exit # Abort was requested while waiting. We should exit
@ -297,8 +298,8 @@ class Service(object):
def shutdown(self): def shutdown(self):
ga = GoogleAnalytics() #ga = GoogleAnalytics()
ga.sendEventData("Application", "Shutdown") #ga.sendEventData("Application", "Shutdown")
if self.userclient_running: if self.userclient_running:
self.userclient_thread.stop_client() self.userclient_thread.stop_client()