From 96ec3e857abdfd30b03a821d57a2887aafa4e1e4 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 3 Mar 2018 21:42:59 +0000 Subject: [PATCH] Flush segment on each queue loop --- src/SegmentServiceProvider.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/SegmentServiceProvider.php b/src/SegmentServiceProvider.php index 8a53e20..f3ddc7b 100644 --- a/src/SegmentServiceProvider.php +++ b/src/SegmentServiceProvider.php @@ -37,6 +37,8 @@ public function boot() if ($writeKey = $this->app->config->get('segment.write_key')) { Segment::init($writeKey, (array) $this->app->config->get('segment.init_options')); } + + $this->setupQueue(); } /** @@ -57,6 +59,18 @@ protected function setupConfig() $this->mergeConfigFrom($source, 'segment'); } + /** + * Setup the queue. + * + * @return void + */ + protected function setupQueue() + { + $this->app->queue->looping(function () { + Segment::flush(); + }); + } + /** * Register the service provider. *