fix: omit null object properties from serialized events - #137
Draft
marandaneto wants to merge 2 commits into
Draft
fix: omit null object properties from serialized events#137marandaneto wants to merge 2 commits into
marandaneto wants to merge 2 commits into
Conversation
Contributor
posthog-unity Compliance ReportDate: 2026-09-09 09:33:25 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
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
Custom event properties currently retain null object members in network payloads and persisted events. This implements the serialization rule in PostHog/sdk-specs#60 without restricting the existing capture inputs.
The shared event serializer now omits null object members recursively, including objects inside arrays. It preserves null array positions, empty objects, other scalar values, and caller-owned inputs. Existing fallback
ToStringconversion runs once per occurrence, including when it returns null. Generic serialization used for unrelated cache and state data is unchanged. Only the root$exception_listsubtree on$exceptionkeeps its existing nullable metadata semantics.Includes a patch changeset for
com.posthog.unity.💚 How did you test it?
EventPropertySerializationTests,JsonSerializerTests,FileStorageProviderTests, andPostHogEventTestsagainst the actual runtime sources on .NET 9. Tests inspect event and batch JSON, invoke the real before-send hook through reflection, write and reopen physical event files, load legacy events, and inspect final batch serialization. Queues do not start and have no network transport.dotnet format stylechecks.Draft validation limits: No Unity Editor/player, IL2CPP, UnityWebRequest, platform-specific storage, or full public SDK initialization testing was performed. The source/stub tests and build do not establish those platform checks. The full local test suite and local public API checker were not run. All 16 hosted checks passed for
b206fc756cdc5fee034d2b60ee55b1cc4da0333c, including build/public API, tests, formatting, security, and SDK compliance. Hosted compliance does not establish the native null-policy checks above because the Unity compliance adapter bypasses native serialization.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset fileThe changeset was authored directly in the repository's existing format. No release is requested.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented and validated with Pi using file tools, Git, .NET, CSharpier, the isolated autoreview helper, and GitHub CLI under human direction. The fix stays in the existing event serializer rather than adding a wrapper prepass or changing dependencies. Private session logs are not published. Human review and the native platform checks above remain required.