35 from copy
import deepcopy
36 from classes
import info
37 from classes
import language
38 from classes.logger
import log
39 from classes
import settings
43 from PyQt5.Qt
import PYQT_VERSION_STR
47 libopenshot_version = openshot.GetVersion()
53 os_version =
"X11; Linux %s" % platform.machine()
56 if platform.system() ==
"Darwin":
57 v = platform.mac_ver()
58 os_version =
"Macintosh; Intel Mac OS X %s" % v[0].replace(
".",
"_")
59 linux_distro =
"OS X %s" % v[0]
61 elif platform.system() ==
"Windows":
62 v = platform.win32_ver()
64 os_version =
"Windows NT %s; %s" % (v[0], v[1])
65 linux_distro =
"Windows %s" %
"-".join(platform.win32_ver())
67 elif platform.system() ==
"Linux":
69 linux_distro =
"-".join(platform.linux_distribution())
71 except Exception
as Ex:
72 log.error(
"Error determining OS version in metrics.py")
75 user_agent =
"Mozilla/5.0 (%s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36" % os_version
78 "cid" : s.get(
"unique_install_id"),
80 "tid" :
"UA-4381101-5",
81 "an" : info.PRODUCT_NAME,
83 "aid" :
"org.openshot.%s" % info.NAME,
87 "cd1" : libopenshot_version.ToString(),
88 "cd2" : platform.python_version(),
89 "cd3" : QT_VERSION_STR,
90 "cd4" : PYQT_VERSION_STR,
97 metric_params = deepcopy(params)
98 metric_params[
"t"] =
"screenview"
99 metric_params[
"cd"] = screen_name
100 metric_params[
"cid"] = s.get(
"unique_install_id")
102 t = threading.Thread(target=send_metric, args=[metric_params])
108 metric_params = deepcopy(params)
109 metric_params[
"t"] =
"event"
110 metric_params[
"ec"] = event_category
111 metric_params[
"ea"] = event_action
112 metric_params[
"el"] = event_label
113 metric_params[
"ev"] = event_value
114 metric_params[
"cid"] = s.get(
"unique_install_id")
116 t = threading.Thread(target=send_metric, args=[metric_params])
122 metric_params = deepcopy(params)
123 metric_params[
"t"] =
"exception"
124 metric_params[
"exd"] = error_name
125 metric_params[
"exf"] = 0
127 metric_params[
"exf"] = 1
129 t = threading.Thread(target=send_metric, args=[metric_params])
135 t = threading.Thread(target=send_exception, args=[stacktrace, source])
141 metric_params = deepcopy(params)
142 metric_params[
"t"] =
"screenview"
143 metric_params[
"sc"] =
"start"
144 metric_params[
"cd"] =
"launch-app"
145 metric_params[
"cid"] = s.get(
"unique_install_id")
147 metric_params[
"sc"] =
"end"
148 metric_params[
"cd"] =
"close-app"
150 t = threading.Thread(target=send_metric, args=[metric_params])
157 if s.get(
"send_metrics"):
159 url_params = urllib.parse.urlencode(params)
160 url =
"http://www.google-analytics.com/collect?%s" % url_params
164 r = requests.get(url, headers={
"user-agent": user_agent}, verify=
False)
165 log.info(
"Track metric: [%s] %s | (%s bytes)" % (r.status_code, r.url, len(r.content)))
167 except Exception
as Ex:
168 log.error(
"Failed to Track metric: %s" % (Ex))
174 if s.get(
"send_metrics"):
176 data = urllib.parse.urlencode({
"stacktrace": stacktrace,
177 "platform": platform.system(),
178 "version": info.VERSION,
180 "unique_install_id": s.get(
"unique_install_id" )})
181 url =
"http://www.openshot.org/exception/json/"
185 r = requests.post(url, data=data, headers={
"user-agent": user_agent,
"content-type":
"application/x-www-form-urlencoded"}, verify=
False)
186 log.info(
"Track exception: [%s] %s | %s" % (r.status_code, r.url, r.text))
188 except Exception
as Ex:
189 log.error(
"Failed to Track exception: %s" % (Ex))
def track_metric_screen
Track a GUI screen being shown.
def send_metric
Send anonymous metric over HTTP for tracking.
def track_metric_error
Track an error has occurred.
def track_metric_event
Track a GUI screen being shown.
def track_exception_stacktrace
Track an exception/stacktrace has occurred.
def send_exception
Send exception stacktrace over HTTP for tracking.
def track_metric_session
Track a GUI screen being shown.
def get_settings
Get the current QApplication's settings instance.