浏览代码

replace ENABLE_SENTRY by SENTRY_DSN

Son NK 5 年之前
父节点
当前提交
66091b4f9e
共有 5 个文件被更改,包括 9 次插入13 次删除
  1. 2 2
      .env.example
  2. 1 2
      app/config.py
  3. 4 4
      server.py
  4. 2 2
      templates/base.html
  5. 0 3
      tests/env.test

+ 2 - 2
.env.example

@@ -1,8 +1,8 @@
 # Server url
 URL=http://localhost:7777
 
-# Enable sentry
-ENABLE_SENTRY=true
+# If you want to enable sentry for error tracking, put your sentry dsn here.
+# SENTRY_DSN=your_sentry_dsn
 
 # apply colored log
 COLOR_LOG=true

+ 1 - 2
app/config.py

@@ -34,8 +34,7 @@ PROMO_CODE = "SIMPLEISBETTER"
 URL = os.environ["URL"]
 print(">>> URL:", URL)
 
-# Whether sentry is enabled
-ENABLE_SENTRY = "ENABLE_SENTRY" in os.environ
+SENTRY_DSN = os.environ.get("SENTRY_DSN")
 
 # Email related settings
 NOT_SEND_EMAIL = "NOT_SEND_EMAIL" in os.environ

+ 4 - 4
server.py

@@ -17,7 +17,7 @@ from app.auth.base import auth_bp
 from app.config import (
     DB_URI,
     FLASK_SECRET,
-    ENABLE_SENTRY,
+    SENTRY_DSN,
     URL,
     SHA1,
     PADDLE_MONTHLY_PRODUCT_ID,
@@ -42,10 +42,10 @@ from app.models import (
 from app.monitor.base import monitor_bp
 from app.oauth.base import oauth_bp
 
-if ENABLE_SENTRY:
+if SENTRY_DSN:
     LOG.d("enable sentry")
     sentry_sdk.init(
-        dsn="https://ad2187ed843340a1b4165bd8d5d6cdce@sentry.io/1478143",
+        dsn=SENTRY_DSN,
         integrations=[FlaskIntegration()],
     )
 
@@ -260,7 +260,7 @@ def jinja2_filter(app):
     @app.context_processor
     def inject_stage_and_region():
         return dict(
-            YEAR=arrow.now().year, URL=URL, ENABLE_SENTRY=ENABLE_SENTRY, VERSION=SHA1
+            YEAR=arrow.now().year, URL=URL, SENTRY_DSN=SENTRY_DSN, VERSION=SHA1
         )
 
 

+ 2 - 2
templates/base.html

@@ -92,10 +92,10 @@
 </div>
 
 <script>
-  {% if ENABLE_SENTRY %}
+  {% if SENTRY_DSN %}
     console.log("Init sentry");
     try {
-      Sentry.init({dsn: 'https://ad2187ed843340a1b4165bd8d5d6cdce@sentry.io/1478143'});
+      Sentry.init({dsn: '{{SENTRY_DSN}}'});
     } catch (error) {
       console.log("Sentry error, probably due to AdBlocker ...")
     }

+ 0 - 3
tests/env.test

@@ -1,9 +1,6 @@
 # Server url
 URL=http://localhost
 
-# Enable sentry
-# ENABLE_SENTRY=true
-
 # Email related settings
 # Only print email content, not sending it
 NOT_SEND_EMAIL=true