mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 21:21:15 -07:00
Add some more system metrics
This commit is contained in:
parent
700547b63b
commit
51b5e615f5
3 changed files with 39 additions and 12 deletions
|
@ -62,7 +62,7 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
locale.setlocale(locale.LC_ALL, "")
|
locale.setlocale(locale.LC_ALL, "")
|
||||||
plexpy.SYS_ENCODING = locale.getpreferredencoding()
|
plexpy.SYS_LANGUAGE, plexpy.SYS_ENCODING = locale.getdefaultlocale()
|
||||||
except (locale.Error, IOError):
|
except (locale.Error, IOError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -303,6 +303,7 @@ Tracker.alias(safe_unicode, 'dr', 'referrer', 'referer')
|
||||||
Tracker.alias(int, 'qt', 'queueTime', 'queue-time')
|
Tracker.alias(int, 'qt', 'queueTime', 'queue-time')
|
||||||
Tracker.alias(safe_unicode, 't', 'hitType', 'hittype')
|
Tracker.alias(safe_unicode, 't', 'hitType', 'hittype')
|
||||||
Tracker.alias(int, 'aip', 'anonymizeIp', 'anonIp', 'anonymize-ip')
|
Tracker.alias(int, 'aip', 'anonymizeIp', 'anonIp', 'anonymize-ip')
|
||||||
|
Tracker.alias(safe_unicode, 'ds', 'dataSource', 'data-source')
|
||||||
|
|
||||||
# Campaign attribution
|
# Campaign attribution
|
||||||
Tracker.alias(safe_unicode, 'cn', 'campaign', 'campaignName', 'campaign-name')
|
Tracker.alias(safe_unicode, 'cn', 'campaign', 'campaignName', 'campaign-name')
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from Queue import Queue
|
from Queue import Queue
|
||||||
import shutil
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -56,6 +55,7 @@ ARGS = None
|
||||||
SIGNAL = None
|
SIGNAL = None
|
||||||
|
|
||||||
SYS_PLATFORM = None
|
SYS_PLATFORM = None
|
||||||
|
SYS_LANGUAGE = None
|
||||||
SYS_ENCODING = None
|
SYS_ENCODING = None
|
||||||
|
|
||||||
QUIET = False
|
QUIET = False
|
||||||
|
@ -98,6 +98,8 @@ DEV = False
|
||||||
WS_CONNECTED = False
|
WS_CONNECTED = False
|
||||||
PLEX_SERVER_UP = None
|
PLEX_SERVER_UP = None
|
||||||
|
|
||||||
|
TRACKER = None
|
||||||
|
|
||||||
|
|
||||||
def initialize(config_file):
|
def initialize(config_file):
|
||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
@ -460,14 +462,17 @@ def start():
|
||||||
activity_pinger.connect_server(log=True, startup=True)
|
activity_pinger.connect_server(log=True, startup=True)
|
||||||
|
|
||||||
if CONFIG.SYSTEM_ANALYTICS:
|
if CONFIG.SYSTEM_ANALYTICS:
|
||||||
# Send analytic events
|
global TRACKER
|
||||||
|
TRACKER = initialize_tracker()
|
||||||
|
|
||||||
|
# Send system analytics events
|
||||||
if not CONFIG.FIRST_RUN_COMPLETE:
|
if not CONFIG.FIRST_RUN_COMPLETE:
|
||||||
send_analytics(category='system', action='install')
|
analytics_event(category='system', action='install')
|
||||||
|
|
||||||
if _UPDATE:
|
if _UPDATE:
|
||||||
send_analytics(category='system', action='update')
|
analytics_event(category='system', action='update')
|
||||||
|
|
||||||
send_analytics(category='system', action='start')
|
analytics_event(category='system', action='start')
|
||||||
|
|
||||||
_STARTED = True
|
_STARTED = True
|
||||||
|
|
||||||
|
@ -1684,14 +1689,35 @@ def generate_uuid():
|
||||||
return uuid.uuid4().hex
|
return uuid.uuid4().hex
|
||||||
|
|
||||||
|
|
||||||
def send_analytics(category, action):
|
def initialize_tracker():
|
||||||
tracker = Tracker.create('UA-111522699-2', client_id=CONFIG.PMS_UUID, hash_client_id=True)
|
data = {
|
||||||
tracker.send('event', {
|
'dataSource': 'server',
|
||||||
'category': category,
|
|
||||||
'action': action,
|
|
||||||
'appName': 'Tautulli',
|
'appName': 'Tautulli',
|
||||||
'appVersion': common.VERSION_NUMBER,
|
'appVersion': common.VERSION_NUMBER,
|
||||||
'appID': '{} {}'.format(common.PLATFORM, common.PLATFORM_VERSION),
|
'appID': '{} {}'.format(common.PLATFORM, common.PLATFORM_VERSION),
|
||||||
'appInstallerId': plexpy.INSTALL_TYPE,
|
'appInstallerId': plexpy.INSTALL_TYPE,
|
||||||
|
'userLanguage': plexpy.SYS_LANGUAGE,
|
||||||
|
'documentEncoding': plexpy.SYS_ENCODING,
|
||||||
'noninteractive': True
|
'noninteractive': True
|
||||||
})
|
}
|
||||||
|
|
||||||
|
tracker = Tracker.create('UA-111522699-2', client_id=CONFIG.PMS_UUID, hash_client_id=True)
|
||||||
|
tracker.set(data)
|
||||||
|
|
||||||
|
return tracker
|
||||||
|
|
||||||
|
|
||||||
|
def analytics_event(category, action, label=None, value=None, **kwargs):
|
||||||
|
data = {'category': category, 'action': action}
|
||||||
|
|
||||||
|
if label is not None:
|
||||||
|
data['label'] = label
|
||||||
|
|
||||||
|
if value is not None:
|
||||||
|
data['value'] = value
|
||||||
|
|
||||||
|
if kwargs:
|
||||||
|
data.update(kwargs)
|
||||||
|
|
||||||
|
if TRACKER:
|
||||||
|
TRACKER.send('event', data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue