From 6ef29631742947a89c8ba6e565ff31dcefd74bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artem=20Bo=CC=88hme?= Date: Tue, 12 Nov 2019 16:02:32 +0100 Subject: [PATCH 1/7] Make the telemetry requests configurable --- config/api_sample.php | 1 + .../Application/CoreServicesProvider.php | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/config/api_sample.php b/config/api_sample.php index 760dfbc9a9..1e633383cc 100644 --- a/config/api_sample.php +++ b/config/api_sample.php @@ -10,6 +10,7 @@ 'logger' => [ 'path' => __DIR__ . '/../logs', ], + 'useTelemetry' => true ], 'database' => [ diff --git a/src/core/Directus/Application/CoreServicesProvider.php b/src/core/Directus/Application/CoreServicesProvider.php index d8e05abacd..3b465a38b5 100644 --- a/src/core/Directus/Application/CoreServicesProvider.php +++ b/src/core/Directus/Application/CoreServicesProvider.php @@ -717,19 +717,27 @@ protected function getEmitter() $emitter->addAction('auth.request:credentials', function () use ($container) { /** @var Session $session */ $session = $container->get('session'); - if ($session->getStorage()->get('telemetry') === true) { - return; + $config = $container->get('config'); + $useTelemetry = true; // default + if ($config->has('settings.useTelemetry')) { + $useTelemetry = $config->get('settings.useTelemetry'); } - $data = [ - 'version' => Application::DIRECTUS_VERSION, - 'url' => get_url(), - 'type' => 'api' - ]; - \Directus\request_send_json('POST', 'https://telemetry.directus.io/count', $data); + if($useTelemetry) { + if ($session->getStorage()->get('telemetry') === true) { + return; + } - // NOTE: this only works when the client sends subsequent request with the same cookie - $session->getStorage()->set('telemetry', true); + $data = [ + 'version' => Application::DIRECTUS_VERSION, + 'url' => get_url(), + 'type' => 'api' + ]; + \Directus\request_send_json('POST', 'https://telemetry.directus.io/count', $data); + + // NOTE: this only works when the client sends subsequent request with the same cookie + $session->getStorage()->set('telemetry', true); + } }); return $emitter; From e2ed0bfd836a53b180dde06375855b3b3363b94f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artem=20Bo=CC=88hme?= Date: Tue, 12 Nov 2019 16:53:08 +0100 Subject: [PATCH 2/7] Add new config setting to the schema --- src/core/Directus/Config/Schema/Schema.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/Directus/Config/Schema/Schema.php b/src/core/Directus/Config/Schema/Schema.php index 3b4c27537f..43f9c55d77 100644 --- a/src/core/Directus/Config/Schema/Schema.php +++ b/src/core/Directus/Config/Schema/Schema.php @@ -26,7 +26,8 @@ public static function get() { new Group('settings', [ new Group('logger', [ new Value('path', Types::STRING, $loggerPath), - ]) + ]), + new Value('useTelemetry', Types::BOOLEAN, true), ]), new Group('database', [ new Value('type', Types::STRING, 'mysql'), From 6fe0de4a898bd2e48360fa7c59027b4b9f77b678 Mon Sep 17 00:00:00 2001 From: Binal Gajjar Date: Tue, 26 Nov 2019 15:19:32 +0530 Subject: [PATCH 3/7] Remove telemetry from configuration file --- config/api_sample.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/config/api_sample.php b/config/api_sample.php index 1e633383cc..36b3e331ff 100644 --- a/config/api_sample.php +++ b/config/api_sample.php @@ -9,8 +9,7 @@ 'settings' => [ 'logger' => [ 'path' => __DIR__ . '/../logs', - ], - 'useTelemetry' => true + ] ], 'database' => [ From a90118c899fcabac69230f11e95142748d168d4f Mon Sep 17 00:00:00 2001 From: Binal Gajjar Date: Tue, 26 Nov 2019 15:20:00 +0530 Subject: [PATCH 4/7] Remove telemetry from configuration file --- config/api_sample.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/api_sample.php b/config/api_sample.php index 36b3e331ff..760dfbc9a9 100644 --- a/config/api_sample.php +++ b/config/api_sample.php @@ -9,7 +9,7 @@ 'settings' => [ 'logger' => [ 'path' => __DIR__ . '/../logs', - ] + ], ], 'database' => [ From e7b40f254c2fbf3caded4fa375ad3dd35d11b9ce Mon Sep 17 00:00:00 2001 From: Binal Gajjar Date: Tue, 26 Nov 2019 15:20:33 +0530 Subject: [PATCH 5/7] Remove telemetry from schema --- src/core/Directus/Config/Schema/Schema.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/Directus/Config/Schema/Schema.php b/src/core/Directus/Config/Schema/Schema.php index 43f9c55d77..d931f97111 100644 --- a/src/core/Directus/Config/Schema/Schema.php +++ b/src/core/Directus/Config/Schema/Schema.php @@ -27,7 +27,6 @@ public static function get() { new Group('logger', [ new Value('path', Types::STRING, $loggerPath), ]), - new Value('useTelemetry', Types::BOOLEAN, true), ]), new Group('database', [ new Value('type', Types::STRING, 'mysql'), From b659b20a7198fb09183a1a4f3967a5b74cb3ba2b Mon Sep 17 00:00:00 2001 From: Binal Gajjar Date: Tue, 26 Nov 2019 15:22:43 +0530 Subject: [PATCH 6/7] Remove extra comma --- src/core/Directus/Config/Schema/Schema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Directus/Config/Schema/Schema.php b/src/core/Directus/Config/Schema/Schema.php index d931f97111..3b4c27537f 100644 --- a/src/core/Directus/Config/Schema/Schema.php +++ b/src/core/Directus/Config/Schema/Schema.php @@ -26,7 +26,7 @@ public static function get() { new Group('settings', [ new Group('logger', [ new Value('path', Types::STRING, $loggerPath), - ]), + ]) ]), new Group('database', [ new Value('type', Types::STRING, 'mysql'), From e06c374bd492fbc40cea43c6da49975bdaf5bece Mon Sep 17 00:00:00 2001 From: Binal Gajjar Date: Tue, 26 Nov 2019 15:30:06 +0530 Subject: [PATCH 7/7] Fetch the telemetry from settings table instead of configuration file --- src/core/Directus/Application/CoreServicesProvider.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/core/Directus/Application/CoreServicesProvider.php b/src/core/Directus/Application/CoreServicesProvider.php index 3b465a38b5..c7d68ff0b4 100644 --- a/src/core/Directus/Application/CoreServicesProvider.php +++ b/src/core/Directus/Application/CoreServicesProvider.php @@ -717,11 +717,7 @@ protected function getEmitter() $emitter->addAction('auth.request:credentials', function () use ($container) { /** @var Session $session */ $session = $container->get('session'); - $config = $container->get('config'); - $useTelemetry = true; // default - if ($config->has('settings.useTelemetry')) { - $useTelemetry = $config->get('settings.useTelemetry'); - } + $useTelemetry = get_directus_setting('telemetry',true); if($useTelemetry) { if ($session->getStorage()->get('telemetry') === true) {