fix(deps): update dependency posthog to v7#2765
Conversation
5f99506 to
2e80889
Compare
0ebd496 to
7eacc99
Compare
081ca27 to
450b7fb
Compare
70c7b6f to
4417b6e
Compare
OpenAPI ChangesShow/hide No detectable change.Unexpected changes? Ensure your branch is up-to-date with |
pyproject.toml
Outdated
| 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" |
There was a problem hiding this comment.
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.
pyproject.toml
Outdated
| "opentelemetry-sdk>=1.31.0", | ||
| "pluggy>=1.3.0,<2", | ||
| "posthog>=5.0.0,<6", | ||
| "posthog>=7.9.4,<8", |
There was a problem hiding this comment.
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.
pyproject.toml
Outdated
| "opentelemetry-sdk>=1.31.0", | ||
| "pluggy>=1.3.0,<2", | ||
| "posthog>=5.0.0,<6", | ||
| "posthog>=7.9.4,<8", |
There was a problem hiding this comment.
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.
pyproject.toml
Outdated
| "opentelemetry-sdk>=1.31.0", | ||
| "pluggy>=1.3.0,<2", | ||
| "posthog>=5.0.0,<6", | ||
| "posthog>=7.9.7,<8", |
There was a problem hiding this comment.
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.
pyproject.toml
Outdated
| "opentelemetry-sdk>=1.31.0", | ||
| "pluggy>=1.3.0,<2", | ||
| "posthog>=5.0.0,<6", | ||
| "posthog>=7.9.8,<8", |
There was a problem hiding this comment.
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.
This PR contains the following updates:
>=5.0.0,<6→>=7.9.10,<8Release Notes
posthog/posthog-python (posthog)
v7.9.10Compare Source
Patch changes
v7.9.9Compare Source
Patch changes
v7.9.8Compare Source
Patch changes
v7.9.7Compare Source
Patch changes
v7.9.6Compare Source
Patch changes
v7.9.5Compare Source
Patch changes
v7.9.4Compare Source
Patch changes
$ai_tokens_sourceproperty ("sdk" or "passthrough") to all$ai_generationevents to detect when token values are externally overridden viaposthog_properties— Thanks @carlos-marchal-ph!v7.9.3Compare Source
Patch changes
v7.9.2Patch changes
v7.9.1fix(llma): make prompt fetches deterministic by requiring project_api_key and sending it as token query param
v7.9.0Compare Source
feat: Support device_id as bucketing identifier for local evaluation
v7.8.6Compare Source
fix: limit collections scanning in code variables
v7.8.5Compare Source
fix: further optimize code variables pattern matching
v7.8.4Compare Source
fix: do not pattern match long values in code variables
v7.8.3Compare Source
fix: openAI input image sanitization
v7.8.2Compare Source
fix(llma): fix prompts default url
v7.8.1Compare Source
fix(llma): small fixes for prompt management
v7.8.0Compare Source
feat(llma): add prompt management
Adds the Prompt Management feature. At the time of release, this feature is in a closed alpha.
v7.7.0Compare Source
feat(ai): Add OpenAI Agents SDK integration
Automatic tracing for agent workflows, handoffs, tool calls, guardrails, and custom spans. Includes
$ai_total_tokens,$ai_error_typecategorization, and$ai_frameworkproperty.v7.6.0Compare Source
feat: add device_id to flags request payload
Add device_id parameter to all feature flag methods, allowing the server to track device identifiers for flag evaluation. The device_id can be passed explicitly or set via context using
set_context_device_id().v7.5.1Compare Source
fix: avoid return from finally block to fix Python 3.14 SyntaxWarning (#361) - thanks @jodal
v7.5.0Compare Source
feat: Capture Langchain, OpenAI and Anthropic errors as exceptions (if exception autocapture is enabled)
feat: Add reference to exception in LLMA trace and span events
v7.4.3Compare Source
Fixes cache creation cost for Langchain with Anthropic
v7.4.2Compare Source
feat: add
in_app_modulesoption to control code variables capturingv7.4.1Compare Source
fix: extract model from response for OpenAI stored prompts
When using OpenAI stored prompts, the model is defined in the OpenAI dashboard rather than passed in the API request. This fix adds a fallback to extract the model from the response object when not provided in kwargs, ensuring generations show up with the correct model and enabling cost calculations.
v7.4.0Compare Source
feat: Add automatic retries for feature flag requests
Feature flag API requests now automatically retry on transient failures:
Rate limit (429) and quota (402) errors are not retried.
v7.3.1Compare Source
fix: remove unused $exception_message and $exception_type
v7.0.1Compare Source
Try to use repr() when formatting code variables
v7.0.0Compare Source
NB Python 3.9 is no longer supported
v6.9.3Compare Source
v6.9.2Compare Source
v6.9.1Compare Source
v6.9.0Compare Source
v6.8.0Compare Source
v6.7.14Compare Source
v6.7.13Compare Source
v6.7.12Compare Source
v6.7.11Compare Source
$ai_frameworkproperty for framework integrations (e.g. LangChain)v6.7.10Compare Source
v6.7.9Compare Source
v6.7.8Compare Source
v6.7.7Compare Source
v6.7.6Compare Source
v6.7.5Compare Source
v6.7.4Compare Source
v6.7.3Compare Source
v6.7.2Compare Source
v6.7.1Compare Source
v6.7.0Compare Source
v6.6.1Compare Source
NoneTypeerror whengroup_propertiesisNonev6.6.0Compare Source
flag_keys_to_evaluateparameter to optimize feature flag evaluation performance by only evaluating specified flagsflag_keys_filteroption tosend_feature_flagsfor selective flag evaluation in capture eventsv6.5.0Compare Source
$context_tagsto an event to know which properties were included as tagsv6.4.1Compare Source
remote_configrequests for deterministic project routingv6.4.0Compare Source
v6.3.4Compare Source
$ai_toolsfor all providers and$ai_output_choicesfor all non-streaming provider flows properlyv6.3.3Compare Source
get_feature_flag_resultnow correctly returns FeatureFlagResult when payload is empty string instead of Nonev6.3.2Compare Source
v6.3.1: 6.3.1Compare Source
v6.3.0Compare Source
send_feature_flagsparameter to acceptSendFeatureFlagsOptionsobject for declarative control over local/remote evaluation and custom propertiesv6.2.1Compare Source
posthog_clientan optional argument in PostHog AI providers wrappers (posthog.ai.*), intuitively using the default client as the defaultv6.1.1Compare Source
v6.1.0Compare Source
v6.0.4Compare Source
v6.0.3Compare Source
v6.0.2Compare Source
Client::capture_exceptionv6.0.1Compare Source
$process_person_profileproperty when passed to capturev6.0.0Compare Source
This release contains a number of major breaking changes:
Optional[str], which is the UUID of the sent event, if it was sentidentify(preferposthog.set()), andpageandscreen(preferposthog.capture())Integration.To migrate to this version, you'll mostly just need to switch to using named keyword arguments, rather than positional ones. For example:
Generally, arguments are now appropriately typed, and docstrings have been updated. If something is unclear, please open an issue, or submit a PR!
Configuration
📅 Schedule: Branch creation - "every weekend" in timezone US/Eastern, 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.
This PR was generated by Mend Renovate. View the repository job log.