Skip to content

Commit

Permalink
Adding sentry error rates on our openshot.org version request... so w…
Browse files Browse the repository at this point in the history
…e can adjust them dynamically (stable vs unstable versions).
  • Loading branch information
jonoomph committed Aug 19, 2021
1 parent 7c83cf0 commit 3ab16f2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
11 changes: 11 additions & 0 deletions src/classes/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@
CURRENT_LANGUAGE = 'en_US'
SUPPORTED_LANGUAGES = ['en_US']

# Sentry.io error reporting rate (0.0 TO 1.0)
# 0.0 = no error reporting to Sentry
# 0.5 = 1/2 of errors reported to Sentry
# 1.0 = all errors reporting to Sentry
# STABLE: If this version matches the current version (reported on openshot.org)
# UNSTABLE: If this version does not match the current version (reported on openshot.org)
# STABLE_VERSION: This is the current stable release reported by openshot.org
ERROR_REPORT_RATE_STABLE = 0.0
ERROR_REPORT_RATE_UNSTABLE = 0.0
ERROR_REPORT_STABLE_VERSION = None

try:
from language import openshot_lang
language_path = ":/locale/"
Expand Down
17 changes: 11 additions & 6 deletions src/classes/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import platform

from classes.logger import log
from classes import info

try:
Expand All @@ -47,12 +48,16 @@ def init_tracing():
return

# Determine sample rate for exceptions
traces_sample_rate = 0.1
environment = "production"
if "-dev" in info.VERSION:
# Dev mode, trace all exceptions
traces_sample_rate = 1.0
environment = "development"
traces_sample_rate = 0.0
if info.VERSION == info.ERROR_REPORT_STABLE_VERSION:
traces_sample_rate = info.ERROR_REPORT_RATE_STABLE
environment = "production"
else:
traces_sample_rate = info.ERROR_REPORT_RATE_UNSTABLE
environment = "unstable"

if info.ERROR_REPORT_STABLE_VERSION:
log.info("Sentry initialized with %s error reporting rate (%s)" % (traces_sample_rate, environment))

# Initialize sentry exception tracing
sdk.init(
Expand Down
9 changes: 6 additions & 3 deletions src/classes/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from classes.app import get_app
from classes import info
from classes.logger import log
import json


def get_current_Version():
"""Get the current version """
Expand All @@ -46,10 +46,13 @@ def get_version_from_http():
# Send metric HTTP data
try:
r = requests.get(url, headers={"user-agent": "openshot-qt-%s" % info.VERSION}, verify=False)
log.info("Found current version: %s" % r.text)
log.info("Found current version: %s" % r.json())

# Parse version
openshot_version = r.json()["openshot_version"]
openshot_version = r.json().get("openshot_version")
info.ERROR_REPORT_STABLE_VERSION = r.json().get("openshot_version")
info.ERROR_REPORT_RATE_STABLE = r.json().get("error_rate_stable")
info.ERROR_REPORT_RATE_UNSTABLE = r.json().get("error_rate_unstable")

# Emit signal for the UI
get_app().window.FoundVersionSignal.emit(openshot_version)
Expand Down

0 comments on commit 3ab16f2

Please sign in to comment.