浏览代码

use another sentry project for the front-end using SENTRY_FRONT_END_DSN param

Son NK 5 年之前
父节点
当前提交
ec248dcae6
共有 3 个文件被更改,包括 14 次插入1 次删除
  1. 3 0
      app/config.py
  2. 4 0
      example.env
  3. 7 1
      server.py

+ 3 - 0
app/config.py

@@ -39,6 +39,9 @@ print(">>> URL:", URL)
 
 SENTRY_DSN = os.environ.get("SENTRY_DSN")
 
+# can use another sentry project for the front-end to avoid noises
+SENTRY_FRONT_END_DSN = os.environ.get("SENTRY_FRONT_END_DSN") or SENTRY_DSN
+
 # Email related settings
 NOT_SEND_EMAIL = "NOT_SEND_EMAIL" in os.environ
 EMAIL_DOMAIN = os.environ["EMAIL_DOMAIN"]

+ 4 - 0
example.env

@@ -4,6 +4,10 @@ URL=http://localhost:7777
 # If you want to enable sentry for error tracking, put your sentry dsn here.
 # SENTRY_DSN=your_sentry_dsn
 
+# Possible to use another sentry project for the front-end to avoid noises
+# If not set, fallback to SENTRY_DSN
+# SENTRY_FRONT_END_DSN=your_sentry_dsn
+
 # apply colored log to facilitate local development
 # COLOR_LOG=true
 

+ 7 - 1
server.py

@@ -28,6 +28,7 @@ from app.config import (
     RESET_DB,
     FLASK_PROFILER_PATH,
     FLASK_PROFILER_PASSWORD,
+    SENTRY_FRONT_END_DSN,
 )
 from app.dashboard.base import dashboard_bp
 from app.developer.base import developer_bp
@@ -301,7 +302,12 @@ def jinja2_filter(app):
 
     @app.context_processor
     def inject_stage_and_region():
-        return dict(YEAR=arrow.now().year, URL=URL, SENTRY_DSN=SENTRY_DSN, VERSION=SHA1)
+        return dict(
+            YEAR=arrow.now().year,
+            URL=URL,
+            SENTRY_DSN=SENTRY_FRONT_END_DSN,
+            VERSION=SHA1,
+        )
 
 
 def setup_paddle_callback(app: Flask):