posthoganalytics 6.0.3__tar.gz → 6.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {posthoganalytics-6.0.3/posthoganalytics.egg-info → posthoganalytics-6.0.4}/PKG-INFO +1 -1
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/integrations/django.py +11 -2
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/version.py +1 -1
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4/posthoganalytics.egg-info}/PKG-INFO +1 -1
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/LICENSE +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/MANIFEST.in +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/README.md +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/anthropic/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/anthropic/anthropic.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/anthropic/anthropic_async.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/anthropic/anthropic_providers.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/gemini/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/gemini/gemini.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/langchain/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/langchain/callbacks.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/openai/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/openai/openai.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/openai/openai_async.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/openai/openai_providers.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/utils.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/args.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/client.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/consumer.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/contexts.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/exception_capture.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/exception_utils.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/feature_flags.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/integrations/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/poller.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/py.typed +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/request.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/__init__.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_before_send.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_client.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_consumer.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_contexts.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_exception_capture.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_feature_flag.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_feature_flag_result.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_feature_flags.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_module.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_request.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_size_limited_dict.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_types.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_utils.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/types.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/utils.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics.egg-info/SOURCES.txt +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics.egg-info/dependency_links.txt +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics.egg-info/requires.txt +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics.egg-info/top_level.txt +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/pyproject.toml +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/setup.cfg +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/setup.py +0 -0
- {posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/setup_analytics.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from typing import TYPE_CHECKING, cast
|
|
2
2
|
from posthoganalytics import contexts
|
|
3
|
+
from posthoganalytics.client import Client
|
|
3
4
|
|
|
4
5
|
if TYPE_CHECKING:
|
|
5
6
|
from django.http import HttpRequest, HttpResponse # noqa: F401
|
|
@@ -16,7 +17,8 @@ class PosthogContextMiddleware:
|
|
|
16
17
|
- Request Method as $request_method
|
|
17
18
|
|
|
18
19
|
The context will also auto-capture exceptions and send them to PostHog, unless you disable it by setting
|
|
19
|
-
`POSTHOG_MW_CAPTURE_EXCEPTIONS` to `False` in your Django settings.
|
|
20
|
+
`POSTHOG_MW_CAPTURE_EXCEPTIONS` to `False` in your Django settings. The exceptions are captured using the
|
|
21
|
+
global client, unless the setting `POSTHOG_MW_CLIENT` is set to a custom client instance
|
|
20
22
|
|
|
21
23
|
The middleware behaviour is customisable through 3 additional functions:
|
|
22
24
|
- `POSTHOG_MW_EXTRA_TAGS`, which is a Callable[[HttpRequest], Dict[str, Any]] expected to return a dictionary of additional tags to be added to the context.
|
|
@@ -74,6 +76,13 @@ class PosthogContextMiddleware:
|
|
|
74
76
|
else:
|
|
75
77
|
self.capture_exceptions = True
|
|
76
78
|
|
|
79
|
+
if hasattr(settings, "POSTHOG_MW_CLIENT") and isinstance(
|
|
80
|
+
settings.POSTHOG_MW_CLIENT, Client
|
|
81
|
+
):
|
|
82
|
+
self.client = cast("Optional[Client]", settings.POSTHOG_MW_CLIENT)
|
|
83
|
+
else:
|
|
84
|
+
self.client = None
|
|
85
|
+
|
|
77
86
|
def extract_tags(self, request):
|
|
78
87
|
# type: (HttpRequest) -> Dict[str, Any]
|
|
79
88
|
tags = {}
|
|
@@ -153,7 +162,7 @@ class PosthogContextMiddleware:
|
|
|
153
162
|
if self.request_filter and not self.request_filter(request):
|
|
154
163
|
return self.get_response(request)
|
|
155
164
|
|
|
156
|
-
with contexts.new_context(self.capture_exceptions):
|
|
165
|
+
with contexts.new_context(self.capture_exceptions, client=self.client):
|
|
157
166
|
for k, v in self.extract_tags(request).items():
|
|
158
167
|
contexts.tag(k, v)
|
|
159
168
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/anthropic/anthropic.py
RENAMED
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/anthropic/anthropic_async.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/langchain/callbacks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/openai/openai_async.py
RENAMED
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/ai/openai/openai_providers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_exception_capture.py
RENAMED
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_feature_flag.py
RENAMED
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_feature_flag_result.py
RENAMED
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_feature_flags.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics/test/test_size_limited_dict.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.0.3 → posthoganalytics-6.0.4}/posthoganalytics.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|