Skip to content

Commit da09639

Browse files
authored
fix: capture django processed exceptions (#287)
1 parent 6a27102 commit da09639

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 6.1.1 - 2025-07-16
2+
3+
- fix: correctly capture exceptions processed by Django from views or middleware
4+
15
# 6.1.0 - 2025-07-10
26

37
- feat: decouple feature flag local evaluation from personal API keys; support decrypting remote config payloads without relying on the feature flags poller
@@ -21,12 +25,14 @@
2125
# 6.0.0
2226

2327
This release contains a number of major breaking changes:
28+
2429
- feat: make distinct_id an optional parameter in posthog.capture and related functions
2530
- feat: make capture and related functions return `Optional[str]`, which is the UUID of the sent event, if it was sent
2631
- fix: remove `identify` (prefer `posthog.set()`), and `page` and `screen` (prefer `posthog.capture()`)
2732
- fix: delete exception-capture specific integrations module. Prefer the general-purpose django middleware as a replacement for the django `Integration`.
2833

2934
To migrate to this version, you'll mostly just need to switch to using named keyword arguments, rather than positional ones. For example:
35+
3036
```python
3137
# Old calling convention
3238
posthog.capture("user123", "button_clicked", {"button_id": "123"})

posthog/integrations/django.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import TYPE_CHECKING, cast
2-
from posthog import contexts
2+
from posthog import contexts, capture_exception
33
from posthog.client import Client
44

55
if TYPE_CHECKING:
@@ -167,3 +167,15 @@ def __call__(self, request):
167167
contexts.tag(k, v)
168168

169169
return self.get_response(request)
170+
171+
def process_exception(self, request, exception):
172+
if self.request_filter and not self.request_filter(request):
173+
return
174+
175+
if not self.capture_exceptions:
176+
return
177+
178+
if self.client:
179+
self.client.capture_exception(exception)
180+
else:
181+
capture_exception(exception)

posthog/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = "6.1.0"
1+
VERSION = "6.1.1"
22

33
if __name__ == "__main__":
44
print(VERSION, end="") # noqa: T201

uv.lock

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)