Skip to content

Commit

Permalink
fix(errors): Make sure project root exists to judge in app frames (#136)
Browse files Browse the repository at this point in the history
* fix(errors): Make sure project root exists to judge in app frames

* prep release
  • Loading branch information
neilkakkar authored Sep 16, 2024
1 parent 1521621 commit 67a343f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.6.6 - 2024-09-16

1. Fix manual capture support for in app frames

## 3.6.5 - 2024-09-10

1. Fix django integration support for manual exception capture.
Expand Down
2 changes: 2 additions & 0 deletions posthog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
# Currently alpha, use at your own risk
enable_exception_autocapture = False # type: bool
exception_autocapture_integrations = [] # type: List[Integrations]
# Used to determine in app paths for exception autocapture. Defaults to the current working directory
project_root = None # type: Optional[str]

default_client = None # type: Optional[Client]

Expand Down
13 changes: 12 additions & 1 deletion posthog/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import atexit
import logging
import numbers
import os
import sys
from datetime import datetime, timedelta
from uuid import UUID
Expand Down Expand Up @@ -56,6 +57,7 @@ def __init__(
feature_flags_request_timeout_seconds=3,
enable_exception_autocapture=False,
exception_autocapture_integrations=None,
project_root=None,
):
self.queue = queue.Queue(max_queue_size)

Expand Down Expand Up @@ -88,6 +90,14 @@ def __init__(
self.exception_autocapture_integrations = exception_autocapture_integrations
self.exception_capture = None

if project_root is None:
try:
project_root = os.getcwd()
except Exception:
project_root = None

self.project_root = project_root

# personal_api_key: This should be a generated Personal API Key, private
self.personal_api_key = personal_api_key
if debug:
Expand Down Expand Up @@ -382,7 +392,8 @@ def capture_exception(
"exception": {
"values": all_exceptions_with_trace,
},
}
},
project_root=self.project_root,
)
all_exceptions_with_trace_and_in_app = event["exception"]["values"]

Expand Down
1 change: 1 addition & 0 deletions posthog/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def test_basic_capture_exception_with_no_exception_given(self):
self.assertEqual(
capture_call[2]["$exception_list"][0]["stacktrace"]["frames"][0]["module"], "posthog.test.test_client"
)
self.assertEqual(capture_call[2]["$exception_list"][0]["stacktrace"]["frames"][0]["in_app"], True)

def test_basic_capture_exception_with_no_exception_happening(self):

Expand Down
2 changes: 1 addition & 1 deletion posthog/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "3.6.5"
VERSION = "3.6.6"

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

0 comments on commit 67a343f

Please sign in to comment.