Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 9d8e2ff

Browse files
authored
Merge pull request #115 from francislavoie/stats-url
Add support for overriding stats logger's base URL
2 parents 4c12fb3 + 1020867 commit 9d8e2ff

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

config/websockets.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@
9292
*/
9393
'delete_statistics_older_than_days' => 60,
9494

95+
/*
96+
* By default, the websockets server attempts to connect to whatever
97+
* your APP_URL is set to. If running in a more complex environment,
98+
* you may wish to override the base URL for internal requests to
99+
* allow statistics to be collected.
100+
*/
101+
'base_url_override' => null,
102+
95103
/*
96104
* Use an DNS resolver to make the requests to the statistics logger
97105
* default is to resolve everything to 127.0.0.1.

src/Statistics/Logger/HttpStatisticsLogger.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function save()
7979
$this
8080
->browser
8181
->post(
82-
action([WebSocketStatisticsEntriesController::class, 'store']),
82+
$this->storeStatisticsUrl(),
8383
['Content-Type' => 'application/json'],
8484
stream_for(json_encode($postData))
8585
);
@@ -88,4 +88,15 @@ public function save()
8888
$statistic->reset($currentConnectionCount);
8989
}
9090
}
91+
92+
protected function storeStatisticsUrl(): string
93+
{
94+
$action = [WebSocketStatisticsEntriesController::class, 'store'];
95+
96+
$overridenUrl = config('websockets.statistics.base_url_override');
97+
98+
return $overridentUrl
99+
? $overridenUrl.action($action, [], false)
100+
: action($action);
101+
}
91102
}

0 commit comments

Comments
 (0)