Skip to content

Commit

Permalink
Optimising the opt-in / opt-out process, so we can capture the initia…
Browse files Browse the repository at this point in the history
…l launch anonymously, and then opt-out the user and prompt them to opt back in. Essentially this is the same as before, except we get the initial launch analytic (to help us better report on our usage and market share). All subsequent tracking is disabled until the user opts in.
  • Loading branch information
jonoomph committed Aug 19, 2021
1 parent 5cc355e commit c8b670c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/classes/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ def send_metric(params):
# Send metric HTTP data
try:
r = requests.get(url, headers={"user-agent": user_agent})
log.info("Track metric: [%s] %s | (%s bytes)" % (r.status_code, r.url, len(r.content)))

except Exception:
log.warning("Failed to track metric", exc_info=1)

Expand Down
39 changes: 22 additions & 17 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ def closeEvent(self, event):
# Stop threads
self.StopSignal.emit()

# Stop thumbnail server thread
self.http_server_thread.kill()

# Stop ZMQ polling thread
get_app().logger_libopenshot.kill()

# Process any queued events
QCoreApplication.processEvents()

Expand Down Expand Up @@ -2079,19 +2085,7 @@ def actionSimple_View_trigger(self):

# Set initial size of docks
simple_state = "".join([
"AAAA/wAAAAD9AAAAAwAAAAAAAAEnAAAC3/wCAAAAA/wAAAJeAAAApwAAAAAA////+gAAAAACAAAAAfsAAAA"
"YAGQAbwBjAGsASwBlAHkAZgByAGEAbQBlAAAAAAD/////AAAAAAAAAAD7AAAAHABkAG8AYwBrAFAAcgBvAH"
"AAZQByAHQAaQBlAHMAAAAAJwAAAt8AAAChAP////sAAAAYAGQAbwBjAGsAVAB1AHQAbwByAGkAYQBsAgAAA"
"AAAAAAAAAAAyAAAAGQAAAABAAABHAAAAUD8AgAAAAH7AAAAGABkAG8AYwBrAEsAZQB5AGYAcgBhAG0AZQEA"
"AAFYAAAAFQAAAAAAAAAAAAAAAgAABEYAAALY/AEAAAAC/AAAAAAAAANnAAAA+gD////8AgAAAAL8AAAAJwA"
"AAcAAAACvAP////wBAAAAAvwAAAAAAAABFQAAAHsA////+gAAAAACAAAAA/sAAAASAGQAbwBjAGsARgBpAG"
"wAZQBzAQAAAAD/////AAAAkgD////7AAAAHgBkAG8AYwBrAFQAcgBhAG4AcwBpAHQAaQBvAG4AcwEAAAAA/"
"////wAAAJIA////+wAAABYAZABvAGMAawBFAGYAZgBlAGMAdABzAQAAAAD/////AAAAkgD////7AAAAEgBk"
"AG8AYwBrAFYAaQBkAGUAbwEAAAEbAAACTAAAAEcA////+wAAABgAZABvAGMAawBUAGkAbQBlAGwAaQBuAGU"
"BAAAB7QAAARIAAACWAP////wAAANtAAAA2QAAAIIA////+gAAAAECAAAAAvsAAAAiAGQAbwBjAGsAQwBhAH"
"AAdABpAG8AbgBFAGQAaQB0AG8AcgAAAAAA/////wAAAJgA////+wAAABQAZABvAGMAawBFAG0AbwBqAGkAc"
"wEAAADFAAACOgAAAJIA////AAAERgAAAAEAAAABAAAAAgAAAAEAAAAC/AAAAAEAAAACAAAAAQAAAA4AdABv"
"AG8AbABCAGEAcgEAAAAA/////wAAAAAAAAAA"
"AAAA/wAAAAD9AAAAAwAAAAAAAAEnAAAC3/wCAAAAA/wAAAJeAAAApwAAAAAA////+gAAAAACAAAAAfsAAAAYAGQAbwBjAGsASwBlAHkAZgByAGEAbQBlAAAAAAD/////AAAAAAAAAAD7AAAAHABkAG8AYwBrAFAAcgBvAHAAZQByAHQAaQBlAHMAAAAAJwAAAt8AAAChAP////sAAAAYAGQAbwBjAGsAVAB1AHQAbwByAGkAYQBsAgAABUQAAAF6AAABYAAAANwAAAABAAABHAAAAUD8AgAAAAH7AAAAGABkAG8AYwBrAEsAZQB5AGYAcgBhAG0AZQEAAAFYAAAAFQAAAAAAAAAAAAAAAgAABEYAAALC/AEAAAAC/AAAAAAAAARGAAAA+gD////8AgAAAAL8AAAAPQAAAa4AAACvAP////wBAAAAAvwAAAAAAAABwQAAAJcA////+gAAAAACAAAABPsAAAASAGQAbwBjAGsARgBpAGwAZQBzAQAAAAD/////AAAAkgD////7AAAAHgBkAG8AYwBrAFQAcgBhAG4AcwBpAHQAaQBvAG4AcwEAAAAA/////wAAAJIA////+wAAABYAZABvAGMAawBFAGYAZgBlAGMAdABzAQAAAAD/////AAAAkgD////7AAAAFABkAG8AYwBrAEUAbQBvAGoAaQBzAQAAAAD/////AAAAkgD////7AAAAEgBkAG8AYwBrAFYAaQBkAGUAbwEAAAHHAAACfwAAAEcA////+wAAABgAZABvAGMAawBUAGkAbQBlAGwAaQBuAGUBAAAB8QAAAQ4AAACWAP////sAAAAiAGQAbwBjAGsAQwBhAHAAdABpAG8AbgBFAGQAaQB0AG8AcgAAAANtAAAA2QAAAFgA////AAAERgAAAAEAAAABAAAAAgAAAAEAAAAC/AAAAAEAAAACAAAAAQAAAA4AdABvAG8AbABCAGEAcgEAAAAA/////wAAAAAAAAAA"
])
self.restoreState(qt_types.str_to_bytes(simple_state))
QCoreApplication.processEvents()
Expand Down Expand Up @@ -2633,7 +2627,6 @@ def clearSelections(self):

def foundCurrentVersion(self, version):
"""Handle the callback for detecting the current version on openshot.org"""
log.info('foundCurrentVersion: Found the latest version: %s' % version)
_ = get_app()._tr

# Compare versions (alphabetical compare of version strings should work fine)
Expand All @@ -2654,6 +2647,10 @@ def foundCurrentVersion(self, version):
updateButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.toolBar.addWidget(updateButton)

# Initialize sentry exception tracing (now that we know the current version)
from classes import sentry
sentry.init_tracing()

def moveEvent(self, event):
""" Move tutorial dialogs also (if any)"""
QMainWindow.moveEvent(self, event)
Expand Down Expand Up @@ -2823,17 +2820,25 @@ def __init__(self, *args, mode=None):

# Set unique install id (if blank)
if not s.get("unique_install_id"):
# This is assumed to be the 1st launch
s.set("unique_install_id", str(uuid4()))

# Track 1st launch metric
track_metric_screen("initial-launch-screen")

# Track 1st main screen
track_metric_screen("main-screen")

# Opt-out of metrics tracking on 1st launch (and prompt user)
track_metric_screen("metrics-opt-out")
s.set("send_metrics", False)
else:
# Only track main screen
track_metric_screen("main-screen")

# Set unique id for Sentry
sentry.set_user({"id": s.get("unique_install_id")})

# Track main screen
track_metric_screen("main-screen")

# Create blank tutorial manager
self.tutorial_manager = None

Expand Down

0 comments on commit c8b670c

Please sign in to comment.