Skip to content

Commit 307bb9e

Browse files
committed
chore: remove the unused request identity plumbing and stale MCP client advice
1 parent 9c932be commit 307bb9e

2 files changed

Lines changed: 3 additions & 35 deletions

File tree

‎posthog/mcp/README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ but anyone wrapping a server already has it.
3434
MCP analytics events report `$lib: "posthog-python"` and the installed `posthog` package version in `$lib_version`, like every other event the client sends.
3535
PostHog sets both from the client's `PostHog-Sdk-Info` request header, so `instrument()` and `PostHogMCP` do not relabel the client.
3636
Filter MCP traffic by its `$mcp_*` events and properties instead.
37-
Use a client dedicated to MCP analytics if the application also captures unrelated events.
3837

3938
## Defaults and opt-outs
4039

‎posthog/request.py‎

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ def post(
219219
) -> requests.Response:
220220
"""Post the `kwargs` to the API"""
221221
log = logging.getLogger("posthog")
222-
user_agent = kwargs.pop("_user_agent", USER_AGENT)
223222
body = kwargs
224223
body["sent_at"] = datetime.now(tz=timezone.utc).isoformat()
225224
trimmed_host = remove_trailing_slash(normalize_host(host))
@@ -232,7 +231,7 @@ def post(
232231
json.dumps({**body, "api_key": "[redacted]"}, cls=DatetimeSerializer),
233232
url,
234233
)
235-
headers = {"Content-Type": "application/json", "User-Agent": user_agent}
234+
headers = {"Content-Type": "application/json", "User-Agent": USER_AGENT}
236235

237236
res = (session or _get_session()).post(
238237
url, data=data, headers=headers, timeout=timeout
@@ -304,7 +303,6 @@ def flags(
304303
**kwargs,
305304
) -> Any:
306305
"""Post the kwargs to the flags API endpoint with bounded transient retries."""
307-
user_agent = kwargs.pop("_user_agent", USER_AGENT)
308306
retries = max(0, max_retries)
309307
failed_attempt = 0
310308

@@ -316,7 +314,6 @@ def flags(
316314
"/flags/?v=2",
317315
timeout,
318316
session=_get_flags_session(),
319-
_user_agent=user_agent,
320317
**kwargs,
321318
)
322319
return _process_response(
@@ -343,24 +340,11 @@ def remote_config(
343340
timeout: int = 15,
344341
) -> Any:
345342
"""Get remote config flag value from remote_config API endpoint"""
346-
return _remote_config(personal_api_key, project_api_key, host, key, timeout)
347-
348-
349-
def _remote_config(
350-
personal_api_key: str,
351-
project_api_key: str,
352-
host: Optional[str] = None,
353-
key: str = "",
354-
timeout: int = 15,
355-
*,
356-
_user_agent: str = USER_AGENT,
357-
) -> Any:
358-
response = _get(
343+
response = get(
359344
personal_api_key,
360345
f"/api/projects/@current/feature_flags/{key}/remote_config?token={project_api_key}",
361346
host,
362347
timeout,
363-
_user_agent=_user_agent,
364348
)
365349
return response.data
366350

@@ -379,25 +363,10 @@ def get(
379363
- not_modified=True and data=None if server returns 304
380364
- not_modified=False and data=response if server returns 200
381365
"""
382-
return _get(api_key, url, host, timeout, etag)
383-
384-
385-
def _get(
386-
api_key: str,
387-
url: str,
388-
host: Optional[str] = None,
389-
timeout: Optional[int] = None,
390-
etag: Optional[str] = None,
391-
*,
392-
_user_agent: str = USER_AGENT,
393-
) -> GetResponse:
394366
log = logging.getLogger("posthog")
395367
trimmed_host = remove_trailing_slash(normalize_host(host))
396368
full_url = trimmed_host + url
397-
headers = {
398-
"Authorization": "Bearer %s" % api_key,
399-
"User-Agent": _user_agent,
400-
}
369+
headers = {"Authorization": "Bearer %s" % api_key, "User-Agent": USER_AGENT}
401370

402371
if etag:
403372
headers["If-None-Match"] = etag

0 commit comments

Comments
 (0)