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