mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31: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:
|
||||
locale.setlocale(locale.LC_ALL, "")
|
||||
plexpy.SYS_ENCODING = locale.getpreferredencoding()
|
||||
plexpy.SYS_LANGUAGE, plexpy.SYS_ENCODING = locale.getdefaultlocale()
|
||||
except (locale.Error, IOError):
|
||||
pass
|
||||
|
||||
|
|
|
@ -303,6 +303,7 @@ Tracker.alias(safe_unicode, 'dr', 'referrer', 'referer')
|
|||
Tracker.alias(int, 'qt', 'queueTime', 'queue-time')
|
||||
Tracker.alias(safe_unicode, 't', 'hitType', 'hittype')
|
||||
Tracker.alias(int, 'aip', 'anonymizeIp', 'anonIp', 'anonymize-ip')
|
||||
Tracker.alias(safe_unicode, 'ds', 'dataSource', 'data-source')
|
||||
|
||||
# Campaign attribution
|
||||
Tracker.alias(safe_unicode, 'cn', 'campaign', 'campaignName', 'campaign-name')
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
import os
|
||||
from Queue import Queue
|
||||
import shutil
|
||||
import sqlite3
|
||||
import sys
|
||||
import subprocess
|
||||
|
@ -56,6 +55,7 @@ ARGS = None
|
|||
SIGNAL = None
|
||||
|
||||
SYS_PLATFORM = None
|
||||
SYS_LANGUAGE = None
|
||||
SYS_ENCODING = None
|
||||
|
||||
QUIET = False
|
||||
|
@ -98,6 +98,8 @@ DEV = False
|
|||
WS_CONNECTED = False
|
||||
PLEX_SERVER_UP = None
|
||||
|
||||
TRACKER = None
|
||||
|
||||
|
||||
def initialize(config_file):
|
||||
with INIT_LOCK:
|
||||
|
@ -460,14 +462,17 @@ def start():
|
|||
activity_pinger.connect_server(log=True, startup=True)
|
||||
|
||||
if CONFIG.SYSTEM_ANALYTICS:
|
||||
# Send analytic events
|
||||
global TRACKER
|
||||
TRACKER = initialize_tracker()
|
||||
|
||||
# Send system analytics events
|
||||
if not CONFIG.FIRST_RUN_COMPLETE:
|
||||
send_analytics(category='system', action='install')
|
||||
analytics_event(category='system', action='install')
|
||||
|
||||
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
|
||||
|
||||
|
@ -1684,14 +1689,35 @@ def generate_uuid():
|
|||
return uuid.uuid4().hex
|
||||
|
||||
|
||||
def send_analytics(category, action):
|
||||
tracker = Tracker.create('UA-111522699-2', client_id=CONFIG.PMS_UUID, hash_client_id=True)
|
||||
tracker.send('event', {
|
||||
'category': category,
|
||||
'action': action,
|
||||
def initialize_tracker():
|
||||
data = {
|
||||
'dataSource': 'server',
|
||||
'appName': 'Tautulli',
|
||||
'appVersion': common.VERSION_NUMBER,
|
||||
'appID': '{} {}'.format(common.PLATFORM, common.PLATFORM_VERSION),
|
||||
'appInstallerId': plexpy.INSTALL_TYPE,
|
||||
'userLanguage': plexpy.SYS_LANGUAGE,
|
||||
'documentEncoding': plexpy.SYS_ENCODING,
|
||||
'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