Skip to content

flush forcefully sends events regardless the delay#73

Merged
marandaneto merged 3 commits intomainfrom
fix/flush-forcefully
Jan 3, 2024
Merged

flush forcefully sends events regardless the delay#73
marandaneto merged 3 commits intomainfrom
fix/flush-forcefully

Conversation

@marandaneto
Copy link
Member

💡 Motivation and Context

https://github.com/postHog/posthog-js-lite/ sends events regardless the timer if flush is called manually.

https://posthog.com/questions/flush-interval-seconds-not-working

💚 How did you test it?

📝 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.

Copy link

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

I can't tell from the PR alone but I can at least clarify how it works elsewhere:

  1. By default events are queued and are only flushed as a batch once a timer passes or the size threshold is hit.
  2. However, a user can manually call the flush function to force whatever is in the buffer to be flushed.

If this code achieves that then 👍

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

🚢

@marandaneto
Copy link
Member Author

I can't tell from the PR alone but I can at least clarify how it works elsewhere:

  1. By default events are queued and are only flushed as a batch once a timer passes or the size threshold is hit.
  2. However, a user can manually call the flush function to force whatever is in the buffer to be flushed.

If this code achieves that then 👍

  1. not really, since its an and operation, the timer passes and the threshold hits.
  2. yes, this PR addresses this use case.

@marandaneto
Copy link
Member Author

I can't tell from the PR alone but I can at least clarify how it works elsewhere:

  1. By default events are queued and are only flushed as a batch once a timer passes or the size threshold is hit.
  2. However, a user can manually call the flush function to force whatever is in the buffer to be flushed.

If this code achieves that then 👍

  1. not really, since its an and operation, the timer passes and the threshold hits.
  2. yes, this PR addresses this use case.

made new commits that address the 1. item, if this ever becomes a battery-draining issue, we can revert this part since its super simple.

@marandaneto marandaneto merged commit 5298d58 into main Jan 3, 2024
@marandaneto marandaneto deleted the fix/flush-forcefully branch January 3, 2024 12:51
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.

3 participants