class PostHog::SendWorker
def run
public: Continuously runs the loop to check for new events
def run until Thread.current[:should_exit] return if @queue.empty? @lock.synchronize do consume_message_from_queue! until @batch.full? || @queue.empty? end res = @transport.send @api_key, @batch @on_error.call(res.status, res.error) unless res.status == 200 @lock.synchronize { @batch.clear } end ensure @transport.shutdown end