Repository navigation
Conversation
eli-r-ph
marked this pull request as ready for review
October 10, 2026 04:03
3 of 4 tasks
Keeps a uuid.UUID, a named string type or an empty string as $session_id / $window_id, drops nil silently, and logs a warning that names the key and the value's type for any other dropped value.
eli-r-ph
force-pushed
the
v1-session-id-lift
branch
from
October 11, 2026 20:03
1149902 to
d29e7d5
Compare
eli-r-ph
force-pushed
the
v1-options-parity
branch
from
October 11, 2026 20:03
c36473b to
487b20b
Compare
This branch has not been deployed
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
Capture v1 requires
session_idandwindow_idto be strings and rejects the whole request otherwise, so every v1 SDK lifts only a string. Go's lift had two gaps against the agreed rule and against Python and Rust:v.(string), so it dropped values whose JSON form is a string: auuid.UUID, a named string type, or anyjson.Marshaler/encoding.TextMarshalerthat encodes to a string. Go 1.x sent all of these as strings.""for an absent key too, and theomitemptyfield then dropped a real empty string. Python and Rust send"", as Go 1.x sent the property.Changes:
liftStringPropertykeeps astringas is. For any other non-nil value, it marshals once and keeps the result if it is a JSON string. The payload fields are now*string, so""is sent and an absent key is still omitted.dropping $session_id: a number value is not a string. The warning names the key and the JSON type (or the Go type when the value cannot be marshaled), never the value.nil, including a typed nil pointer, counts as unset and drops silently, the same rule options use.buildEventandprepareForSendtake the clientLogger. The fiveEnqueuecall sites passc.Logger; tests passnil(rewritten withgofmt -r).A second commit applies the event uuid rule that every v1 SDK follows: an invalid caller uuid is replaced with a generated one and the SDK warns, and an empty or missing uuid is generated silently.
resolveEventUUIDnormalizes a validUuid, generates one for an emptyUuidwithout logging, and replaces an invalid one with one warning:event Uuid is not a valid UUID; sending the event with a generated UUID. The warning omits the value, because callers can put their own data in the field. Before, the replacement was silent.Enqueueapplies the rule beforeBeforeSendas before, and now again to the message the hook returns. Before, a hook that set an invalid or emptyUuidsent it as is, and capture rejected the whole batch. Re-checking a valid uuid costs one parse.Stacked on #359.
💚 How did you test it?
TestSessionAndWindowLiftOnlyJSONStringscovers a string,"",nil, a typed nil pointer, auuid.UUID, a named string type, a number, a bool, a slice, a map and a channel. It checks the top-level field (sent or omitted), that both keys leaveproperties, and the exact warnings, which also proves no value text is logged. The typed nil pointer case caught that unmarshalingnullinto a string yields"".TestEnqueue_UUID_InvalidPreSuppliednow also checks for exactly one warning, without the value, for all five message types.TestEnqueue_UUID_RuleAppliesAfterBeforeSendsets an invalid, an empty and an uppercaseUuidinBeforeSendfor all five types, and checks the sent uuid and the warnings. These 20 cases fail on the previous commit and pass on this one.gofmt -l,go vet ./...,go test -race ./...andmake api-diffpass locally.TestOpenMachOUniversalfails on my macOS machine with and without this change; CI runs it on Linux.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written with Cursor (Claude Opus 5.5) under the direction of the assignee, to apply the session and window ID rules and the event uuid rule agreed for every v1 SDK. The assignee also decided that, where a hook can change the uuid, the SDK applies the uuid rule again after the hook. Companion PR for posthog-rs: PostHog/posthog-rs#285.