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 @@
## 5.0.0

- fix: removed deprecated sentry integration

## 4.10.0 - 2025-06-13

- fix: no longer fail in autocapture.
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,4 @@ release_analytics:
e2e_test:
.buildscripts/e2e.sh

django_example:
python -m pip install -e ".[sentry]"
cd sentry_django_example && python manage.py runserver 8080

.PHONY: test lint release e2e_test
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ make test

Assuming you have a [local version of PostHog](https://posthog.com/docs/developing-locally) running, you can run `python3 example.py` to see the library in action.

### Running the Django Sentry Integration Locally

There's a sample Django project included, called `sentry_django_example`, which explains how to use PostHog with Sentry.

There's 2 places of importance (Changes required are all marked with TODO in the sample project directory)

1. Settings.py
1. Input your Sentry DSN
2. Input your Sentry Org and ProjectID details into `PosthogIntegration()`
3. Add `POSTHOG_DJANGO` to settings.py. This allows the `PosthogDistinctIdMiddleware` to get the distinct_ids

2. urls.py
1. This includes the `sentry-debug/` endpoint, which generates an exception

To run things: `make django_example`. This installs the posthog-python library with the sentry-sdk add-on, and then runs the django app.
Also start the PostHog app locally.
Then navigate to `http://127.0.0.1:8080/sentry-debug/` and you should get an event in both Sentry and PostHog, with links to each other.

### Releasing Versions

Updated are released using GitHub Actions: after bumping `version.py` in `master` and adding to `CHANGELOG.md`, go to [our release workflow's page](https://github.com/PostHog/posthog-python/actions/workflows/release.yaml) and dispatch it manually, using workflow from `master`.
Updates are released using GitHub Actions: after bumping `version.py` in `master` and adding to `CHANGELOG.md`, go to [our release workflow's page](https://github.com/PostHog/posthog-python/actions/workflows/release.yaml) and dispatch it manually, using workflow from `master`.
3 changes: 0 additions & 3 deletions mypy-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ posthog/__init__.py:0: note: "identify" defined here
simulator.py:0: error: Unexpected keyword argument "traits" for "identify" [call-arg]
posthog/__init__.py:0: note: "identify" defined here
example.py:0: error: Statement is unreachable [unreachable]
posthog/sentry/posthog_integration.py:0: error: Statement is unreachable [unreachable]
posthog/ai/utils.py:0: error: Need type annotation for "output" (hint: "output: list[<type>] = ...") [var-annotated]
posthog/ai/utils.py:0: error: Function "builtins.any" is not valid as a type [valid-type]
posthog/ai/utils.py:0: note: Perhaps you meant "typing.Any" instead of "any"?
posthog/ai/utils.py:0: error: Function "builtins.any" is not valid as a type [valid-type]
posthog/ai/utils.py:0: note: Perhaps you meant "typing.Any" instead of "any"?
sentry_django_example/sentry_django_example/settings.py:0: error: Need type annotation for "ALLOWED_HOSTS" (hint: "ALLOWED_HOSTS: list[<type>] = ...") [var-annotated]
sentry_django_example/sentry_django_example/settings.py:0: error: Incompatible types in assignment (expression has type "str", variable has type "None") [assignment]
20 changes: 3 additions & 17 deletions posthog/exception_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
# "monitor_config": Mapping[str, object],
"monitor_slug": Optional[str],
"platform": Literal["python"],
"profile": object, # Should be sentry_sdk.profiler.Profile, but we can't import that here due to circular imports
"profile": object,
"release": str,
"request": Dict[str, object],
# "sdk": Mapping[str, object],
Expand Down Expand Up @@ -136,9 +136,6 @@ def event_hint_with_exc_info(exc_info=None):
class AnnotatedValue:
"""
Meta information for a data field in the event payload.
This is to tell Relay that we have tampered with the fields value.
See:
https://github.com/getsentry/relay/blob/be12cd49a0f06ea932ed9b9f93a655de5d6ad6d1/relay-general/src/types/meta.rs#L407-L423
"""

__slots__ = ("value", "metadata")
Expand Down Expand Up @@ -400,12 +397,7 @@ def serialize_frame(
)

if include_local_variables:
# TODO(nk): Sort out this current invalid import
# from sentry_sdk.serializer import serialize

# rv["vars"] = serialize(
# dict(frame.f_locals), is_vars=True, custom_repr=custom_repr
# )
# TODO - we don't support local variables, yet
pass

return rv
Expand Down Expand Up @@ -464,10 +456,7 @@ def single_exception_from_error_tuple(
):
# type: (...) -> Dict[str, Any]
"""
Creates a dict that goes into the events `exception.values` list and is ingestible by Sentry.

See the Exception Interface documentation for more details:
https://develop.sentry.dev/sdk/event-payloads/exception/
Creates a dict that goes into the events `exception.values` list
"""
exception_value = {} # type: Dict[str, Any]
exception_value["mechanism"] = (
Expand Down Expand Up @@ -591,9 +580,6 @@ def exceptions_from_error(
"""
Creates the list of exceptions.
This can include chained exceptions and exceptions from an ExceptionGroup.

See the Exception Interface documentation for more details:
https://develop.sentry.dev/sdk/event-payloads/exception/
"""

parent = single_exception_from_error_tuple(
Expand Down
1 change: 0 additions & 1 deletion posthog/sentry/__init__.py

This file was deleted.

28 changes: 0 additions & 28 deletions posthog/sentry/django.py

This file was deleted.

57 changes: 0 additions & 57 deletions posthog/sentry/posthog_integration.py

This file was deleted.

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.10.0"
VERSION = "5.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is technically a breaking change but seems like a pretty niche feature to necessitate a major upgrade for 🤔 Don't suppose there's anything we could bundle in as part of this change like we did for Node recently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Version numbers are free, they let you make them as high as you want, even the major ones 😉.

More seriously, the next breaking change I want to make to this SDK is to make it optional to pass a distinct ID, and that's too large a change to bundle in here IMO. I'm not aware of anyone else working on anything breaking, and I think "biting the bullet" of major version bump for a relatively niche feature here wins us some credibility about future breaking changes.


if __name__ == "__main__":
print(VERSION, end="") # noqa: T201
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
description = "Integrate PostHog into any python application."
authors = [{ name = "PostHog", email = "[email protected]" }]
maintainers = [{ name = "PostHog", email = "[email protected]" }]
license = {text = "MIT"}
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.9"
classifiers = [
Expand Down Expand Up @@ -36,7 +36,6 @@ Homepage = "https://github.com/posthog/posthog-python"
Repository = "https://github.com/posthog/posthog-python"

[project.optional-dependencies]
sentry = ["sentry-sdk", "django"]
langchain = ["langchain>=0.2.0"]
dev = [
"django-stubs",
Expand All @@ -52,7 +51,7 @@ dev = [
"pydantic",
"ruff",
"setuptools",
"packaging",
"packaging",
"wheel",
"twine",
"tomli",
Expand Down Expand Up @@ -87,7 +86,6 @@ packages = [
"posthog.ai.anthropic",
"posthog.ai.gemini",
"posthog.test",
"posthog.sentry",
"posthog.exception_integrations",
]

Expand Down
Empty file removed sentry_django_example/db.sqlite3
Empty file.
23 changes: 0 additions & 23 deletions sentry_django_example/manage.py

This file was deleted.

Empty file.
16 changes: 0 additions & 16 deletions sentry_django_example/sentry_django_example/asgi.py

This file was deleted.

Loading
Loading