33 from copy
import deepcopy
34 from classes
import info
35 from classes
import language
36 from classes.logger
import log
37 from classes
import settings
41 from PyQt5.Qt
import PYQT_VERSION_STR
45 libopenshot_version = openshot.GetVersion()
51 os_version =
"X11; Linux %s" % platform.machine()
54 if platform.system() ==
"Darwin":
55 v = platform.mac_ver()
56 os_version =
"Macintosh; Intel Mac OS X %s" % v[0].replace(
".",
"_")
57 linux_distro =
"OS X %s" % v[0]
59 elif platform.system() ==
"Windows":
60 v = platform.win32_ver()
62 os_version =
"Windows NT %s; %s" % (v[0], v[1])
63 linux_distro =
"Windows %s" %
"-".join(platform.win32_ver())
65 elif platform.system() ==
"Linux":
67 linux_distro =
"-".join(platform.linux_distribution())
69 except Exception
as Ex:
70 log.error(
"Error determing OS version in metrics.py")
73 user_agent =
"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36" % os_version
76 "cid" : s.get(
"unique_install_id"),
78 "tid" :
"UA-4381101-5",
79 "an" : info.PRODUCT_NAME,
81 "aid" :
"org.openshot.%s" % info.NAME,
85 "cd1" : libopenshot_version.ToString(),
86 "cd2" : platform.python_version(),
87 "cd3" : QT_VERSION_STR,
88 "cd4" : PYQT_VERSION_STR,
95 metric_params = deepcopy(params)
96 metric_params[
"t"] =
"screenview" 97 metric_params[
"cd"] = screen_name
99 t = threading.Thread(target=send_metric, args=[metric_params])
105 metric_params = deepcopy(params)
106 metric_params[
"t"] =
"event" 107 metric_params[
"ec"] = event_category
108 metric_params[
"ea"] = event_action
109 metric_params[
"el"] = event_label
110 metric_params[
"ev"] = event_value
112 t = threading.Thread(target=send_metric, args=[metric_params])
118 metric_params = deepcopy(params)
119 metric_params[
"t"] =
"exception" 120 metric_params[
"exd"] = error_name
121 metric_params[
"exf"] = 0
123 metric_params[
"exf"] = 1
125 t = threading.Thread(target=send_metric, args=[metric_params])
131 metric_params = deepcopy(params)
132 metric_params[
"t"] =
"screenview" 133 metric_params[
"sc"] =
"start" 134 metric_params[
"cd"] =
"launch-app" 136 metric_params[
"sc"] =
"end" 137 metric_params[
"cd"] =
"close-app" 139 t = threading.Thread(target=send_metric, args=[metric_params])
146 if s.get(
"send_metrics"):
148 url_params = urllib.parse.urlencode(params)
149 url =
"http://www.google-analytics.com/collect?%s" % url_params
153 resp, content = httplib2.Http(timeout=3).request(url, headers={
"user-agent": user_agent})
154 log.info(
"Track metric: %s (%s)" % (resp, content))
156 except Exception
as Ex:
157 log.error(
"Failed to Track metric: %s" % (Ex))
def send_metric(params)
Send anonymous metric over HTTP for tracking.
def track_metric_session(is_start=True)
Track a GUI screen being shown.
def get_current_locale()
Get the current locale name from the current system.
def track_metric_event(event_action, event_label, event_category="General", event_value=0)
Track a GUI screen being shown.
def get_settings()
Get the current QApplication's settings instance.
def track_metric_screen(screen_name)
Track a GUI screen being shown.
def track_metric_error(error_name, is_fatal=False)
Track an error has occurred.