Skip to content

feat: Report dropped events through onEventsDropped and droppedEvents - #331

Open
tharunkumardeveloper wants to merge 2 commits into
Flagsmith:mainfrom
tharunkumardeveloper:events-dropped-callback
Open

tharunkumardeveloper wants to merge 2 commits into
Flagsmith:mainfrom
tharunkumardeveloper:events-dropped-callback

Conversation

@tharunkumardeveloper

Copy link
Copy Markdown

Part of #330.

What

Events the processor drops without sending were only logged. This adds a programmatic signal:

  • eventProcessorConfig.onEventsDropped({ count, reason }): called whenever events are dropped, with
    reason one of buffer_full (the buffer was full while a batch was in flight or kept), failed (a batch failed
    with a status that isn't retried) or unauthorised (the environment key was refused).
  • EventProcessor.droppedEvents: the running total.

An error thrown by the callback is logged and never reaches trackEvent.

Why

An app that sends experiment events can't tell from code that some were lost, so its experiment results can be
biased without anyone noticing. With the callback it can count, alert, or slow down. In #330's reproduction
(300 events/s, the events API answering after 5 s, defaults) 25% of events were dropped and only logged.

Tests

Four new tests in tests/sdk/events.test.ts: buffer-full drops reported and counted, a non-retried failure reported
as failed, a 401 reported as unauthorised with every buffered event, and a throwing callback not breaking tracking.
The existing event tests are unchanged and pass.

Not in this PR

The other half of #330: a buffer raised past ~7,000 events can produce a batch over the events API's 2 MiB limit,
which is then refused whole. Splitting batches by size would fix that; happy to follow up if that direction suits
you after #325's changes.

…edEvents

Part of Flagsmith#330: a programmatic signal when the event processor drops events without sending them.
@tharunkumardeveloper
tharunkumardeveloper requested a review from a team as a code owner November 26, 2026 17:14
@tharunkumardeveloper
tharunkumardeveloper requested review from khvn26 and removed request for a team November 26, 2026 17:14

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 3 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

Re-trigger cubic

Comment thread sdk/events.ts Resolved
Comment thread tests/sdk/events.test.ts Resolved
Comment thread sdk/events.ts Resolved
Comment thread tests/sdk/events.test.ts Resolved
- A buffer-full drop is reported once the new event is in the buffer, and drops caused while onEventsDropped
  runs (by events it tracks itself) are counted in droppedEvents without calling it again: no recursion, and the
  buffer never exceeds maxBuffer.
- Events tracked after the environment key was refused are reported as unauthorised and counted.
- Tests: the 401 case buffers a second event while the request is pending; events tracked after the refusal;
  a callback that tracks events; the throwing callback's error is logged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tharunkumardeveloper tharunkumardeveloper changed the title feat(events): report dropped events through onEventsDropped and droppedEvents feat: Report dropped events through onEventsDropped and droppedEvents Nov 27, 2026

@cubic-dev-ai cubic-dev-ai 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.

0 issues found across 2 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Auto-approval skipped because this PR is from an external contributor.

Re-trigger cubic

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