Skip to content

Feat/error tracking#352

Open
kdh29 wants to merge 7 commits intomainfrom
feat/error-tracking
Open

Feat/error tracking#352
kdh29 wants to merge 7 commits intomainfrom
feat/error-tracking

Conversation

@kdh29
Copy link
Contributor

@kdh29 kdh29 commented Feb 24, 2026

This branch adds full front and backend error tracking through posthog which is hosted on https://e.thoughtful-ai.com/. Additionally this contains the smoke test which is a backend test that ensures environment variables wont crash the production server. While this shouldn't break anything if it is merged beforehand, posthog will NOT work if the api key isnt added into the jenkins server secrets.

closes issue #13

claude and others added 7 commits February 10, 2026 08:03
Implements PostHog error tracking that gracefully degrades when
POSTHOG_API_KEY is not set (unlike the previous attempt that crashed).

Backend:
- Add posthog_client.py module with capture_exception() and capture_event()
- Add error tracking middleware for unhandled exceptions
- Add exception handlers for validation errors and general exceptions
- Add /api/test-error endpoint for verification

Frontend:
- Add PostHogProvider and PostHogErrorBoundary wrappers
- Conditionally enable based on POSTHOG_KEY environment variable
- Add error fallback UI component

Configuration:
- Backend: POSTHOG_API_KEY, POSTHOG_HOST environment variables
- Frontend: POSTHOG_KEY, POSTHOG_HOST via webpack DefinePlugin

TODO: Set real PostHog API keys in production environment.

https://claude.ai/code/session_01Kz3yVbDK5FfzfXiLKnFLXW
So the professor just needs to add POSTHOG_API_KEY and POSTHOG_KEY
to the .env file — no code changes needed to enable error tracking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kdh29 kdh29 requested a review from kcarnold February 24, 2026 03:09
@Alina086
Copy link
Contributor

Do you mean issue #13? #303 is just your previous PR looks like.

Copy link
Contributor

@kcarnold kcarnold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking generally good. I'll get the key in the Jenkins cert store, but you should include a patch to Jenkinsfile to get that key injected.

exc_type = type(exception).__name__
exc_message = str(exception)
exc_traceback = "".join(
traceback.format_exception(type(exception), exception, exception.__traceback__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have to do all this? isn't this stuff builtin to Posthog? ("exception autocapture"?)

@kcarnold
Copy link
Contributor

Actually the "project token" is "safe to use in public apps" so we can just commit it here.

When we upload sourcemaps, we'll need a "personal API key" that has some additional permissions (so should be separate from the key that we distribute publicly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants