Skip to content

Commit 4426dd9

Browse files
authored
remove 'import posthog' (#255)
1 parent bf0d7ef commit 4426dd9

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.6.2 - 2025-06-09
2+
3+
- fix: replace `import posthog` with direct method imports
4+
15
## 4.6.1 - 2025-06-09
26

37
- fix: replace `import posthog` in `posthoganalytics` package

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ release_analytics:
1818
cp -r posthog/* posthoganalytics/
1919
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthog /from posthoganalytics /g' {} \;
2020
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthog\./from posthoganalytics\./g' {} \;
21-
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/import posthog/import posthoganalytics/g' {} \;
2221
find ./posthoganalytics -name "*.bak" -delete
2322
rm -rf posthog
2423
python setup_analytics.py sdist bdist_wheel
2524
twine upload dist/*
2625
mkdir posthog
2726
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthoganalytics /from posthog /g' {} \;
2827
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/from posthoganalytics\./from posthog\./g' {} \;
29-
find ./posthoganalytics -type f -name "*.py" -exec sed -i.bak -e 's/import posthoganalytics/import posthog/g' {} \;
3028
find ./posthoganalytics -name "*.bak" -delete
3129
cp -r posthoganalytics/* posthog/
3230
rm -rf posthoganalytics

posthog/scopes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def new_context(fresh=False):
3939
raise ValueError("Something went wrong")
4040
4141
"""
42-
import posthog
42+
from posthog import capture_exception
4343

4444
current_tags = _get_current_context().copy()
4545
current_stack = _context_stack.get()
@@ -49,7 +49,7 @@ def new_context(fresh=False):
4949
try:
5050
yield
5151
except Exception as e:
52-
posthog.capture_exception(e)
52+
capture_exception(e)
5353
raise
5454
finally:
5555
_context_stack.reset(token)

posthog/sentry/posthog_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sentry_sdk.scope import add_global_event_processor
55
from sentry_sdk.utils import Dsn
66

7-
import posthog
7+
from posthog import capture, host
88
from posthog.request import DEFAULT_HOST
99
from posthog.sentry import POSTHOG_ID_TAG
1010

@@ -34,7 +34,7 @@ def processor(event, hint):
3434
if event.get("tags", {}).get(POSTHOG_ID_TAG):
3535
posthog_distinct_id = event["tags"][POSTHOG_ID_TAG]
3636
event["tags"]["PostHog URL"] = (
37-
f"{posthog.host or DEFAULT_HOST}/person/{posthog_distinct_id}"
37+
f"{host or DEFAULT_HOST}/person/{posthog_distinct_id}"
3838
)
3939

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

55-
posthog.capture(posthog_distinct_id, "$exception", properties)
55+
capture(posthog_distinct_id, "$exception", properties)
5656

5757
return event

posthog/test/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import hashlib
21
import time
32
import unittest
43
from datetime import datetime

posthog/version.py

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

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

0 commit comments

Comments
 (0)