From 67894c37ae3b73b7d602b7521b05d65cbc49ef30 Mon Sep 17 00:00:00 2001 From: NickJ-7010 Date: Wed, 30 Sep 2026 22:48:36 -0400 Subject: [PATCH 1/3] fix: Disable sentry based on if in local development or not --- conditional/__init__.py | 11 ++++++----- frontend/javascript/app.js | 21 ++++++++++++--------- package-lock.json | 17 +++++++++++++++++ package.json | 1 + webpack.config.js | 6 +++++- 5 files changed, 41 insertions(+), 15 deletions(-) diff --git a/conditional/__init__.py b/conditional/__init__.py index c2644948..c5883f4a 100644 --- a/conditional/__init__.py +++ b/conditional/__init__.py @@ -39,11 +39,12 @@ ) # Sentry setup -sentry_sdk.init( - dsn=app.config['SENTRY_DSN'], - integrations=[FlaskIntegration(), SqlalchemyIntegration()], - environment=app.config['SENTRY_ENV'], -) +if app.config['SENTRY_ENV'] != "local-development": + sentry_sdk.init( + dsn=app.config['SENTRY_DSN'], + integrations=[FlaskIntegration(), SqlalchemyIntegration()], + environment=app.config['SENTRY_ENV'], + ) ldap = CSHLDAP(app.config['LDAP_BIND_DN'], app.config['LDAP_BIND_PW'], diff --git a/frontend/javascript/app.js b/frontend/javascript/app.js index 28de75e4..54a50d12 100644 --- a/frontend/javascript/app.js +++ b/frontend/javascript/app.js @@ -1,15 +1,18 @@ // Install Sentry to send errors to Sentry import * as Sentry from '@sentry/browser'; -Sentry.init( - { - dsn: 'https://151ecfab1a8242009012d45a19064cfd@sentry.io/133175' - } -); -// Capture unhandled exceptions in promises -window.addEventListener('unhandledrejection', err => { - Sentry.captureException(err.reason); -}); +if (process.env.SENTRY_ENV !== "local-development") { + Sentry.init( + { + dsn: 'https://151ecfab1a8242009012d45a19064cfd@sentry.io/133175' + } + ); + + // Capture unhandled exceptions in promises + window.addEventListener('unhandledrejection', err => { + Sentry.captureException(err.reason); + }); +} // Load the rest of the modules import "jquery"; diff --git a/package-lock.json b/package-lock.json index b33f83ad..9428be90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,7 @@ "bootstrap-icons": "^1.13.1", "copy-webpack-plugin": "^14.0.0", "css-loader": "^7.1.4", + "dotenv": "^18.0.5", "eslint-config-google": "^0.14.0", "expose-loader": "^5.0.1", "imports-loader": "^5.0.0", @@ -3270,6 +3271,22 @@ "node": ">=0.10" } }, + "node_modules/dotenv": { + "version": "18.0.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.5.tgz", + "integrity": "sha512-aBrGvt6KhjxbEnatqMWOMidftwsrCiCvqh1yNIGB9QyF0J+VcWkKDMsvYOEm7ZS82oiV+BT1sTOtIlAmUlTpwQ==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "dotenv": "dist/index.cjs" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dropzone": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/dropzone/-/dropzone-5.9.3.tgz", diff --git a/package.json b/package.json index c916305f..4c0264bd 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "bootstrap-icons": "^1.13.1", "copy-webpack-plugin": "^14.0.0", "css-loader": "^7.1.4", + "dotenv": "^18.0.5", "eslint-config-google": "^0.14.0", "expose-loader": "^5.0.1", "imports-loader": "^5.0.0", diff --git a/webpack.config.js b/webpack.config.js index f184daee..c0a8ca85 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,11 +2,14 @@ const webpack = require('webpack'); const CopyPlugin = require('copy-webpack-plugin') const path = require('path'); const sass = require('sass'); +const dotenv = require('dotenv'); var jsSrc = path.resolve('./frontend'); var jsDest = path.resolve('./conditional/static'); var publicPath = 'static/js'; +dotenv.config(); + var babelQuery = { "presets": ["@babel/preset-env"], "plugins": [] @@ -25,7 +28,8 @@ var webpackConfig = { plugins: [ new webpack.DefinePlugin({ 'process.env': { - 'NODE_ENV': JSON.stringify('production') + 'NODE_ENV': JSON.stringify('production'), + 'SENTRY_ENV': JSON.stringify(process.env.CONDITIONAL_SENTRY_ENV || "local-development") } }), new CopyPlugin({ From 42dd6f3f1d6c489dd6925835e9352e0dd92e20b4 Mon Sep 17 00:00:00 2001 From: NickJ-7010 Date: Fri, 2 Oct 2026 14:32:20 -0400 Subject: [PATCH 2/3] fix: Make SENTRY_ENV variable only default on null --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index c0a8ca85..b2e0b6db 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,7 +29,7 @@ var webpackConfig = { new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production'), - 'SENTRY_ENV': JSON.stringify(process.env.CONDITIONAL_SENTRY_ENV || "local-development") + 'SENTRY_ENV': JSON.stringify(process.env.CONDITIONAL_SENTRY_ENV ?? "local-development") } }), new CopyPlugin({ From e24ad7c1c0b6dc1495eedd078687671f98bea5ee Mon Sep 17 00:00:00 2001 From: NickJ-7010 Date: Fri, 2 Oct 2026 14:34:10 -0400 Subject: [PATCH 3/3] docs: Document the changes to how Sentry is enabled --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6dfd4846..fc01d576 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ AWS_ACCESS_KEY_ID = env.get("AWS_ACCESS_KEY_ID", "") AWS_SECRET_ACCESS_KEY = env.get("AWS_SECRET_ACCESS_KEY", "") ``` -### Database +### Database You can either develop using the dev database, or use the local database provided in the docker compose file Using the local database is detailed below, but both options will require the dev database password, so you will have to ask an RTP for this too @@ -106,6 +106,10 @@ Using the local database is detailed below, but both options will require the de ### Forcing evals/rtp or anything else All of the role checking is done in `conditional/utils/user_dict.py`, and you can change the various functions to `return True` for debugging +### Using Sentry +If you want to opt-into logging errors through Sentry then set the `CONDITIONAL_SENTRY_ENV` environment variable to anything other than `local-development`. +Setting it to `local-development` or having the environment variable unset disables Sentry in both the frontend and backend (Re-building the container may be required). + ## Dependencies