Add support for overriding stats logger's base URL
This commit is contained in:
parent
53691ce8a5
commit
70ffe41c86
|
|
@ -80,6 +80,14 @@ return [
|
|||
*/
|
||||
'delete_statistics_older_than_days' => 60,
|
||||
|
||||
/*
|
||||
* By default, the websockets server attempts to connect to whatever
|
||||
* your APP_URL is set to. If running in a more complex environment,
|
||||
* you may wish to override the base URL for internal requests to
|
||||
* allow statistics to be collected.
|
||||
*/
|
||||
'base_url_override' => null,
|
||||
|
||||
/*
|
||||
* Use an DNS resolver to make the requests to the statistics logger
|
||||
* default is to resolve everything to 127.0.0.1.
|
||||
|
|
|
|||
|
|
@ -65,6 +65,19 @@ class HttpStatisticsLogger implements StatisticsLogger
|
|||
return $this->statistics[$appId];
|
||||
}
|
||||
|
||||
protected function getUrl(): string
|
||||
{
|
||||
$action = [WebSocketStatisticsEntriesController::class, 'store'];
|
||||
|
||||
$url_override = config('websockets.statistics.base_url_override', null);
|
||||
|
||||
if ($url_override !== null) {
|
||||
return $url_override.action($action, [], false);
|
||||
}
|
||||
|
||||
return action($action);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
foreach ($this->statistics as $appId => $statistic) {
|
||||
|
|
@ -79,7 +92,7 @@ class HttpStatisticsLogger implements StatisticsLogger
|
|||
$this
|
||||
->browser
|
||||
->post(
|
||||
action([WebSocketStatisticsEntriesController::class, 'store']),
|
||||
$this->getUrl(),
|
||||
['Content-Type' => 'application/json'],
|
||||
stream_for(json_encode($postData))
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue