Skip to content

feat: split background analytics sends at 5 MiB - #288

Open
eli-r-ph wants to merge 1 commit into
v1from
v1-analytics-byte-batches
Open

eli-r-ph wants to merge 1 commit into
v1from
v1-analytics-byte-batches

Conversation

@eli-r-ph

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

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

PostHog refuses an analytics request over 10 MiB, and the SDK sends uncompressed by default. Batching by count alone let 100 large events exceed that and lose the whole batch.

Changes

  • Each background analytics send is split into requests of at most 5 MiB of serialized events.
  • An event larger than 5 MiB is sent alone; there is no per-event size cap.
  • before_send still runs at send time.
  • capture_batch_immediate still sends one request.
  • Migration guide and changeset.

💚 How did you test it?

  • One flush of [e1, e2, big, e3] sends [e1, e2], then big, then e3, with before_send at send time.
  • Removing the split, or building events at enqueue, fails a new test.
  • fmt, clippy and tests pass in every feature set; the public API is unchanged.

🤖 Generated with Claude Code

Capture V1 refuses an analytics body over 10 MiB, and the SDK sends bodies
uncompressed by default, so a count-only batch of large events could fail
whole. The analytics lane now splits each send by serialized bytes with the
check-before-append rule. Events are still built at send time, so
before_send timing is unchanged; immediate batches stay one request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eli-r-ph eli-r-ph self-assigned this Oct 13, 2026
@eli-r-ph
eli-r-ph marked this pull request as ready for review October 13, 2026 05:28
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 13, 2026 05:28
@eli-r-ph eli-r-ph changed the title feat: split background analytics batches into requests of at most 5 MiB feat: split background analytics sends at 5 MiB Oct 13, 2026

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.

1 participant