Skip to content

Commit c573acc

Browse files
committed
在 VERSION 为 "v0.0.0" 时不进行 Sentry 错误上报
1 parent 46848e7 commit c573acc

1 file changed

Lines changed: 21 additions & 19 deletions

File tree

main.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from app.tools.path_utils import get_app_root
1313
from app.tools.config import configure_logging
1414
from app.tools.settings_access import readme_settings_async
15-
from app.tools.variable import APP_QUIT_ON_LAST_WINDOW_CLOSED
15+
from app.tools.variable import APP_QUIT_ON_LAST_WINDOW_CLOSED, VERSION
1616
from app.core.single_instance import (
1717
check_single_instance,
1818
setup_local_server,
@@ -38,24 +38,26 @@ def main():
3838
logger.remove()
3939
configure_logging()
4040

41-
def before_send(event, hint):
42-
# 如果事件中不包含异常信息(即没有堆栈),则不上传
43-
if "exception" not in event:
44-
return None
45-
return event
46-
47-
sentry_sdk.init(
48-
dsn="https://f48074b49e319f7b952583c283046259@o4510289605296128.ingest.de.sentry.io/4510681366659152",
49-
integrations=[
50-
LoguruIntegration(
51-
level=LoggingLevels.INFO.value,
52-
event_level=LoggingLevels.ERROR.value,
53-
),
54-
],
55-
before_send=before_send,
56-
send_default_pii=True,
57-
enable_logs=True,
58-
)
41+
if VERSION != "v0.0.0":
42+
43+
def before_send(event, hint):
44+
# 如果事件中不包含异常信息(即没有堆栈),则不上传
45+
if "exception" not in event:
46+
return None
47+
return event
48+
49+
sentry_sdk.init(
50+
dsn="https://f48074b49e319f7b952583c283046259@o4510289605296128.ingest.de.sentry.io/4510681366659152",
51+
integrations=[
52+
LoguruIntegration(
53+
level=LoggingLevels.INFO.value,
54+
event_level=LoggingLevels.ERROR.value,
55+
),
56+
],
57+
before_send=before_send,
58+
send_default_pii=True,
59+
enable_logs=True,
60+
)
5961

6062
wm.app_start_time = time.perf_counter()
6163

0 commit comments

Comments
 (0)