Closed hansottowirtz closed 9 months ago
Hmmm this is indeed a tricky one. We don't want to change the signature of the method but if we don't make it async and awaitable then there is a potential for the captured event to happen after that flush call... We would have to do something like allow the capture
to receive promises that could later be awaited but that is... tricky.
There were a few improvements discussed here that might help with this issue, I don't think we need to make everything async but flushAsync
should be able to send everything pending regardless of calling capture
or just using sendFeatureFlags
.
oh, I think I fixed this here: https://github.com/PostHog/posthog-js-lite/pull/149 - didn't realise you had already mentioned the issue! 🤦
oh, I think I fixed this here: #149 - didn't realise you had already mentioned the issue! 🤦
26 Dec I was OOO, sorry missed that. Alright, let's close it then, thanks.
Feel free to comment if this isn't solved @hansottowirtz , but now we track promises being enqueued from inside sendFeatureFlags, which should make sure they are sent on shutdown, although not necessarily on the flush immediately after the capture call.
Bug description
Normally, this works:
but this doesn't work (flushAsync doesn't flush this capture):
because
super.getFeatureFlagsStateless
is not waited-on on this line:https://github.com/PostHog/posthog-js-lite/blob/32d74d2642168325a10cb1f9a6eab4f7a75ff0b8/posthog-node/src/posthog-node.ts#L106-L107
Related sub-libraries
Additional context