posthoganalytics 7.8.0__tar.gz → 7.8.1__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.
Files changed (74) hide show
  1. {posthoganalytics-7.8.0/posthoganalytics.egg-info → posthoganalytics-7.8.1}/PKG-INFO +1 -1
  2. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/prompts.py +9 -8
  3. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/ai/test_prompts.py +6 -6
  4. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/version.py +1 -1
  5. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1/posthoganalytics.egg-info}/PKG-INFO +1 -1
  6. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/LICENSE +0 -0
  7. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/MANIFEST.in +0 -0
  8. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/README.md +0 -0
  9. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/__init__.py +0 -0
  10. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/__init__.py +0 -0
  11. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/anthropic/__init__.py +0 -0
  12. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/anthropic/anthropic.py +0 -0
  13. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/anthropic/anthropic_async.py +0 -0
  14. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/anthropic/anthropic_converter.py +0 -0
  15. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/anthropic/anthropic_providers.py +0 -0
  16. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/gemini/__init__.py +0 -0
  17. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/gemini/gemini.py +0 -0
  18. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/gemini/gemini_async.py +0 -0
  19. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/gemini/gemini_converter.py +0 -0
  20. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/langchain/__init__.py +0 -0
  21. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/langchain/callbacks.py +0 -0
  22. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/openai/__init__.py +0 -0
  23. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/openai/openai.py +0 -0
  24. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/openai/openai_async.py +0 -0
  25. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/openai/openai_converter.py +0 -0
  26. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/openai/openai_providers.py +0 -0
  27. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/openai_agents/__init__.py +0 -0
  28. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/openai_agents/processor.py +0 -0
  29. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/sanitization.py +0 -0
  30. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/types.py +0 -0
  31. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/ai/utils.py +0 -0
  32. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/args.py +0 -0
  33. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/client.py +0 -0
  34. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/consumer.py +0 -0
  35. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/contexts.py +0 -0
  36. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/exception_capture.py +0 -0
  37. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/exception_utils.py +0 -0
  38. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/feature_flags.py +0 -0
  39. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/flag_definition_cache.py +0 -0
  40. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/integrations/__init__.py +0 -0
  41. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/integrations/django.py +0 -0
  42. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/poller.py +0 -0
  43. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/py.typed +0 -0
  44. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/request.py +0 -0
  45. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/__init__.py +0 -0
  46. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/ai/__init__.py +0 -0
  47. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/ai/openai_agents/__init__.py +0 -0
  48. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/ai/openai_agents/test_processor.py +0 -0
  49. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/ai/test_sanitization.py +0 -0
  50. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/ai/test_system_prompts.py +0 -0
  51. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_before_send.py +0 -0
  52. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_client.py +0 -0
  53. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_consumer.py +0 -0
  54. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_contexts.py +0 -0
  55. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_exception_capture.py +0 -0
  56. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_feature_flag.py +0 -0
  57. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_feature_flag_result.py +0 -0
  58. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_feature_flags.py +0 -0
  59. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_flag_definition_cache.py +0 -0
  60. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_module.py +0 -0
  61. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_request.py +0 -0
  62. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_size_limited_dict.py +0 -0
  63. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_types.py +0 -0
  64. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/test/test_utils.py +0 -0
  65. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/types.py +0 -0
  66. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics/utils.py +0 -0
  67. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics.egg-info/SOURCES.txt +0 -0
  68. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics.egg-info/dependency_links.txt +0 -0
  69. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics.egg-info/requires.txt +0 -0
  70. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/posthoganalytics.egg-info/top_level.txt +0 -0
  71. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/pyproject.toml +0 -0
  72. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/setup.cfg +0 -0
  73. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/setup.py +0 -0
  74. {posthoganalytics-7.8.0 → posthoganalytics-7.8.1}/setup_analytics.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: posthoganalytics
3
- Version: 7.8.0
3
+ Version: 7.8.1
4
4
  Summary: Integrate PostHog into any python application.
5
5
  Home-page: https://github.com/posthog/posthog-python
6
6
  Author: Posthog
@@ -10,11 +10,12 @@ import time
10
10
  import urllib.parse
11
11
  from typing import Any, Dict, Optional, Union
12
12
 
13
- from posthoganalytics.request import DEFAULT_HOST, USER_AGENT, _get_session
13
+ from posthoganalytics.request import USER_AGENT, _get_session
14
14
  from posthoganalytics.utils import remove_trailing_slash
15
15
 
16
16
  log = logging.getLogger("posthog")
17
17
 
18
+ APP_ENDPOINT = "https://app.posthog.com"
18
19
  DEFAULT_CACHE_TTL_SECONDS = 300 # 5 minutes
19
20
 
20
21
  PromptVariables = Dict[str, Union[str, int, float, bool]]
@@ -49,11 +50,11 @@ class Prompts:
49
50
  from posthoganalytics.ai.prompts import Prompts
50
51
 
51
52
  # With PostHog client
52
- posthog = Posthog('phc_xxx', host='https://us.i.posthog.com', personal_api_key='phx_xxx')
53
+ posthog = Posthog('phc_xxx', host='https://app.posthog.com', personal_api_key='phx_xxx')
53
54
  prompts = Prompts(posthog)
54
55
 
55
56
  # Or with direct options (no PostHog client needed)
56
- prompts = Prompts(personal_api_key='phx_xxx', host='https://us.i.posthog.com')
57
+ prompts = Prompts(personal_api_key='phx_xxx', host='https://app.posthog.com')
57
58
 
58
59
  # Fetch with caching and fallback
59
60
  template = prompts.get('support-system-prompt', fallback='You are a helpful assistant.')
@@ -80,7 +81,7 @@ class Prompts:
80
81
  Args:
81
82
  posthog: PostHog client instance (optional if personal_api_key provided)
82
83
  personal_api_key: Direct API key (optional if posthog provided)
83
- host: PostHog host (defaults to US ingestion endpoint)
84
+ host: PostHog host (defaults to app endpoint)
84
85
  default_cache_ttl_seconds: Default cache TTL (defaults to 300)
85
86
  """
86
87
  self._default_cache_ttl_seconds = (
@@ -91,11 +92,11 @@ class Prompts:
91
92
  if posthog is not None:
92
93
  self._personal_api_key = getattr(posthog, "personal_api_key", None) or ""
93
94
  self._host = remove_trailing_slash(
94
- getattr(posthog, "raw_host", None) or DEFAULT_HOST
95
+ getattr(posthog, "raw_host", None) or APP_ENDPOINT
95
96
  )
96
97
  else:
97
98
  self._personal_api_key = personal_api_key or ""
98
- self._host = remove_trailing_slash(host or DEFAULT_HOST)
99
+ self._host = remove_trailing_slash(host or APP_ENDPOINT)
99
100
 
100
101
  def get(
101
102
  self,
@@ -214,7 +215,7 @@ class Prompts:
214
215
  """
215
216
  Fetch prompt from PostHog API.
216
217
 
217
- Endpoint: {host}/api/projects/@current/llm_prompts/name/{encoded_name}/
218
+ Endpoint: {host}/api/environments/@current/llm_prompts/name/{encoded_name}/
218
219
  Auth: Bearer {personal_api_key}
219
220
 
220
221
  Args:
@@ -233,7 +234,7 @@ class Prompts:
233
234
  )
234
235
 
235
236
  encoded_name = urllib.parse.quote(name, safe="")
236
- url = f"{self._host}/api/projects/@current/llm_prompts/name/{encoded_name}/"
237
+ url = f"{self._host}/api/environments/@current/llm_prompts/name/{encoded_name}/"
237
238
 
238
239
  headers = {
239
240
  "Authorization": f"Bearer {self._personal_api_key}",
@@ -33,7 +33,7 @@ class TestPrompts(unittest.TestCase):
33
33
  }
34
34
 
35
35
  def create_mock_posthog(
36
- self, personal_api_key="phx_test_key", host="https://us.i.posthog.com"
36
+ self, personal_api_key="phx_test_key", host="https://app.posthog.com"
37
37
  ):
38
38
  """Create a mock PostHog client."""
39
39
  mock = MagicMock()
@@ -61,7 +61,7 @@ class TestPromptsGet(TestPrompts):
61
61
  call_args = mock_get.call_args
62
62
  self.assertEqual(
63
63
  call_args[0][0],
64
- "https://us.i.posthog.com/api/projects/@current/llm_prompts/name/test-prompt/",
64
+ "https://app.posthog.com/api/environments/@current/llm_prompts/name/test-prompt/",
65
65
  )
66
66
  self.assertIn("Authorization", call_args[1]["headers"])
67
67
  self.assertEqual(
@@ -333,7 +333,7 @@ class TestPromptsGet(TestPrompts):
333
333
  call_args = mock_get.call_args
334
334
  self.assertEqual(
335
335
  call_args[0][0],
336
- "https://us.i.posthog.com/api/projects/@current/llm_prompts/name/prompt%20with%20spaces%2Fand%2Fslashes/",
336
+ "https://app.posthog.com/api/environments/@current/llm_prompts/name/prompt%20with%20spaces%2Fand%2Fslashes/",
337
337
  )
338
338
 
339
339
  @patch("posthog.ai.prompts._get_session")
@@ -350,7 +350,7 @@ class TestPromptsGet(TestPrompts):
350
350
  call_args = mock_get.call_args
351
351
  self.assertEqual(
352
352
  call_args[0][0],
353
- "https://us.i.posthog.com/api/projects/@current/llm_prompts/name/test-prompt/",
353
+ "https://app.posthog.com/api/environments/@current/llm_prompts/name/test-prompt/",
354
354
  )
355
355
  self.assertEqual(
356
356
  call_args[1]["headers"]["Authorization"], "Bearer phx_direct_key"
@@ -363,7 +363,7 @@ class TestPromptsGet(TestPrompts):
363
363
  mock_get.return_value = MockResponse(json_data=self.mock_prompt_response)
364
364
 
365
365
  prompts = Prompts(
366
- personal_api_key="phx_direct_key", host="https://eu.i.posthog.com"
366
+ personal_api_key="phx_direct_key", host="https://eu.posthog.com"
367
367
  )
368
368
 
369
369
  prompts.get("test-prompt")
@@ -371,7 +371,7 @@ class TestPromptsGet(TestPrompts):
371
371
  call_args = mock_get.call_args
372
372
  self.assertEqual(
373
373
  call_args[0][0],
374
- "https://eu.i.posthog.com/api/projects/@current/llm_prompts/name/test-prompt/",
374
+ "https://eu.posthog.com/api/environments/@current/llm_prompts/name/test-prompt/",
375
375
  )
376
376
 
377
377
  @patch("posthog.ai.prompts._get_session")
@@ -1,4 +1,4 @@
1
- VERSION = "7.8.0"
1
+ VERSION = "7.8.1"
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: posthoganalytics
3
- Version: 7.8.0
3
+ Version: 7.8.1
4
4
  Summary: Integrate PostHog into any python application.
5
5
  Home-page: https://github.com/posthog/posthog-python
6
6
  Author: Posthog