-
Notifications
You must be signed in to change notification settings - Fork 11
feat: Add optional support for per-context summary events. #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
bugbot review |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.)


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
summaryevents per flush (one perLDContext) instead of a single aggregated summary.Refactors the event pipeline to use a new
EventSummarizerInterfacewithAggregatedEventSummarizer(backward-compatible default) andPerContextEventSummarizer, extendsEventsConfigurationwith aperContextSummarizationflag, and updatesDefaultEventProcessor/EventOutputFormatterto send/restore a list of summaries and to include serializedcontextin summary output when present. Tests are updated and a comprehensivePerContextEventSummarizerTestis added.Written by Cursor Bugbot for commit 3a0f579. This will update automatically on new commits. Configure here.