Skip to content

Commit

Permalink
Add Sentry (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahanneda authored Aug 19, 2024
1 parent c40e5ca commit c7fe515
Show file tree
Hide file tree
Showing 11 changed files with 20,278 additions and 41 deletions.
34 changes: 24 additions & 10 deletions backend/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime, timezone
import sentry_sdk
import os
import re
import firebase_admin
Expand Down Expand Up @@ -43,6 +44,21 @@


def create_app(config_name):
print("Environment is", config_name)
if config_name != "testing":
sentry_sdk.init(
dsn="https://85a9bf2fc71b287cc4e60cb9f918f034@o4507682847850496.ingest.us.sentry.io/4507801405227008",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
# Config name is either development or testing or production
environment=config_name,
send_default_pii=True,
)
dictConfig(
{
"version": 1,
Expand All @@ -66,17 +82,15 @@ def create_app(config_name):

app = Flask(__name__, template_folder="templates", static_folder="static")
# do not read config object if creating app from Flask CLI (e.g. flask db migrate)
print("right before entering config setup ")
print("type config name", type(config_name))
# if type(config_name) is not ScriptInfo:
print("Right before reading config object right now!")
print("At this time the env vars are: ")
print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
print("MG_DB_NAME:", os.getenv("MG_DB_NAME"))
print("config name is", config_name)
print("app config is", app_config)
# print("Right before reading config object right now!")
# print("At this time the env vars are: ")
# print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
# print("MG_DB_NAME:", os.getenv("MG_DB_NAME"))
# print("config name is", config_name)
# print("app config is", app_config)
app.config.from_object(app_config[config_name])
print("Now, app.config is", app.config)
# print("Now, app.config is", app.config)
app.add_url_rule(
"/graphql",
view_func=GraphQLView.as_view(
Expand All @@ -98,7 +112,7 @@ def create_app(config_name):
for env_var in required_env_vars:
not_found_one = False
missing = []
print(f"variable: {env_var} is {os.getenv(env_var)}")
# print(f"variable: {env_var} is {os.getenv(env_var)}")
if (env_var not in os.environ or os.getenv(env_var) is None) and not app.config[
"TESTING"
]:
Expand Down
9 changes: 4 additions & 5 deletions backend/app/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys


class Config(object):
Expand All @@ -9,10 +8,10 @@ class Config(object):

# put any configurations here that are common across all environments
# list of available configs: https://flask.palletsprojects.com/en/1.1.x/config/
print("running thiS in config!")
print("python version", sys.version)
print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
print("MG_DB_NAME:", os.getenv("MG_DB_NAME"))
# print("running thiS in config!")
# print("python version", sys.version)
# print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
# print("MG_DB_NAME:", os.getenv("MG_DB_NAME"))

MONGODB_URL = os.getenv("MG_DATABASE_URL")
MONGODB_DB_NAME = os.getenv("MG_DB_NAME")
Expand Down
6 changes: 1 addition & 5 deletions backend/app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ def init_app(app):
if "USE_MONGOMOCK_CLIENT" in app.config
else pymongo.MongoClient
)
print("doing this!!")
print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
# print("MG_DATABASE_URL:", os.getenv("MG_DATABASE_URL"))
# print("app.config mgdb url", app.config["MONGODB_URL"])
# print("app.config mg db name", app.config["MONGODB_DB_NAME"])
print("app.config", app.config)
print("mongodb url in", "MONGODB_URL" in app.config)
print("mongodb db name in", "MONGODB_DB_NAME" in app.config)
if "MONGODB_URL" in app.config and "MONGODB_DB_NAME" in app.config:
connect(
host=app.config["MONGODB_URL"],
Expand Down
7 changes: 4 additions & 3 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ python-dotenv==0.15.0
python-editor==1.0.4
pytz==2021.1
regex==2020.11.13
requests==2.25.1
requests==2.32.3
rsa==4.7.2
sentinels==1.0.0
six==1.15.0
Expand All @@ -78,8 +78,9 @@ toml==0.10.2
typed-ast==1.5.4
typing-extensions==4.3.0
uritemplate==3.0.1
urllib3==1.26.4
urllib3==1.26.16
Werkzeug==1.0.1
zipp==3.4.1
tzlocal==5.2
freezegun==1.5.1
freezegun==1.5.1
sentry-sdk==2.13.0
3 changes: 3 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Sentry Config File
.sentryclirc
Loading

0 comments on commit c7fe515

Please sign in to comment.