Skip to content

fix(events): gzip analytics event payloads when compression is enabled - #442

Merged
abelonogov-ld merged 1 commit into
andrey/event-durability-tier3-persistencefrom
andrey/analytics-event-compression
Nov 21, 2026
Merged

abelonogov-ld merged 1 commit into
andrey/event-durability-tier3-persistencefrom
andrey/analytics-event-compression

Conversation

@abelonogov-ld

@abelonogov-ld abelonogov-ld commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #408 (tier 3).

main added EventProcessorBuilder.enableCompression (#414). Since tier 3, analytics events are posted by AnalyticsEventSender, which ignored that option, so only diagnostic events were compressed and EventCompressionTest.eventPayloadsAreGzipEncodedWhenCompressionIsEnabled failed.

  • AnalyticsEventSender takes a compress flag, wired from enableCompression in ComponentsImpl.
  • When it is set, the body is gzip-encoded at send time with Content-Encoding: gzip. The batch on disk stays plain JSON, so every attempt at a delivery, including one by a later run, compresses the same bytes under the same payload ID.
  • If compression fails, the batch goes uncompressed with a warning, rather than not at all.

EventCompressionTest passes on this branch.


Note

Overview
Analytics event delivery now honors EventProcessorBuilder.enableCompression, which previously only affected diagnostic posts via DefaultEventSender.

AnalyticsEventSender accepts a compress flag (wired from enableCompression in ComponentsImpl). When enabled, each sendBatch gzip-encodes the JSON body and sets Content-Encoding: gzip; persisted batches on disk remain plain JSON so retries and later app runs re-compress the same bytes under the same payload ID. If gzip fails, the batch is sent uncompressed with a warning instead of being dropped.

Tests construct AnalyticsEventSender with an explicit compress argument so EventCompressionTest can assert analytics payloads are gzip-encoded when compression is on.

Reviewed by Cursor Bugbot for commit 71ed617. Bugbot is set up for automated code reviews on this repo. Configure here.

Persisted batches are posted by AnalyticsEventSender, which ignored EventProcessorBuilder.enableCompression, so only diagnostic events were compressed. The batch on disk stays plain JSON; each attempt compresses it, and one that cannot be compressed goes uncompressed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abelonogov-ld
abelonogov-ld requested a review from a team as a code owner November 21, 2026 00:34

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: medium. SDK rule 2 (Approve only PRs opened by an SDK team member): the author is not on that list, so this was not approved. Human review is needed and no reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK - Pull Request Router and Approver

@abelonogov-ld
abelonogov-ld merged commit 71ed617 into andrey/event-durability-tier3-persistence Nov 21, 2026
8 checks passed
@abelonogov-ld
abelonogov-ld deleted the andrey/analytics-event-compression branch November 21, 2026 00:51
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