Skip to content

fix!: match capture v1 rules for ids, timestamps and size - #367

Open
eli-r-ph wants to merge 4 commits into
v1-options-parityfrom
v1-session-id-lift
Open

eli-r-ph wants to merge 4 commits into
v1-options-parityfrom
v1-session-id-lift

Conversation

@eli-r-ph

@eli-r-ph eli-r-ph commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Stacked on #359.

Capture v1 drops or delays some events that the Go SDK sends as is today.
This PR fixes each case so events arrive as the caller expects.

Changes

  • $session_id and $window_id are sent only when they encode as JSON strings; other values are dropped with a warning.
  • An invalid event Uuid is replaced with a new one and logs a warning, also when set in BeforeSend.
  • Request timestamps carry sub-second precision, so clock-skew correction no longer shifts events by up to a second.
  • $groupidentify now sends GroupIdentify.DistinctId, then the request context's ID, then $<type>_<key>.
  • An empty or whitespace-only distinct ID counts as missing.
  • Analytics has no per-event size cap by default, because capture drops an oversize event on its own.
    • MaxEventBytes still sets an optional cap, and DefaultMaxEventBytes is removed.
  • The debug log no longer prints event contents.

💚 How did you test it?

  • Table tests cover each rule, including values set in BeforeSend.
  • go vet, go test -race and make api-diff pass in all three modules.

🤖 Agent context

Autonomy: Human-driven (agent-assisted). Written with Claude Code. Same rules in posthog-rs: PostHog/posthog-rs#285.

🤖 Generated with Claude Code

@eli-r-ph eli-r-ph self-assigned this Oct 10, 2026
@eli-r-ph
eli-r-ph marked this pull request as ready for review October 10, 2026 04:03
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 10, 2026 04:03
@eli-r-ph eli-r-ph changed the title fix: lift JSON-string session ids and warn on every drop fix: lift JSON-string session ids and enforce the event uuid rule Oct 10, 2026
Comment thread posthog.go
@veria-ai

veria-ai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@eli-r-ph eli-r-ph changed the title fix: lift JSON-string session ids and enforce the event uuid rule fix!: match capture v1 rules for ids, timestamps and size Oct 13, 2026

@dustinbyrne dustinbyrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The wire-format and identity corrections look sound. One optional documentation clarification below.

AI-assisted review.

Comment thread config.go Outdated
eli-r-ph and others added 4 commits October 20, 2026 08:43
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.
…vent cap

- PostHog-Request-Timestamp and created_at use RFC 3339 with nanoseconds.
  Capture corrects clock skew against the header, so whole seconds moved
  every event up to a second later.
- $groupidentify uses GroupIdentify.DistinctId, then the request context's
  distinct ID, then "$<type>_<key>". DistinctId was accepted and ignored.
- An empty or whitespace-only distinct ID is treated as missing.
- The analytics lane has no per-event size cap by default (MaxEventBytes 0).
  Capture v1 drops an oversized event on its own and reports it per event, so
  the old 500,000-byte cap only refused events PostHog accepts. An event over
  MaxBatchBytes is sent alone. DefaultMaxEventBytes is removed.
- The batch debug log no longer prints each message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

2 participants