An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
feat(traffic): add traffic analytics server settings
Aditya Tripathi99b25fbd8a0c
diff --git a/app/Models/Server.php b/app/Models/Server.phpindex 619382dfda..f2954b67c1 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -934,6 +934,11 @@ $schema://$host {return $this->settings->is_metrics_enabled;}+ public function isTrafficAnalyticsEnabled(): bool+ {+ return (bool) data_get($this, 'settings.is_traffic_analytics_enabled', false);+ }+public function isServerApiEnabled(){return $this->settings->is_sentinel_enabled;diff --git a/app/Models/ServerSetting.php b/app/Models/ServerSetting.phpindex 93f040e4ad..6cc5d2baee 100644--- a/app/Models/ServerSetting.php+++ b/app/Models/ServerSetting.php@@ -26,6 +26,7 @@ use OpenApi\Attributes as OA;'is_logdrain_highlight_enabled' => ['type' => 'boolean'],'is_logdrain_newrelic_enabled' => ['type' => 'boolean'],'is_metrics_enabled' => ['type' => 'boolean'],+ 'is_traffic_analytics_enabled' => ['type' => 'boolean'],'is_reachable' => ['type' => 'boolean'],'is_sentinel_enabled' => ['type' => 'boolean'],'is_swarm_manager' => ['type' => 'boolean'],@@ -100,6 +101,8 @@ class ServerSetting extends Model'deployment_queue_limit','disable_application_image_retention','connection_timeout',+ 'is_traffic_analytics_enabled',+ 'geoip_maxmind_license_key',];protected $casts = [@@ -113,6 +116,8 @@ class ServerSetting extends Model'is_terminal_enabled' => 'boolean','disable_application_image_retention' => 'boolean','connection_timeout' => 'integer',+ 'is_traffic_analytics_enabled' => 'boolean',+ 'geoip_maxmind_license_key' => 'encrypted',];/**@@ -127,6 +132,7 @@ class ServerSetting extends Model'logdrain_axiom_api_key','logdrain_custom_config','logdrain_custom_config_parser',+ 'geoip_maxmind_license_key',];protected static function booted()diff --git a/database/migrations/2026_08_10_191228_add_traffic_analytics_to_server_settings.php b/database/migrations/2026_08_10_191228_add_traffic_analytics_to_server_settings.phpnew file mode 100644index 0000000000..6fdd2a213c--- /dev/null+++ b/database/migrations/2026_08_10_191228_add_traffic_analytics_to_server_settings.php@@ -0,0 +1,29 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {+ Schema::table('server_settings', function (Blueprint $table) {+ $table->boolean('is_traffic_analytics_enabled')->default(false);+ $table->text('geoip_maxmind_license_key')->nullable();+ });+ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {+ Schema::table('server_settings', function (Blueprint $table) {+ $table->dropColumn(['is_traffic_analytics_enabled', 'geoip_maxmind_license_key']);+ });+ }+};diff --git a/tests/Feature/TrafficAnalytics/ServerSettingTrafficTest.php b/tests/Feature/TrafficAnalytics/ServerSettingTrafficTest.phpnew file mode 100644index 0000000000..0a8003c226--- /dev/null+++ b/tests/Feature/TrafficAnalytics/ServerSettingTrafficTest.php@@ -0,0 +1,31 @@+<?php++use App\Models\Server;+use App\Models\User;+use Illuminate\Foundation\Testing\RefreshDatabase;++uses(RefreshDatabase::class);++beforeEach(function () {+ $user = User::factory()->create();+ $this->team = $user->teams()->first();+});++it('defaults traffic analytics to disabled and exposes a server helper', function () {+ $server = Server::factory()->create(['team_id' => $this->team->id]);+ expect($server->settings->is_traffic_analytics_enabled)->toBeFalse();+ expect($server->isTrafficAnalyticsEnabled())->toBeFalse();++ $server->settings->is_traffic_analytics_enabled = true;+ $server->settings->save();+ expect($server->fresh()->isTrafficAnalyticsEnabled())->toBeTrue();+});++it('encrypts the maxmind license key and hides it from array output', function () {+ $server = Server::factory()->create(['team_id' => $this->team->id]);+ $server->settings->geoip_maxmind_license_key = 'secret-key';+ $server->settings->save();++ expect($server->settings->fresh()->geoip_maxmind_license_key)->toBe('secret-key');+ expect(array_key_exists('geoip_maxmind_license_key', $server->settings->fresh()->toArray()))->toBeFalse();+});