Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cura/CrashHandler.py16
-rwxr-xr-xcura_app.py4
-rw-r--r--plugins/SentryLogger/SentryLogger.py13
3 files changed, 23 insertions, 10 deletions
diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py
index e72180887c..3cfbab2551 100644
--- a/cura/CrashHandler.py
+++ b/cura/CrashHandler.py
@@ -32,6 +32,8 @@ from UM.Resources import Resources
from cura import ApplicationMetadata
catalog = i18nCatalog("cura")
+home_dir = os.path.expanduser("~")
+
MYPY = False
if MYPY:
@@ -83,6 +85,20 @@ class CrashHandler:
self.dialog = QDialog()
self._createDialog()
+ @staticmethod
+ def pruneSensitiveData(obj):
+ if type(obj) is list:
+ return [CrashHandler.pruneSensitiveData(item) for item in obj]
+ if type(obj) is dict:
+ return {k: CrashHandler.pruneSensitiveData(v) for k, v in obj.items()}
+ if type(obj) is str:
+ return obj.replace(home_dir, "<user_home>")
+ return obj
+
+ @staticmethod
+ def sentry_before_send(event, hint):
+ return CrashHandler.pruneSensitiveData(event)
+
def _createEarlyCrashDialog(self):
dialog = QDialog()
dialog.setMinimumWidth(500)
diff --git a/cura_app.py b/cura_app.py
index a8fe708c5f..fba136516c 100755
--- a/cura_app.py
+++ b/cura_app.py
@@ -11,6 +11,7 @@ import sys
from UM.Platform import Platform
from cura import ApplicationMetadata
from cura.ApplicationMetadata import CuraAppName
+from cura.CrashHandler import CrashHandler
try:
import sentry_sdk
@@ -42,8 +43,9 @@ if with_sentry_sdk:
sentry_env = "nightly"
except IndexError:
pass
-
+
sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564",
+ before_send = CrashHandler.sentry_before_send,
environment = sentry_env,
release = "cura%s" % ApplicationMetadata.CuraVersion,
default_integrations = False,
diff --git a/plugins/SentryLogger/SentryLogger.py b/plugins/SentryLogger/SentryLogger.py
index 31ab38b6e2..51e77ad589 100644
--- a/plugins/SentryLogger/SentryLogger.py
+++ b/plugins/SentryLogger/SentryLogger.py
@@ -3,6 +3,9 @@
from UM.Logger import LogOutput
from typing import Set
+
+from cura.CrashHandler import CrashHandler
+
try:
from sentry_sdk import add_breadcrumb
except ImportError:
@@ -10,8 +13,6 @@ except ImportError:
from typing import Optional
import os
-home_dir = os.path.expanduser("~")
-
class SentryLogger(LogOutput):
# Sentry (https://sentry.io) is the service that Cura uses for logging crashes. This logger ensures that the
@@ -37,7 +38,7 @@ class SentryLogger(LogOutput):
# \param message String containing message to be logged
def log(self, log_type: str, message: str) -> None:
level = self._translateLogType(log_type)
- message = self._pruneSensitiveData(message)
+ message = CrashHandler.pruneSensitiveData(message)
if level is None:
if message not in self._show_once:
level = self._translateLogType(log_type[0])
@@ -48,11 +49,5 @@ class SentryLogger(LogOutput):
add_breadcrumb(level = level, message = message)
@staticmethod
- def _pruneSensitiveData(message):
- if home_dir in message:
- message = message.replace(home_dir, "<user_home>")
- return message
-
- @staticmethod
def _translateLogType(log_type: str) -> Optional[str]:
return SentryLogger._levels.get(log_type)