Skip to content
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 @@
## 4.6.2 - 2025-06-09

- fix: replace `import posthog` with direct method imports

## 4.6.1 - 2025-06-09

- fix: replace `import posthog` in `posthoganalytics` package
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ release_analytics:
cp -r posthog/* posthoganalytics/
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthog /from posthoganalytics /g' {} \;
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthog\./from posthoganalytics\./g' {} \;
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/import posthog/import posthoganalytics/g' {} \;
find ./posthoganalytics -name "*.bak" -delete
rm -rf posthog
python setup_analytics.py sdist bdist_wheel
twine upload dist/*
mkdir posthog
Comment on lines 22 to 25
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Removing and recreating 'posthog' directory between operations could lead to issues if twine upload fails. Consider moving directory operations after successful upload.

find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthoganalytics /from posthog /g' {} \;
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthoganalytics\./from posthog\./g' {} \;
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/import posthoganalytics/import posthog/g' {} \;
find ./posthoganalytics -name "*.bak" -delete
cp -r posthoganalytics/* posthog/
rm -rf posthoganalytics
Expand Down
4 changes: 2 additions & 2 deletions posthog/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def new_context(fresh=False):
raise ValueError("Something went wrong")

"""
import posthog
Copy link
Member

Choose a reason for hiding this comment

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

would be cool if we can have ruff forbid this in future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. ChatGPT is down right now and I'm having trouble googling for the right rule. Will double back

from posthog import capture_exception

current_tags = _get_current_context().copy()
current_stack = _context_stack.get()
Expand All @@ -49,7 +49,7 @@ def new_context(fresh=False):
try:
yield
except Exception as e:
posthog.capture_exception(e)
capture_exception(e)
raise
finally:
_context_stack.reset(token)
Expand Down
6 changes: 3 additions & 3 deletions posthog/sentry/posthog_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sentry_sdk.scope import add_global_event_processor
from sentry_sdk.utils import Dsn

import posthog
from posthog import capture, host
from posthog.request import DEFAULT_HOST
from posthog.sentry import POSTHOG_ID_TAG

Expand Down Expand Up @@ -34,7 +34,7 @@ def processor(event, hint):
if event.get("tags", {}).get(POSTHOG_ID_TAG):
posthog_distinct_id = event["tags"][POSTHOG_ID_TAG]
event["tags"]["PostHog URL"] = (
f"{posthog.host or DEFAULT_HOST}/person/{posthog_distinct_id}"
f"{host or DEFAULT_HOST}/person/{posthog_distinct_id}"
)

properties = {
Expand All @@ -52,6 +52,6 @@ def processor(event, hint):
f"{PostHogIntegration.prefix}{PostHogIntegration.organization}/issues/?project={project_id}&query={event['event_id']}"
)

posthog.capture(posthog_distinct_id, "$exception", properties)
capture(posthog_distinct_id, "$exception", properties)

return event
1 change: 0 additions & 1 deletion posthog/test/test_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import hashlib
import time
import unittest
from datetime import datetime
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 = "4.6.1"
VERSION = "4.6.2"

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