Merged
Conversation
Contributor
There was a problem hiding this comment.
PR Summary
This PR adds a new configuration option log_captured_exceptions to the PostHog Python SDK, allowing exceptions captured via capture_exception to be logged locally in addition to being sent to PostHog.
- Added
log_captured_exceptionsboolean parameter toClientclass constructor with default value ofFalse - Implemented logging logic in
capture_exceptionmethod to log exceptions with additional context when enabled - Added
**kwargsparameter to module-levelcapture_exceptionfunction to pass through additional context - Added test case
test_capture_exception_logs_when_enabledto verify logging behavior - Updated version from 3.23.0 to 3.24.0 in
version.pyand documented the feature inCHANGELOG.md
5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Contributor
Author
|
Currently blocked by failing tests. Fix in #216 |
timgl
approved these changes
Apr 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
log_captured_exceptionsconfig option so that all$exceptionevents can also be loggedThis is useful internally to capture exceptions if our own product is unavailable.
We have a version of this already in https://github.com/PostHog/posthog/blob/c2c65827b31b13c8e2e84d4ddc33df34b5924487/posthog/exceptions.py#L58-L66 but that only applies to DFR views.
By doing this at the SDK level we can log any exception that is being captured. One difference is that the logger in the SDK is not structured but I think that's ok