feat: Add configurable flush interval#171
Merged
Merged
Conversation
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
test/PostHogTest.php:551-631
**Duplicate tests should be a single parameterised test**
`testNegativeCaptureFlushIntervalDefaultsToFiveSeconds` and `testInvalidCaptureFlushIntervalDefaultsToFiveSeconds` are byte-for-byte identical except for the value of `flush_interval_seconds` (`-1` vs `"1"`). The project rule says to prefer parameterised tests and to say everything OnceAndOnlyOnce. A single `@dataProvider` method covering both invalid inputs would satisfy both rules and make it trivial to add further edge cases (e.g. `NAN`, `INF`, `null`) without another copy-paste block.
Reviews (1): Last reviewed commit: "feat: add configurable flush interval" | Re-trigger Greptile |
Member
Author
|
#170 would be the ideal word but its much more effort |
|
Reviews (2): Last reviewed commit: "test: parameterize invalid flush interva..." | Re-trigger Greptile |
ioannisj
approved these changes
Jun 18, 2026
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
PHP batching previously flushed queued events only when
batch_sizewas reached, via explicitflush(), or during cleanup. This adds a configurable flush interval mechanism for low-volume queues while accounting for PHP's lack of a portable in-process background timer.💚 How did you test it?
php -l lib/QueueConsumer.php && php -l lib/Client.php && php -l lib/PostHog.php && php -l test/PostHogTest.php./vendor/bin/phpunit test/PostHogTest.php --filter 'FlushInterval|testInvalidCaptureFlushIntervalDefaultsToFiveSeconds' --no-coveragephp scripts/check-public-api.phpgit diff --check! rg -n 'flush_interval_ms|"flush_interval"|flush_interval\?:' lib test README.md composer.json./vendor/bin/phpunit --no-coverage— passes with existing warnings/deprecations📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Pi coding agent assistance. The change keeps the public API minimal with only
flush_interval_seconds, defaults to 5 seconds, treats invalid, negative, or non-finite values as the default, flushes immediately when set to0, and uses opportunistic interval flushing on the next enqueue because PHP does not provide a portable request-local background timer. Follow-up review feedback clarified the existingtimeoutandmaximum_backoff_durationunits in PHPDoc without renaming those options.