Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,26 @@ def main():
logger.remove()
configure_logging()

# Sentry 环境与版本号自动识别
environment = "development" if "0.0.0" in VERSION else "production"

def before_send(event, hint):
# 如果事件中不包含异常信息(即没有堆栈),则不上传
if "exception" not in event:
return None
return event

sentry_sdk.init(
dsn="https://f48074b49e319f7b952583c283046259@o4510289605296128.ingest.de.sentry.io/4510681366659152",
integrations=[
LoguruIntegration(
level=LoggingLevels.INFO.value,
event_level=LoggingLevels.ERROR.value,
),
],
before_send=before_send,
environment=environment,
release=VERSION,
send_default_pii=True,
)
# 仅在开发环境(版本号包含 0.0.0)下初始化 Sentry
if "0.0.0" in VERSION:
Comment on lines +41 to +42
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "仅在开发环境(版本号包含 0.0.0)下初始化 Sentry" (Only initialize Sentry in development environment when version contains 0.0.0). While this accurately describes the code, it contradicts standard error monitoring practices where Sentry should be enabled in production to track real-world errors. The PR title "开发环境不上报,上报版本信息" (Development environment does not report, report version information) and the comment suggest intentionally disabling production error reporting, which may not be the desired behavior for effective error monitoring.

Suggested change
# 仅在开发环境(版本号包含 0.0.0)下初始化 Sentry
if "0.0.0" in VERSION:
# 在非开发环境(版本号不包含 0.0.0)下初始化 Sentry
if "0.0.0" not in VERSION:

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +42
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here appears to be inverted. The code now only initializes Sentry when VERSION contains "0.0.0" (development builds), which means error reporting will NOT be active in production builds. Typically, error monitoring systems like Sentry are most valuable in production environments where you need to track real user-facing errors. The condition should likely be inverted to if "0.0.0" not in VERSION: to enable Sentry only in production, or the conditional should be removed entirely to enable it in both environments with different configurations.

Suggested change
# 仅在开发环境(版本号包含 0.0.0)下初始化 Sentry
if "0.0.0" in VERSION:
# 在非开发环境(版本号不包含 0.0.0)下初始化 Sentry
if "0.0.0" not in VERSION:

Copilot uses AI. Check for mistakes.
def before_send(event, hint):
# 如果事件中不包含异常信息(即没有堆栈),则不上传
if "exception" not in event:
return None
return event

sentry_sdk.init(
dsn="https://f48074b49e319f7b952583c283046259@o4510289605296128.ingest.de.sentry.io/4510681366659152",
integrations=[
LoguruIntegration(
level=LoggingLevels.INFO.value,
event_level=LoggingLevels.ERROR.value,
),
],
before_send=before_send,
release=VERSION,
send_default_pii=True,
)

wm.app_start_time = time.perf_counter()

Expand Down
Loading