posthog 6.7.10__py3-none-any.whl → 6.7.12__py3-none-any.whl

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.
@@ -20,8 +20,14 @@ from typing import (
20
20
  )
21
21
  from uuid import UUID
22
22
 
23
- from langchain.callbacks.base import BaseCallbackHandler
24
- from langchain.schema.agent import AgentAction, AgentFinish
23
+ try:
24
+ # LangChain 1.0+ and modern 0.x with langchain-core
25
+ from langchain_core.callbacks.base import BaseCallbackHandler
26
+ from langchain_core.agents import AgentAction, AgentFinish
27
+ except (ImportError, ModuleNotFoundError):
28
+ # Fallback for older LangChain versions
29
+ from langchain.callbacks.base import BaseCallbackHandler
30
+ from langchain.schema.agent import AgentAction, AgentFinish
25
31
  from langchain_core.documents import Document
26
32
  from langchain_core.messages import (
27
33
  AIMessage,
@@ -486,6 +492,7 @@ class CallbackHandler(BaseCallbackHandler):
486
492
  "$ai_latency": run.latency,
487
493
  "$ai_span_name": run.name,
488
494
  "$ai_span_id": run_id,
495
+ "$ai_framework": "langchain",
489
496
  }
490
497
  if parent_run_id is not None:
491
498
  event_properties["$ai_parent_id"] = parent_run_id
@@ -556,6 +563,7 @@ class CallbackHandler(BaseCallbackHandler):
556
563
  "$ai_http_status": 200,
557
564
  "$ai_latency": run.latency,
558
565
  "$ai_base_url": run.base_url,
566
+ "$ai_framework": "langchain",
559
567
  }
560
568
 
561
569
  if run.tools:
@@ -220,3 +220,32 @@ class PosthogContextMiddleware:
220
220
  contexts.tag(k, v)
221
221
 
222
222
  return await self.get_response(request)
223
+
224
+ def process_exception(self, request, exception):
225
+ # type: (HttpRequest, Exception) -> None
226
+ """
227
+ Process exceptions from views and downstream middleware.
228
+
229
+ Django calls this WHILE still inside the context created by __call__,
230
+ so request tags have already been extracted and set. This method just
231
+ needs to capture the exception directly.
232
+
233
+ Django converts view exceptions into responses before they propagate through
234
+ the middleware stack, so the context manager in __call__/__acall__ never sees them.
235
+
236
+ Note: Django's process_exception is always synchronous, even for async views.
237
+ """
238
+ if self.request_filter and not self.request_filter(request):
239
+ return
240
+
241
+ if not self.capture_exceptions:
242
+ return
243
+
244
+ # Context and tags already set by __call__ or __acall__
245
+ # Just capture the exception
246
+ if self.client:
247
+ self.client.capture_exception(exception)
248
+ else:
249
+ from posthog import capture_exception
250
+
251
+ capture_exception(exception)
posthog/version.py CHANGED
@@ -1,4 +1,4 @@
1
- VERSION = "6.7.10"
1
+ VERSION = "6.7.12"
2
2
 
3
3
  if __name__ == "__main__":
4
4
  print(VERSION, end="") # noqa: T201
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: posthog
3
- Version: 6.7.10
3
+ Version: 6.7.12
4
4
  Summary: Integrate PostHog into any python application.
5
5
  Home-page: https://github.com/posthog/posthog-python
6
6
  Author: Posthog
@@ -11,7 +11,7 @@ posthog/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  posthog/request.py,sha256=CaONBN7a5RD8xiSShVMgHEd9XxKWM6ZQTLZypiqABhA,6168
12
12
  posthog/types.py,sha256=Dl3aFGX9XUR0wMmK12r2s5Hjan9jL4HpQ9GHpVcEq5U,10207
13
13
  posthog/utils.py,sha256=-0w-OLcCaoldkbBebPzQyBzLJSo9G9yBOg8NDVz7La8,16088
14
- posthog/version.py,sha256=nZjqu-65D7o-byHYYEIUo6_Aa-szIb7lGhSsPoJkJas,88
14
+ posthog/version.py,sha256=Xccfj-7JKyvSLDAdLr_RHvSeKlklk1btmrlKdJ-haUU,88
15
15
  posthog/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  posthog/ai/sanitization.py,sha256=owipZ4eJYtd4JTI-CM_klatclXaeaIec3XJBOUfsOnQ,5770
17
17
  posthog/ai/types.py,sha256=ceubs4K9xf8vQx7wokq1NL9hPtxyS7D7sUOuT7Lx1lM,3237
@@ -25,14 +25,14 @@ posthog/ai/gemini/__init__.py,sha256=JV_9-gBR87leHgZW4XAYZP7LSl4YaXeuhqDUpA8HygA
25
25
  posthog/ai/gemini/gemini.py,sha256=-c2MnBeask6SrAbFZ7XXZ_OMcuglTBRdnFe_ROVgXWQ,14972
26
26
  posthog/ai/gemini/gemini_converter.py,sha256=0LM5OXsCWjg8eazi06VI5Fc4LSGxSUvg-_XpZVll78A,16009
27
27
  posthog/ai/langchain/__init__.py,sha256=9CqAwLynTGj3ASAR80C3PmdTdrYGmu99tz0JL-HPFgI,70
28
- posthog/ai/langchain/callbacks.py,sha256=vkcOUch82N6BJPDTZTmTHVrRu0ZpLdFZqgt_LEqwGPg,29491
28
+ posthog/ai/langchain/callbacks.py,sha256=9bGsuBemnRApeMKwlNZR4Twg_iXOQ55IEhDS15-dr-c,29860
29
29
  posthog/ai/openai/__init__.py,sha256=u4OuUT7k1NgFj0TrxjuyegOg7a_UA8nAU6a-Hszr0OM,490
30
30
  posthog/ai/openai/openai.py,sha256=ts95vdvWH7h0TX4FpLLK_wU_7H0MP3eZBEg0S-lsCKw,20127
31
31
  posthog/ai/openai/openai_async.py,sha256=QFewU-8VBW1BhrNHkKCFuW57jqu2RSnF2VZ9mDuxjbE,21775
32
32
  posthog/ai/openai/openai_converter.py,sha256=B38g_RgN1n7mbxbDDAZFcu50RO4UHCtJQAmpvDVry7o,20451
33
33
  posthog/ai/openai/openai_providers.py,sha256=zQIFTXHS2-dBKQX7FZxTFo7rIj5iiN7VHm9_2RzuDs8,3941
34
34
  posthog/integrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- posthog/integrations/django.py,sha256=7z7YsF46KTe11WfgX__qHpYau_jFt-9BacNYY9GI17A,8667
35
+ posthog/integrations/django.py,sha256=ybFRsSEv-ishDZShWN07-_PDbGBiHjWm0Gh1care18I,9763
36
36
  posthog/test/__init__.py,sha256=VYgM6xPbJbvS-xhIcDiBRs0MFC9V_jT65uNeerCz_rM,299
37
37
  posthog/test/test_before_send.py,sha256=3546WKlk8rF6bhvqhwcxAsjJovDw0Hf8yTvcYGbrhyI,7912
38
38
  posthog/test/test_client.py,sha256=F-jUA0uKgHpVLOdnen2j6WSTp6whlJcpZdSecLoREFg,96273
@@ -47,8 +47,8 @@ posthog/test/test_request.py,sha256=l19WVyZQc4Iqmh_bpnAFOj4nGRpDK1iO-o5aJDQfFdo,
47
47
  posthog/test/test_size_limited_dict.py,sha256=Wom7BkzpHmusHilZy0SV3PNzhw7ucuQgqrx86jf8euo,765
48
48
  posthog/test/test_types.py,sha256=csLuBiz6RMV36cpg9LVIor4Khq6MfjjGxYXodx5VttY,7586
49
49
  posthog/test/test_utils.py,sha256=NUs2bgqrVuMdnKRq52syizgglt5_7wxxZl3dDMun-Tg,9602
50
- posthog-6.7.10.dist-info/licenses/LICENSE,sha256=wGf9JBotDkSygFj43m49oiKlFnpMnn97keiZKF-40vE,2450
51
- posthog-6.7.10.dist-info/METADATA,sha256=xXwTtZo74FQWRV5n4jsS9mG8MqlX1DrGY2qPVlUPaRo,6016
52
- posthog-6.7.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
- posthog-6.7.10.dist-info/top_level.txt,sha256=7FBLsRjIUHVKQsXIhozuI3k-mun1tapp8iZO9EmUPEw,8
54
- posthog-6.7.10.dist-info/RECORD,,
50
+ posthog-6.7.12.dist-info/licenses/LICENSE,sha256=wGf9JBotDkSygFj43m49oiKlFnpMnn97keiZKF-40vE,2450
51
+ posthog-6.7.12.dist-info/METADATA,sha256=6ngwQgmYnwNE63rqfYXlbVMTOSR2PCXOyGldah7k8ZU,6016
52
+ posthog-6.7.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
+ posthog-6.7.12.dist-info/top_level.txt,sha256=7FBLsRjIUHVKQsXIhozuI3k-mun1tapp8iZO9EmUPEw,8
54
+ posthog-6.7.12.dist-info/RECORD,,