Skip to content

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Feb 10, 2026

Note

Medium Risk
Touches core analytics event buffering/flush and JSON output paths; enabling per-context summarization changes payload shape/volume and includes context data in summary events, so regressions could affect event delivery and privacy expectations.

Overview
Adds an optional per-context summarization mode that can emit multiple summary events per flush (one per LDContext) instead of a single aggregated summary.

Refactors the event pipeline to use a new EventSummarizerInterface with AggregatedEventSummarizer (backward-compatible default) and PerContextEventSummarizer, extends EventsConfiguration with a perContextSummarization flag, and updates DefaultEventProcessor/EventOutputFormatter to send/restore a list of summaries and to include serialized context in summary output when present. Tests are updated and a comprehensive PerContextEventSummarizerTest is added.

Written by Cursor Bugbot for commit 3a0f579. This will update automatically on new commits. Configure here.

@kinyoklion
Copy link
Member Author

bugbot review

@kinyoklion kinyoklion marked this pull request as ready for review February 10, 2026 22:43
@kinyoklion kinyoklion requested a review from a team as a code owner February 10, 2026 22:43
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

EventSummarizer summarizer = summarizersByContext.get(context);
if (summarizer == null) {
summarizer = new EventSummarizer(context);
summarizersByContext.put(context, summarizer);
Copy link

Choose a reason for hiding this comment

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

Using LDContext as HashMap key causes incorrect grouping

Medium Severity

PerContextEventSummarizer uses LDContext as a HashMap key, but LDContext.equals()/hashCode() compare all attributes (name, anonymous, custom attributes, private attributes), not just identity (kind + key). Two contexts representing the same user but with different attribute values would produce separate summaries instead of being grouped together. Additionally, LDContext.hashCode() is explicitly documented as inefficient and "not an anticipated or recommended use case" for map keys. The existing ServerSideEventContextDeduplicator demonstrates the correct pattern: keying by getFullyQualifiedKey().

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

This is describing the correct behavior. We want summaries grouped by their exact context accounting for all attributes.

The performance isn't a concern for this use-case. (Even then the performance of this is actually fine given the number of attributes contexts have in practice.)

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