Skip to content

Update dependency posthog to v7 - #2765

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/posthog-7.x
Open

Update dependency posthog to v7#2765
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/posthog-7.x

Conversation

@renovate

@renovate renovate Bot commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
posthog >=5.0.0,<6>=7.30,<8 age confidence

Warning

Some dependencies could not be looked up. Check the Dependency Dashboard for more information.


Release Notes

posthog/posthog-python (posthog)

v7.30.0

Compare Source

Minor changes
  • 37aafd3 feat(mcp): stateless and multi-pod server support — carry $session_id and the client identity (harness) across pods via a self-encoded Mcp-Session-Id token minted at initialize and replayed on every request. Auto-wired on the instrument() FastMCP path (stateless_http=True); custom PostHogMCP dispatchers add PostHogMcpStatelessSessionMiddleware and read get_mcp_session(). — Thanks @​gesh!

v7.29.0

Compare Source

Minor changes
  • f9a163c Refactored capture internals to support multiple delivery lanes per client. Added an internal test lane for heavy AI events.

    Events captured after shutdown() are now dropped with a warning instead of being silently queued with no consumer to deliver them. — Thanks @​carlos-marchal-ph!

v7.28.0

Compare Source

Minor changes
  • 2d7f8cc The client.metrics config can now be set through module-level settings: assign posthog.metrics = {"service_name": ..., ...} alongside posthog.api_key and the dict is applied when setup() builds the global client. Previously module-configured apps had no way to pass the metrics config, so every series recorded through the global client shipped service.name='unknown_service'. Late assignment (e.g. a Django ready() hook running after an early setup()) still applies on the next setup() call, as long as the metrics API hasn't been used yet. — Thanks @​DanielVisca!
Patch changes
  • 6766309 Harden the alpha posthog.metrics client based on review follow-ups.

    • Metric attributes are now deep-snapshotted at capture time, so mutating a nested list/dict value after count()/gauge()/histogram() can no longer rewrite an already-recorded series' attributes on the wire.
    • Failed metric flushes now retry with exponential backoff (first retry at the base interval, then doubling per consecutive failure, capped at 64x the flush interval — the shared JS logs ramp) instead of the fixed cadence, and the buffered window is dropped loudly after 8 consecutive failed flushes — previously documented as 3 but effectively 4.
    • Invalid metrics client config (non-dict config or resource_attributes, non-numeric flush_interval, non-integer max_series_per_flush, non-callable before_send) now degrades to defaults with a warning instead of raising from the first client.metrics.count() call, matching the client's no-throw contract. — Thanks @​DanielVisca!

v7.27.1

Compare Source

Patch changes
  • ca5e883 Clarify the queue-full warning to say the event is being dropped, instead of only reporting that the queue is full. — Thanks @​emmayusufu for your first contribution 🎉!

v7.27.0

Compare Source

Minor changes
  • 5ef2c23 $feature_flag_called events are now minimized for non-experiment flags when the server enables it. When the /flags v2 response (minimalFlagCalledEvents) or the local-evaluation payload (minimal_flag_called_events) reports the gate as enabled and the evaluated flag has no linked experiment (has_experiment is false), the event's properties are reduced to a strict allowlist ($feature_flag, $feature_flag_response, $feature_flag_has_experiment, the $feature_flag_* debug scalars, locally_evaluated, $groups, $process_person_profile, $session_id, $lib, $lib_version, $is_server, $geoip_disable, $os, $os_version, $os_distro, $python_runtime, $python_version). Everything else — including super properties and custom event properties — is stripped from those events.

    If the server does not report the gate, if the flag's has_experiment signal is missing, or if the flag is linked to an experiment, the full property set is sent unchanged. There is no SDK-side configuration; the gate is controlled per-team by the server. For evaluate_flags() snapshots, the gate is pinned when the snapshot is created, so deferred flag accesses are shaped by the evaluation that produced them.

    Custom flag_definition_cache providers now receive an additional minimal_flag_called_events key in the definitions payload, so the gate survives external cache round-trips.

    When the server reports has_experiment for a flag, every $feature_flag_called event also carries a $feature_flag_has_experiment boolean property. — Thanks @​haacked!

v7.26.0

Compare Source

Minor changes
  • 1653bcb Add a label option to Prompts.get() to fetch the prompt version a label (e.g. production) currently points to. Labeled fetches are cached separately, and PromptResult carries the resolved label. Requires a PostHog version with prompt labels; older servers ignore the parameter and return the latest version. — Thanks @​jurajmajerik!

v7.25.0

Compare Source

Minor changes
  • 5ab6318 Add the active OpenTelemetry span's $trace_id and $span_id to events captured with capture_exception. — Thanks @​hpouillot!

v7.24.0

Compare Source

Minor changes
  • 556c134 $feature_flag_called events now carry a $feature_flag_has_experiment boolean property when the server reports whether the flag is linked to an experiment. When the server does not report the signal (older deployments), the property is omitted. — Thanks @​haacked!

v7.23.0

Compare Source

Minor changes
  • 5e42b1e Add the posthog.metrics API (count, gauge, histogram) — alpha.

    Backend services can now record metrics through the same statsd-style pre-aggregating client the browser SDK ships, with no OpenTelemetry setup:

    client = Posthog("<ph_project_api_key>", metrics={"service_name": "billing-worker"})
    client.metrics.count("invoices.processed", 1, attributes={"plan": "pro"})
    client.metrics.gauge("queue.depth", 42)
    client.metrics.histogram("job.duration", 187, unit="ms")

    Samples aggregate in memory and flush as OTLP/JSON to /i/v1/metrics (one data point per series per window, delta temporality). Pending metrics are flushed on shutdown(); buffered windows are retried on transient failures and dropped loudly after 3 consecutive failed flushes. The metrics client option accepts service_name, service_version, environment, resource_attributes, flush_interval (seconds), max_series_per_flush (cardinality guardrail, default 1000), and a before_send hook. — Thanks @​DanielVisca!

v7.22.4

Compare Source

Patch changes
  • eb025c8 Django middleware also sends the request user agent as $raw_user_agent, the standardized property PostHog's server-side classification (e.g. bot detection) reads — Thanks @​lricoy!

v7.22.3

Compare Source

Patch changes
  • ae3c4e5 Malformed flag-dependency conditions (missing key, null value, or wrong operator) now evaluate locally as no-match (false), matching the server, instead of falling back to the /flags endpoint on every evaluation. 7.22.1 made these conditions fall back to the server, which could massively increase billable /flags request volume for flag definitions containing legacy/malformed dependency conditions. — Thanks @​patricio-posthog!

v7.22.2

Compare Source

Patch changes
  • 4d61b18 Capture pre-calculated total cost from OpenAI Agents Responses API usage. — Thanks @​fuchengwarrenzhu for your first contribution 🎉!

v7.22.1

Compare Source

Patch changes
  • 650d107 Fix local evaluation of flag dependencies with a flag_evaluates_to: false condition: such conditions never matched, forcing the dependent flag to false for every locally-evaluated user. — Thanks @​matheus-vb!

v7.22.0

Compare Source

Minor changes
  • d459b57 Add an opt-in capture_mode for the Capture V1 ingestion protocol (POST /i/v1/analytics/events). Set capture_mode="v1" on the client (or the POSTHOG_CAPTURE_MODE=v1 environment variable) to use Bearer auth, per-event results, and partial retry. Defaults to "v0" (the legacy /batch/ endpoint), so existing setups are unaffected.

    When using capture_mode="v1", request bodies can be compressed via capture_compression (or POSTHOG_CAPTURE_COMPRESSION): "gzip", "deflate", "zstd" (requires the optional posthog[zstd] extra), or "none" (default). The legacy gzip=True flag is honored as a fallback.

    Per-event server verdicts are surfaced through the existing on_error handler: events the backend explicitly drops, or fails to accept after retries, raise a CaptureV1Error carrying the affected event UUIDs — so a rejection is never silently lost, even when the HTTP request itself succeeded. — Thanks @​eli-r-ph for your first contribution 🎉!

v7.21.3

Compare Source

Patch changes

v7.21.2

Compare Source

Patch changes

v7.21.1

Compare Source

Patch changes

v7.21.0

Compare Source

Minor changes
  • 888a725 Add posthog.mcp, a Python SDK for PostHog MCP analytics (just pip install posthog; the MCP SDK is a peer dependency of instrument(), not bundled). instrument(server, posthog_client) wraps a FastMCP or low-level mcp.server.Server so every tool call, agent intent, tools/list, initialize, and failure is captured to PostHog as a $mcp_* event. Also adds PostHogMCP, a Client subclass for custom dispatchers (needs nothing beyond posthog), plus opt-in context intent capture, identify, report_missing (get_more_tools), and conversation_id. Beta. — Thanks @​lucasheriques for your first contribution 🎉!

v7.20.5

Compare Source

Patch changes

v7.20.4

Compare Source

Patch changes

v7.20.3

Compare Source

Patch changes
  • 42ff4ca Detect and redact high-entropy secrets (API keys, tokens, passwords) in exception code variables. Adds the code_variables_detect_secrets option (default True). — Thanks @​ablaszkiewicz!

v7.20.2

Compare Source

Patch changes
  • c359f93 Mask sensitive data held inside objects and in URL/DSN credentials when capturing exception code variables. Custom objects are now traversed so fields like password are redacted by attribute name instead of leaking via repr(), and credentials embedded in connection strings are scrubbed. Adds the code_variables_mask_url_credentials option (default True). — Thanks @​ablaszkiewicz!
  • c359f93 Improve strict Pyright coverage for public PostHog APIs. — Thanks @​ablaszkiewicz!

v7.20.1

Compare Source

Patch changes
  • 09c8fba Warn on duplicate async PostHog clients and document client lifecycle guidance — Thanks @​marandaneto!

v7.20.0

Compare Source

Minor changes

v7.19.2

Compare Source

Patch changes

v7.19.1

Compare Source

Patch changes
  • 8d416ae Add missing return type annotations to improve typing coverage without changing runtime behavior. — Thanks @​miachillgood for your first contribution 🎉!

v7.19.0

Compare Source

Minor changes
  • b9f3208 Add opt-in client-side rate limiting for exception autocapture, using the same token bucket algorithm as the posthog-js and posthog-node SDKs: a bucket per exception type allows a burst of captures, then refills over time. Rate-limited exceptions are skipped before they reach the ingestion queue. Disabled by default; enable with the new enable_exception_autocapture_rate_limiting client option and tune via exception_autocapture_bucket_size (default 50), exception_autocapture_refill_rate (default 10), and exception_autocapture_refill_interval_seconds (default 10). — Thanks @​hpouillot!

v7.18.3

Compare Source

Patch changes
  • ee6a3c8 Warn when an AI wrapper's base_url points at the PostHog AI Gateway. The gateway emits its own $ai_generation, so each call would be captured (and billed) twice. The wrapper only warns and never drops the event. Detection covers the wrapper funnels (OpenAI, Anthropic, LangChain) and the OTel span path. — Thanks @​richardsolomou!

v7.18.2

Compare Source

Patch changes
  • fe76fc9 Improve mypy coverage for core SDK modules without changing runtime behavior. — Thanks @​Kshitijmishradev for your first contribution 🎉!

v7.18.1

Compare Source

Patch changes
  • 00b2091 Add internal-only routing of $ai_* events to a dedicated capture endpoint in their own batch, gated behind the unstable _dedicated_ai_endpoint client option (off by default, not for general use). — Thanks @​carlos-marchal-ph!

v7.18.0

Compare Source

Minor changes
  • a2ce51e feat(feature-flags): support the early_exit condition option in local evaluation. When a flag enables early exit, evaluation now stops and returns False as soon as a condition group's property filters match but the rollout percentage excludes the user, instead of falling through to later groups — matching the server-side evaluation behavior. — Thanks @​gustavohstrassburger!

v7.17.0

Compare Source

Minor changes
  • 3aed638 Add a configurable $is_server event property (default true) so PostHog can identify server-side events. Set is_server=False when using posthog-python as a client/CLI so the device OS is attributed normally. — Thanks @​turnipdabeets for your first contribution 🎉!

v7.16.4

Compare Source

Patch changes
  • 44e6b14 Fix async streaming responses from the AI wrappers (OpenAI, Anthropic, Gemini) so they support async with as well as async for. Previously, consuming a stream via async with (e.g. with pydantic-ai) raised TypeError: 'async_generator' object does not support the asynchronous context manager protocol. — Thanks @​turnipdabeets for your first contribution 🎉!

v7.16.3

Compare Source

Patch changes
  • 643a810 Return empty flag defaults from Client flag helpers when the flags API fails. — Thanks @​marandaneto!

v7.16.2

Compare Source

Patch changes

v7.16.1

Compare Source

Patch changes
  • 8f6d6c8 Include group context in the $feature_flag_called dedupe key so group-scoped flags fire a separate event for each group a user is evaluated under, instead of being dedup-ed against the first group context the same (distinct_id, flag, response) was seen under. — Thanks @​gustavohstrassburger!

v7.16.0

Compare Source

Minor changes

v7.15.4

Compare Source

Patch changes

v7.15.3

Compare Source

Patch changes
  • be9b78b Reject semver values with leading zeros in local flag evaluation. Per semver 2.0.0 §2, numeric identifiers must not include leading zeros — values like 1.07.3 are not valid semver and should not match targeting conditions. Both override values and flag values are now validated; invalid inputs raise InconclusiveMatchError so the condition does not match. — Thanks @​dmarticus!

v7.15.2

Compare Source

Patch changes

v7.15.1

Compare Source

Patch changes

v7.15.0

Compare Source

Minor changes

v7.14.2

Compare Source

Patch changes

v7.14.1

Compare Source

Patch changes
  • f6c8ede fix: type warning on new_context — Thanks @​itsaphel for your first contribution 🎉!

v7.14.0

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@7.13.2...7.14.0

v7.13.2

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@7.13.1...7.13.2

v7.13.1

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@7.13.0...7.13.1

v7.13.0

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.12.0...7.13.0

v7.12.0

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.11.2...v7.12.0

v7.11.2

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.11.1...v7.11.2

v7.11.1

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.11.0...v7.11.1

v7.11.0

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.10.3...v7.11.0

v7.10.3

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.10.2...v7.10.3

v7.10.2

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.10.1...v7.10.2

v7.10.1

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.10.0...v7.10.1

v7.10.0

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.9.12...v7.10.0

v7.9.12

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.9.11...v7.9.12

v7.9.11

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.10...v7.9.11

v7.9.10

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.9...v7.9.10

v7.9.9

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.8...v7.9.9

v7.9.8

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.7...v7.9.8

v7.9.7

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.9.6...v7.9.7

v7.9.6

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.5...v7.9.6

v7.9.5

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.4...v7.9.5

v7.9.4

Compare Source

What's Changed

New Contributors

Full Changelog: PostHog/posthog-python@v7.9.3...v7.9.4

v7.9.3

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.2...v7.9.3

v7.9.2

What's Changed

Full Changelog: PostHog/posthog-python@v7.9.0...v7.9.2

v7.9.0: 7.9.0

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.8.6...v7.9.0

v7.8.6: 7.8.6

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.8.5...v7.8.6

v7.8.5: 7.8.5

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.8.4...v7.8.5

v7.8.4: 7.8.4

Compare Source

What's Changed

Full Changelog: PostHog/posthog-python@v7.8.3...v7.8.4

v7.8.3: 7.8.3

Compare Source

What's Changed

Note

PR body was truncated to here.


Configuration

📅 Schedule: (in timezone US/Eastern)

  • Branch creation
    • "every weekend"
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
renovate Bot force-pushed the renovate/posthog-7.x branch 4 times, most recently from 5f99506 to 2e80889 Compare December 1, 2025 16:18
@renovate
renovate Bot force-pushed the renovate/posthog-7.x branch 13 times, most recently from 0ebd496 to 7eacc99 Compare December 12, 2025 21:24
@renovate
renovate Bot force-pushed the renovate/posthog-7.x branch 13 times, most recently from 081ca27 to 450b7fb Compare December 18, 2025 04:01
@renovate
renovate Bot force-pushed the renovate/posthog-7.x branch 11 times, most recently from 70c7b6f to 4417b6e Compare January 14, 2026 18:17
@github-actions

github-actions Bot commented Jan 22, 2026

Copy link
Copy Markdown

OpenAPI Changes

No changes detected

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment thread pyproject.toml Outdated
Comment on lines 84 to 90
opentelemetry-instrumentation-requests = ">=0.52b0"
opentelemetry-sdk = ">=1.31.0"
pluggy = "^1.3.0"
posthog = "^5.0.0"
posthog = "^7.0.0"
psycopg = "^3.2.4"
psycopg2 = "^2.9.6"
pycountry = "^24.6.1"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Calls to PostHog functions like posthog.capture use positional arguments that may have become keyword-only in the upgraded version, potentially causing a TypeError at runtime.
Severity: MEDIUM

Suggested Fix

Update all calls to posthog.capture, posthog.get_all_flags, and posthog.get_feature_flag to use explicit keyword arguments to match the new API. For example, change posthog.capture(user.id, ...) to posthog.capture(distinct_id=user.id, ...).

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: pyproject.toml#L84-L90

Potential issue: The `posthog` library was upgraded, and versions since v6 have
introduced breaking changes to function signatures. Calls to `posthog.capture`,
`posthog.get_all_flags`, and `posthog.get_feature_flag` in the codebase use positional
arguments (e.g., `posthog.capture(user.id, ...)`). The newer library versions may
require these arguments to be passed as keyword arguments (e.g., `distinct_id=user.id`).
If backward compatibility is not maintained in v7, these function calls will raise a
`TypeError` at runtime. This potential issue is not covered by the test suite because
the `posthog` functions are mocked, preventing signature validation against the actual
library.

Comment thread pyproject.toml Outdated
"opentelemetry-sdk>=1.31.0",
"pluggy>=1.3.0,<2",
"posthog>=5.0.0,<6",
"posthog>=7.9.4,<8",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The call to posthog.capture() in main/middleware/apisix_user.py uses a positional argument for the user ID, but the upgraded PostHog library requires a keyword argument (distinct_id=...).
Severity: CRITICAL

Suggested Fix

In main/middleware/apisix_user.py, change the call to posthog.capture() to use the keyword argument distinct_id for the user ID. The corrected call should be posthog.capture(distinct_id=user.id, event=..., properties={...}).

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: pyproject.toml#L83

Potential issue: The `posthog` library was upgraded to v7, which requires keyword
arguments for the `capture` method. The code in `main/middleware/apisix_user.py` calls
`posthog.capture(user.id, ...)` using a positional argument for the distinct ID. In
PostHog v7, this positional argument is interpreted as the `event` parameter. Since the
`event` keyword argument is also supplied in the call, this will raise a `TypeError` at
runtime due to a duplicate argument. This error will occur whenever a new user account
is created, preventing the account creation process from completing successfully.

Comment thread pyproject.toml Outdated
"opentelemetry-sdk>=1.31.0",
"pluggy>=1.3.0,<2",
"posthog>=5.0.0,<6",
"posthog>=7.9.4,<8",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: A temporary Posthog instance in apisix_user.py is garbage collected before its asynchronously queued events can be sent, causing silent event loss.
Severity: HIGH

Suggested Fix

To ensure the event is sent, either call posthog.shutdown() after the .capture() call, instantiate the client with sync_mode=True, or use the existing singleton posthog.default_client from main/features.py.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: pyproject.toml#L83

Potential issue: In `main/middleware/apisix_user.py`, a one-off `Posthog` instance is
created to track user creation events. The PostHog v7 SDK sends events asynchronously by
default, queuing them to be sent by a background thread. However, because the `Posthog`
instance is not stored and no `posthog.shutdown()` or `posthog.flush()` is called, the
instance is garbage collected before the background thread can send the queued event.
This results in the silent loss of all user creation events, which are critical for
telemetry and usage analysis.

Comment thread pyproject.toml Outdated
"opentelemetry-sdk>=1.31.0",
"pluggy>=1.3.0,<2",
"posthog>=5.0.0,<6",
"posthog>=7.9.7,<8",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The posthog.capture() call uses a positional argument for distinct_id, which is incompatible with the PostHog v7 API and will cause a runtime failure.
Severity: HIGH

Suggested Fix

Update the posthog.capture() call in main/middleware/apisix_user.py to use a keyword argument for the user's ID. Change the call from posthog.capture(user.id, event=...) to posthog.capture(distinct_id=user.id, event=...) to match the v6+ API.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: pyproject.toml#L83

Potential issue: The upgrade of the `posthog` library from v5 to v7 introduces a
breaking API change. The `posthog.capture()` method in `main/middleware/apisix_user.py`
is called with a positional argument for the user's ID (`user.id`), following the old v5
pattern. However, PostHog v6 and later require this to be a keyword argument,
`distinct_id=user.id`. This will cause a runtime error, likely a `TypeError`, or a
silent failure when a new user is created via the APISIX authentication pathway. As a
result, account creation events will not be tracked. This issue is not caught by
existing tests because the `Posthog` class is mocked without signature validation.

Comment thread pyproject.toml Outdated
"opentelemetry-sdk>=1.31.0",
"pluggy>=1.3.0,<2",
"posthog>=5.0.0,<6",
"posthog>=7.9.8,<8",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The call to posthog.capture() uses an outdated positional argument for user.id, which will cause a TypeError with the updated PostHog v7 library during user creation.
Severity: HIGH

Suggested Fix

Update the posthog.capture() call in main/middleware/apisix_user.py to use keyword arguments as required by the new version of the library. The distinct_id should be passed as a keyword argument, not a positional one. The corrected call should look like: posthog.capture(event=PostHogEvents.ACCOUNT_CREATED.value, distinct_id=user.id, properties={...}).

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: pyproject.toml#L83

Potential issue: The upgrade of the `posthog` library from version 5 to 7 introduces a
breaking API change that is not accounted for. The `posthog.capture()` method in
`main/middleware/apisix_user.py` is called with a positional argument for the user ID:
`posthog.capture(user.id, event=...)`. In PostHog v7, the first argument is expected to
be the event name, and the `distinct_id` (user ID) must be passed as a keyword argument.
This mismatch will cause a `TypeError` at runtime whenever a new user account is
created, breaking the user creation flow.

@renovate

renovate Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

⚠️ Artifact update problem

Renovate failed to update an artifact related to this branch. You probably do not want to merge this PR as-is.

♻ Renovate will retry this branch, including artifacts, only when one of the following happens:

  • any of the package files in this branch needs updating, or
  • the branch becomes conflicted, or
  • you click the rebase/retry checkbox if found above, or
  • you rename this PR's title to start with "rebase!" to trigger it manually

The artifact failure details are included below:

File name: pyproject.toml
Artifact update for posthog resolved to version 7.35.5, which is a pending version that has not yet passed the Minimum Release Age threshold.
Renovate was attempting to update to 7.30.0
This is (likely) not a bug in Renovate, but due to the way your project pins dependencies, _and_ how Renovate calls your package manager to update them.
Until Renovate supports specifying an exact update to your package manager (https://github.com/renovatebot/renovate/issues/41624), it is recommended to directly pin your dependencies (with `rangeStrategy=pin` for apps, or `rangeStrategy=widen` for libraries)
See also: https://docs.renovatebot.com/dependency-pinning/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants