Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(errors): Make sure project root exists to judge in app frames #136

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading