|
21 | 21 | import os |
22 | 22 |
|
23 | 23 | import pymysql |
| 24 | +import sentry_sdk |
24 | 25 | from celery import Celery |
25 | 26 | from dotenv import load_dotenv |
26 | 27 | from flask import Flask |
|
32 | 33 | from PyMatcha.utils.tables import create_tables |
33 | 34 | from pymysql.cursors import DictCursor |
34 | 35 | from redis import StrictRedis |
| 36 | +from sentry_sdk import configure_scope |
| 37 | +from sentry_sdk.integrations.flask import FlaskIntegration |
| 38 | + |
35 | 39 |
|
36 | 40 | PYMATCHA_ROOT = os.path.join(os.path.dirname(__file__), "../..") # refers to application_top |
37 | 41 | dotenv_path = os.path.join(PYMATCHA_ROOT, ".env") |
|
79 | 83 | if ENABLE_LOGGING == "True": |
80 | 84 | setup_logging() |
81 | 85 |
|
| 86 | +sentry_sdk.init( |
| 87 | + dsn="https://bb17c14c99d448e2804bf2f105d4ec52@o450203.ingest.sentry.io/5434438", |
| 88 | + integrations=[FlaskIntegration()], |
| 89 | + traces_sample_rate=1.0, |
| 90 | +) |
| 91 | + |
| 92 | + |
82 | 93 | application = Flask(__name__) |
83 | 94 |
|
84 | 95 | if os.getenv("FLASK_DEBUG", "false") == "true" or os.getenv("FLASK_DEBUG", "false") == "1": |
@@ -183,6 +194,9 @@ def jwt_user_callback(identity): |
183 | 194 | except NotFoundError: |
184 | 195 | # The user who the server issues the token for was deleted in the db. |
185 | 196 | return None |
| 197 | + |
| 198 | + with configure_scope() as scope: |
| 199 | + scope.user = {"email": u.email, "id": u.id, "username": u.username} |
186 | 200 | redis.set("online_user:" + str(identity["id"]), datetime.datetime.utcnow().timestamp()) |
187 | 201 | return u |
188 | 202 |
|
|
0 commit comments