diff --git a/CHANGELOG.md b/CHANGELOG.md index 3886b68c..37ed7d5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Makefile b/Makefile index 9964dcc5..dd3512fd 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ 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 @@ -26,7 +25,6 @@ release_analytics: mkdir posthog 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 diff --git a/posthog/scopes.py b/posthog/scopes.py index 08025623..bf27e478 100644 --- a/posthog/scopes.py +++ b/posthog/scopes.py @@ -39,7 +39,7 @@ def new_context(fresh=False): raise ValueError("Something went wrong") """ - import posthog + from posthog import capture_exception current_tags = _get_current_context().copy() current_stack = _context_stack.get() @@ -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) diff --git a/posthog/sentry/posthog_integration.py b/posthog/sentry/posthog_integration.py index 9c73d4c9..92436c1f 100644 --- a/posthog/sentry/posthog_integration.py +++ b/posthog/sentry/posthog_integration.py @@ -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 @@ -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 = { @@ -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 diff --git a/posthog/test/test_client.py b/posthog/test/test_client.py index 1c83983f..e0ab2a22 100644 --- a/posthog/test/test_client.py +++ b/posthog/test/test_client.py @@ -1,4 +1,3 @@ -import hashlib import time import unittest from datetime import datetime diff --git a/posthog/version.py b/posthog/version.py index 92f427d4..1791721a 100644 --- a/posthog/version.py +++ b/posthog/version.py @@ -1,4 +1,4 @@ -VERSION = "4.6.1" +VERSION = "4.6.2" if __name__ == "__main__": print(VERSION, end="") # noqa: T201