posthoganalytics 6.3.4__tar.gz → 6.4.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.
- {posthoganalytics-6.3.4/posthoganalytics.egg-info → posthoganalytics-6.4.1}/PKG-INFO +1 -1
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/gemini/gemini.py +64 -10
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/client.py +1 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/request.py +6 -2
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_client.py +4 -5
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/version.py +1 -1
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1/posthoganalytics.egg-info}/PKG-INFO +1 -1
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/LICENSE +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/MANIFEST.in +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/README.md +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/anthropic/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/anthropic/anthropic.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/anthropic/anthropic_async.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/anthropic/anthropic_providers.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/gemini/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/langchain/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/langchain/callbacks.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/openai/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/openai/openai.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/openai/openai_async.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/openai/openai_providers.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/utils.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/args.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/consumer.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/contexts.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/exception_capture.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/exception_utils.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/feature_flags.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/integrations/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/integrations/django.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/poller.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/py.typed +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/__init__.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_before_send.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_consumer.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_contexts.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_exception_capture.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_feature_flag.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_feature_flag_result.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_feature_flags.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_module.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_request.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_size_limited_dict.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_types.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_utils.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/types.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/utils.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics.egg-info/SOURCES.txt +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics.egg-info/dependency_links.txt +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics.egg-info/requires.txt +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics.egg-info/top_level.txt +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/pyproject.toml +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/setup.cfg +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/setup.py +0 -0
- {posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/setup_analytics.py +0 -0
|
@@ -42,6 +42,12 @@ class Client:
|
|
|
42
42
|
def __init__(
|
|
43
43
|
self,
|
|
44
44
|
api_key: Optional[str] = None,
|
|
45
|
+
vertexai: Optional[bool] = None,
|
|
46
|
+
credentials: Optional[Any] = None,
|
|
47
|
+
project: Optional[str] = None,
|
|
48
|
+
location: Optional[str] = None,
|
|
49
|
+
debug_config: Optional[Any] = None,
|
|
50
|
+
http_options: Optional[Any] = None,
|
|
45
51
|
posthog_client: Optional[PostHogClient] = None,
|
|
46
52
|
posthog_distinct_id: Optional[str] = None,
|
|
47
53
|
posthog_properties: Optional[Dict[str, Any]] = None,
|
|
@@ -51,7 +57,13 @@ class Client:
|
|
|
51
57
|
):
|
|
52
58
|
"""
|
|
53
59
|
Args:
|
|
54
|
-
api_key: Google AI API key. If not provided, will use GOOGLE_API_KEY or API_KEY environment variable
|
|
60
|
+
api_key: Google AI API key. If not provided, will use GOOGLE_API_KEY or API_KEY environment variable (not required for Vertex AI)
|
|
61
|
+
vertexai: Whether to use Vertex AI authentication
|
|
62
|
+
credentials: Vertex AI credentials object
|
|
63
|
+
project: GCP project ID for Vertex AI
|
|
64
|
+
location: GCP location for Vertex AI
|
|
65
|
+
debug_config: Debug configuration for the client
|
|
66
|
+
http_options: HTTP options for the client
|
|
55
67
|
posthog_client: PostHog client for tracking usage
|
|
56
68
|
posthog_distinct_id: Default distinct ID for all calls (can be overridden per call)
|
|
57
69
|
posthog_properties: Default properties for all calls (can be overridden per call)
|
|
@@ -66,6 +78,12 @@ class Client:
|
|
|
66
78
|
|
|
67
79
|
self.models = Models(
|
|
68
80
|
api_key=api_key,
|
|
81
|
+
vertexai=vertexai,
|
|
82
|
+
credentials=credentials,
|
|
83
|
+
project=project,
|
|
84
|
+
location=location,
|
|
85
|
+
debug_config=debug_config,
|
|
86
|
+
http_options=http_options,
|
|
69
87
|
posthog_client=self._ph_client,
|
|
70
88
|
posthog_distinct_id=posthog_distinct_id,
|
|
71
89
|
posthog_properties=posthog_properties,
|
|
@@ -85,6 +103,12 @@ class Models:
|
|
|
85
103
|
def __init__(
|
|
86
104
|
self,
|
|
87
105
|
api_key: Optional[str] = None,
|
|
106
|
+
vertexai: Optional[bool] = None,
|
|
107
|
+
credentials: Optional[Any] = None,
|
|
108
|
+
project: Optional[str] = None,
|
|
109
|
+
location: Optional[str] = None,
|
|
110
|
+
debug_config: Optional[Any] = None,
|
|
111
|
+
http_options: Optional[Any] = None,
|
|
88
112
|
posthog_client: Optional[PostHogClient] = None,
|
|
89
113
|
posthog_distinct_id: Optional[str] = None,
|
|
90
114
|
posthog_properties: Optional[Dict[str, Any]] = None,
|
|
@@ -94,7 +118,13 @@ class Models:
|
|
|
94
118
|
):
|
|
95
119
|
"""
|
|
96
120
|
Args:
|
|
97
|
-
api_key: Google AI API key. If not provided, will use GOOGLE_API_KEY or API_KEY environment variable
|
|
121
|
+
api_key: Google AI API key. If not provided, will use GOOGLE_API_KEY or API_KEY environment variable (not required for Vertex AI)
|
|
122
|
+
vertexai: Whether to use Vertex AI authentication
|
|
123
|
+
credentials: Vertex AI credentials object
|
|
124
|
+
project: GCP project ID for Vertex AI
|
|
125
|
+
location: GCP location for Vertex AI
|
|
126
|
+
debug_config: Debug configuration for the client
|
|
127
|
+
http_options: HTTP options for the client
|
|
98
128
|
posthog_client: PostHog client for tracking usage
|
|
99
129
|
posthog_distinct_id: Default distinct ID for all calls
|
|
100
130
|
posthog_properties: Default properties for all calls
|
|
@@ -113,16 +143,40 @@ class Models:
|
|
|
113
143
|
self._default_privacy_mode = posthog_privacy_mode
|
|
114
144
|
self._default_groups = posthog_groups
|
|
115
145
|
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
146
|
+
# Build genai.Client arguments
|
|
147
|
+
client_args: Dict[str, Any] = {}
|
|
148
|
+
|
|
149
|
+
# Add Vertex AI parameters if provided
|
|
150
|
+
if vertexai is not None:
|
|
151
|
+
client_args["vertexai"] = vertexai
|
|
152
|
+
if credentials is not None:
|
|
153
|
+
client_args["credentials"] = credentials
|
|
154
|
+
if project is not None:
|
|
155
|
+
client_args["project"] = project
|
|
156
|
+
if location is not None:
|
|
157
|
+
client_args["location"] = location
|
|
158
|
+
if debug_config is not None:
|
|
159
|
+
client_args["debug_config"] = debug_config
|
|
160
|
+
if http_options is not None:
|
|
161
|
+
client_args["http_options"] = http_options
|
|
162
|
+
|
|
163
|
+
# Handle API key authentication
|
|
164
|
+
if vertexai:
|
|
165
|
+
# For Vertex AI, api_key is optional
|
|
166
|
+
if api_key is not None:
|
|
167
|
+
client_args["api_key"] = api_key
|
|
168
|
+
else:
|
|
169
|
+
# For non-Vertex AI mode, api_key is required (backwards compatibility)
|
|
170
|
+
if api_key is None:
|
|
171
|
+
api_key = os.environ.get("GOOGLE_API_KEY") or os.environ.get("API_KEY")
|
|
119
172
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
173
|
+
if api_key is None:
|
|
174
|
+
raise ValueError(
|
|
175
|
+
"API key must be provided either as parameter or via GOOGLE_API_KEY/API_KEY environment variable"
|
|
176
|
+
)
|
|
177
|
+
client_args["api_key"] = api_key
|
|
124
178
|
|
|
125
|
-
self._client = genai.Client(
|
|
179
|
+
self._client = genai.Client(**client_args)
|
|
126
180
|
self._base_url = "https://generativelanguage.googleapis.com"
|
|
127
181
|
|
|
128
182
|
def _merge_posthog_params(
|
|
@@ -132,12 +132,16 @@ def flags(
|
|
|
132
132
|
|
|
133
133
|
|
|
134
134
|
def remote_config(
|
|
135
|
-
personal_api_key: str,
|
|
135
|
+
personal_api_key: str,
|
|
136
|
+
project_api_key: str,
|
|
137
|
+
host: Optional[str] = None,
|
|
138
|
+
key: str = "",
|
|
139
|
+
timeout: int = 15,
|
|
136
140
|
) -> Any:
|
|
137
141
|
"""Get remote config flag value from remote_config API endpoint"""
|
|
138
142
|
return get(
|
|
139
143
|
personal_api_key,
|
|
140
|
-
f"/api/projects/@current/feature_flags/{key}/remote_config
|
|
144
|
+
f"/api/projects/@current/feature_flags/{key}/remote_config?token={project_api_key}",
|
|
141
145
|
host,
|
|
142
146
|
timeout,
|
|
143
147
|
)
|
|
@@ -2,13 +2,13 @@ import time
|
|
|
2
2
|
import unittest
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from uuid import uuid4
|
|
5
|
-
from posthoganalytics.contexts import get_context_session_id, set_context_session, new_context
|
|
6
5
|
|
|
7
6
|
import mock
|
|
8
7
|
import six
|
|
9
8
|
from parameterized import parameterized
|
|
10
9
|
|
|
11
10
|
from posthoganalytics.client import Client
|
|
11
|
+
from posthoganalytics.contexts import get_context_session_id, new_context, set_context_session
|
|
12
12
|
from posthoganalytics.request import APIError
|
|
13
13
|
from posthoganalytics.test.test_utils import FAKE_TEST_API_KEY
|
|
14
14
|
from posthoganalytics.types import FeatureFlag, LegacyFlagMetadata
|
|
@@ -2057,7 +2057,7 @@ class TestClient(unittest.TestCase):
|
|
|
2057
2057
|
|
|
2058
2058
|
def test_set_context_session_override_in_capture(self):
|
|
2059
2059
|
"""Test that explicit session ID overrides context session ID in capture"""
|
|
2060
|
-
from posthoganalytics.contexts import
|
|
2060
|
+
from posthoganalytics.contexts import new_context, set_context_session
|
|
2061
2061
|
|
|
2062
2062
|
with mock.patch("posthog.client.batch_post") as mock_post:
|
|
2063
2063
|
client = Client(FAKE_TEST_API_KEY, on_error=self.set_fail, sync_mode=True)
|
|
@@ -2158,6 +2158,7 @@ class TestClient(unittest.TestCase):
|
|
|
2158
2158
|
self.assertEqual(result, {"test": "payload"})
|
|
2159
2159
|
patch_remote_config.assert_called_once_with(
|
|
2160
2160
|
"test-personal-key",
|
|
2161
|
+
FAKE_TEST_API_KEY,
|
|
2161
2162
|
client.host,
|
|
2162
2163
|
"test-flag",
|
|
2163
2164
|
timeout=client.feature_flags_request_timeout_seconds,
|
|
@@ -2282,9 +2283,7 @@ class TestClient(unittest.TestCase):
|
|
|
2282
2283
|
}
|
|
2283
2284
|
]
|
|
2284
2285
|
},
|
|
2285
|
-
"payloads": {
|
|
2286
|
-
"empty-variant": "" # Empty string payload
|
|
2287
|
-
},
|
|
2286
|
+
"payloads": {"empty-variant": ""}, # Empty string payload
|
|
2288
2287
|
},
|
|
2289
2288
|
}
|
|
2290
2289
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/anthropic/anthropic.py
RENAMED
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/anthropic/anthropic_async.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/langchain/callbacks.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/ai/openai/openai_async.py
RENAMED
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/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
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_exception_capture.py
RENAMED
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_feature_flag.py
RENAMED
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_feature_flag_result.py
RENAMED
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/posthoganalytics/test/test_feature_flags.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{posthoganalytics-6.3.4 → posthoganalytics-6.4.1}/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.3.4 → posthoganalytics-6.4.1}/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
|