Skip to content

fix: report capture's dropped duplicate copies as drops - #1113

Merged
eli-r-ph merged 2 commits into
v1from
v1-duplicates-dropped
Oct 23, 2026
Merged

eli-r-ph merged 2 commits into
v1from
v1-duplicates-dropped

Conversation

@eli-r-ph

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Capture v1 now keeps the first event for each uuid in a request and drops the later copies, instead of rejecting the whole batch (PostHog/posthog#122305). It reports the dropped copies as duplicates_dropped: n on that uuid's result. Without this change the SDK counts those copies as delivered with the kept copy's verdict, and resends them when that verdict is retry.

  • The first event with a uuid takes the result and details as before. The next n copies are reported in CaptureError.drops as (uuid, "duplicate_event_uuid") and never resent.
  • verdict_summary() counts each drop by its own reason, so a dropped copy no longer shows the kept copy's verdict.
  • Responses without duplicates_dropped behave as before, and a value that is not a positive integer is ignored.
  • The 8.0 migration guide and a changeset describe the new behavior.

💚 How did you test it?

  • Parse tests for duplicates_dropped, with string, bool, negative, zero, float and null values ignored.
  • One parameterized send test over the kept copy's verdict (ok, warning, drop, retry then ok, and a copy past the count) checks drops, resent uuids, event_results and verdict_summary().
  • A loss-message case with a duplicate drop next to a quota drop.
  • The new tests fail with the duplicate handling or the verdict_summary() fix reverted.
  • pytest posthog/test, ruff check, ruff format --check, mypy and make public_api_check pass locally.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Written with Claude Code (Claude Opus 5.5). Copies past n keep the existing behavior and take the kept copy's verdict. The private parse result carries the counts, so the public CaptureEventResult is unchanged.

🤖 Generated with Claude Code

Capture now keeps the first event for each uuid in a request and returns
duplicates_dropped on that uuid's result. The SDK reports that many later
copies as drops with reason duplicate_event_uuid and never resends them,
and verdict_summary counts each drop by its own reason.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@eli-r-ph eli-r-ph self-assigned this Oct 22, 2026
@eli-r-ph
eli-r-ph marked this pull request as ready for review October 22, 2026 23:24
@eli-r-ph
eli-r-ph requested a review from a team as a code owner October 22, 2026 23:24

@marandaneto marandaneto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code looks good; no qualifying findings. Verdict: correct.

@eli-r-ph
eli-r-ph merged commit 9972f15 into v1 Oct 23, 2026
42 checks passed
@eli-r-ph
eli-r-ph deleted the v1-duplicates-dropped branch October 23, 2026 15:58
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.

2 participants