Repository navigation
fix: only attach $sdk_debug_pending_queue_size once the queue reaches flushAt - #995
Open
marandaneto wants to merge 4 commits into
Open
marandaneto wants to merge 4 commits into
marandaneto wants to merge 4 commits into
Conversation
Contributor
posthog-android Compliance ReportDate: 2026-11-20 09:54:00 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
marandaneto
marked this pull request as ready for review
November 20, 2026 08:56
Contributor
There was a problem hiding this comment.
PostHog Review · Standard · reviewed 4edcf1d: 1 Should fix.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
ioannisj
approved these changes
Nov 20, 2026
ioannisj
left a comment
Contributor
There was a problem hiding this comment.
🤖 An AI agent wrote this on behalf of @ioannisj.
No findings from me. I looked at the backedUpSize threshold, the removal of caller and registered values in posthog/src/main/java/com/posthog/PostHog.kt, and the @Volatile read of the halved flushAt on capture threads, and it all looks right to me.
# Conflicts: # posthog-android/src/test/resources/json/snapshots/batch-request.json # posthog/api/posthog.api # posthog/src/main/java/com/posthog/PostHog.kt # posthog/src/test/java/com/posthog/PostHogTest.kt
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Every event carries
$sdk_debug_pending_queue_size, even when the queue holds fewer events thanflushAt. That is just normal batching, so the value adds bytes to every event without helping anyone find a delivery problem.Now the key is only attached once the queue holds at least
flushAtevents. That means a flush is due and has not happened yet, for example while offline or backing off. The threshold is the queue's currentflushAt, which already halves after a 413 response.PostHogQueueInterfacegets abackedUpSizeproperty that returnsnullby default. It is@PostHogInternal, so this is not a public API change, andposthog.apiis updated.The key stays SDK-owned. While the queue is healthy, a registered or caller-supplied value with the same name is removed instead of being sent. When the queue is backed up, the SDK value replaces it, as before.
Spec: PostHog/sdk-specs#238.
💚 How did you test it?
PostHogQueueTestcase forbackedUpSizebelow and atflushAt.PostHogTestcases: no key belowflushAt, including registered and caller values, and the depth reaching the next event while the queue is held offline. The second test fails whenbackedUpSizeis made to returnnull../gradlew :posthog:testforPostHogTest,PostHogQueueTestandPostHogStatelessTest(376 tests) and:posthog-android:testReleaseUnitTest(1036 tests) pass.apiCheckandmake checkFormatare clean.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)