From 26ae319815c0492e6984dd92688ad0ca82e02c85 Mon Sep 17 00:00:00 2001 From: rob Date: Wed, 31 Dec 2025 23:20:11 -0400 Subject: [PATCH] Add Sentry error monitoring and fix accessibility issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sentry integration: - Add sentry-sdk[flask] to registry dependencies - Initialize Sentry with Flask integration (if SENTRY_DSN is set) - Configure trace/profile sampling rates via environment variables - Privacy-first: send_default_pii=False Accessibility fixes (WCAG 2.0 AA compliance): - Add aria-label to search input - Add label and aria-label to essential cookies checkbox - Fix color contrast issues: - $ prompt: text-gray-400 → text-gray-600 - Version numbers: text-gray-400 → text-gray-600 - Tutorial button: text-cyan-600 → text-cyan-700 - Step labels: text-indigo-500 → text-indigo-700 - Footer text: text-gray-500 → text-gray-300 (on dark bg) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- pyproject.toml | 2 ++ src/smarttools/web/app.py | 18 ++++++++++++++++++ .../templates/components/consent_banner.html | 4 ++-- .../web/templates/components/footer.html | 2 +- .../web/templates/components/header.html | 1 + .../web/templates/components/tool_card.html | 2 +- .../templates/components/tutorial_card.html | 2 +- src/smarttools/web/templates/pages/index.html | 4 ++-- 8 files changed, 28 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bfc1011..629f7e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,11 +46,13 @@ dev = [ registry = [ "Flask>=2.3", "argon2-cffi>=21.0", + "sentry-sdk[flask]>=1.0", ] all = [ "urwid>=2.1.0", "Flask>=2.3", "argon2-cffi>=21.0", + "sentry-sdk[flask]>=1.0", ] [project.scripts] diff --git a/src/smarttools/web/app.py b/src/smarttools/web/app.py index 10e2c5f..797ac69 100644 --- a/src/smarttools/web/app.py +++ b/src/smarttools/web/app.py @@ -7,6 +7,24 @@ import secrets from flask import Flask, render_template, session +# Initialize Sentry before importing Flask app (if DSN is configured) +_sentry_dsn = os.environ.get("SENTRY_DSN") +if _sentry_dsn: + try: + import sentry_sdk + from sentry_sdk.integrations.flask import FlaskIntegration + + sentry_sdk.init( + dsn=_sentry_dsn, + integrations=[FlaskIntegration()], + traces_sample_rate=float(os.environ.get("SENTRY_TRACES_RATE", "0.1")), + profiles_sample_rate=float(os.environ.get("SENTRY_PROFILES_RATE", "0.1")), + environment=os.environ.get("SMARTTOOLS_ENV", "development"), + send_default_pii=False, # Privacy: don't send user IPs, emails, etc. + ) + except ImportError: + pass # sentry-sdk not installed + from smarttools.registry import app as registry_app from . import web_bp diff --git a/src/smarttools/web/templates/components/consent_banner.html b/src/smarttools/web/templates/components/consent_banner.html index eec47b8..dadaeb1 100644 --- a/src/smarttools/web/templates/components/consent_banner.html +++ b/src/smarttools/web/templates/components/consent_banner.html @@ -61,10 +61,10 @@
-

Essential cookies

+

Required for the website to function properly.

- +
diff --git a/src/smarttools/web/templates/components/footer.html b/src/smarttools/web/templates/components/footer.html index e5f9684..757ebac 100644 --- a/src/smarttools/web/templates/components/footer.html +++ b/src/smarttools/web/templates/components/footer.html @@ -51,7 +51,7 @@

© {{ now().year }} SmartTools. Open source under MIT License.

-

+

Made with care for the developer community.

diff --git a/src/smarttools/web/templates/components/header.html b/src/smarttools/web/templates/components/header.html index ace903f..df54c6b 100644 --- a/src/smarttools/web/templates/components/header.html +++ b/src/smarttools/web/templates/components/header.html @@ -166,6 +166,7 @@ diff --git a/src/smarttools/web/templates/components/tool_card.html b/src/smarttools/web/templates/components/tool_card.html index 83c1b95..1bc1a61 100644 --- a/src/smarttools/web/templates/components/tool_card.html +++ b/src/smarttools/web/templates/components/tool_card.html @@ -47,7 +47,7 @@ {{ tool.downloads|default(0) }} downloads - v{{ tool.version }} + v{{ tool.version }} diff --git a/src/smarttools/web/templates/components/tutorial_card.html b/src/smarttools/web/templates/components/tutorial_card.html index 4997c87..619f447 100644 --- a/src/smarttools/web/templates/components/tutorial_card.html +++ b/src/smarttools/web/templates/components/tutorial_card.html @@ -30,7 +30,7 @@