fix: remove ignored batch event fields#176
Merged
Merged
Conversation
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
lib/Client.php:349-353
**`groups: []` still leaks out of `identify()` and `alias()` payloads**
The `message()` helper (line 1690-1692) always injects `"groups" => []` as a default, and `capture()` explicitly unsets it at line 291. But `identify()` and `alias()` have no matching `unset($message["groups"])`, so every identify/alias event still ships `"groups":[]` to the batch endpoint — the very noise this PR aims to eliminate. The same one-liner added to `capture()` would fix both methods.
Reviews (1): Last reviewed commit: "fix: remove ignored batch event fields" | Re-trigger Greptile |
5859a1c to
1458fc0
Compare
|
Reviews (2): Last reviewed commit: "fix: remove ignored batch event fields" | Re-trigger Greptile |
ioannisj
approved these changes
Jun 18, 2026
1458fc0 to
60442c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
The backend
/batch/endpoint ignores several legacy top-level fields on individual events (type,library,library_version,library_consumer, andsend_feature_flags). Keeping them in SDK payloads adds noise and can confuse which fields are canonical.This change strips those deprecated top-level fields before sending events and keeps the backend-supported canonical SDK metadata in event properties instead. For backwards compatibility, legacy top-level
library,library_version, andlibrary_consumervalues are still used as event-property fallbacks when the canonical$lib,$lib_version, or$lib_consumervalues are absent. Top-leveltypeis ignored and not used as a fallback. The HTTPUser-Agentnow always uses the officialPostHog::LIBRARY/PostHog::VERSIONconstants regardless of event metadata.💚 How did you test it?
composer run api:checkphp -lon changed PHP files./vendor/bin/phpunit --testsuite posthog-php(tests pass: 339 tests / 3391 assertions; command exits non-zero because PHPUnit reports no code coverage driver)git diff --check📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
An AI coding agent made the implementation and validation changes at the direction of the maintainer. The backend batch schema was checked first, then the SDK was updated to stop sending ignored per-event top-level fields while preserving canonical
$lib,$lib_version, and$lib_consumerproperties. Backwards compatibility was preserved for legacy top-level SDK metadata values as event-property fallbacks when canonical values are absent;typeremains a no-op. Existing payload assertions and file-consumer expectations were updated to match the canonical shape.