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

Commit 70ffe41

Browse files
committed
Add support for overriding stats logger's base URL
1 parent 53691ce commit 70ffe41

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

config/websockets.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@
8080
*/
8181
'delete_statistics_older_than_days' => 60,
8282

83+
/*
84+
* By default, the websockets server attempts to connect to whatever
85+
* your APP_URL is set to. If running in a more complex environment,
86+
* you may wish to override the base URL for internal requests to
87+
* allow statistics to be collected.
88+
*/
89+
'base_url_override' => null,
90+
8391
/*
8492
* Use an DNS resolver to make the requests to the statistics logger
8593
* default is to resolve everything to 127.0.0.1.

src/Statistics/Logger/HttpStatisticsLogger.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ protected function findOrMakeStatisticForAppId($appId): Statistic
6565
return $this->statistics[$appId];
6666
}
6767

68+
protected function getUrl(): string
69+
{
70+
$action = [WebSocketStatisticsEntriesController::class, 'store'];
71+
72+
$url_override = config('websockets.statistics.base_url_override', null);
73+
74+
if ($url_override !== null) {
75+
return $url_override.action($action, [], false);
76+
}
77+
78+
return action($action);
79+
}
80+
6881
public function save()
6982
{
7083
foreach ($this->statistics as $appId => $statistic) {
@@ -79,7 +92,7 @@ public function save()
7992
$this
8093
->browser
8194
->post(
82-
action([WebSocketStatisticsEntriesController::class, 'store']),
95+
$this->getUrl(),
8396
['Content-Type' => 'application/json'],
8497
stream_for(json_encode($postData))
8598
);

0 commit comments

Comments
 (0)