diff --git a/CHANGELOG.md b/CHANGELOG.md index 355cd0e9..977f707e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ To change this, you need to update the `docker-compose.yml` file: healthcheck: ``` +Telemetry is now disabled by default. To enable it, you need to set `ENABLE_TELEMETRY` env var to `true`. For those who have telemetry enabled using `DISABLE_TELEMETRY` env var set to `false`, telemetry is now disabled by default. + ### Fixed - Flash messages are now being removed after 5 seconds. @@ -35,6 +37,7 @@ To change this, you need to update the `docker-compose.yml` file: - Places page is now accessible from the Visits & Places tab on the navbar. - Exporting process is now being logged. +- `ENABLE_TELEMETRY` env var is now used instead of `DISABLE_TELEMETRY` to enable/disable telemetry. # 0.19.5 - 2024-12-10 diff --git a/app/jobs/telemetry_sending_job.rb b/app/jobs/telemetry_sending_job.rb index 5b84f11a..7bec3b00 100644 --- a/app/jobs/telemetry_sending_job.rb +++ b/app/jobs/telemetry_sending_job.rb @@ -4,7 +4,7 @@ class TelemetrySendingJob < ApplicationJob queue_as :default def perform - return if ENV['DISABLE_TELEMETRY'] == 'true' + return unless ENV['ENABLE_TELEMETRY'] == 'true' data = Telemetry::Gather.new.call Rails.logger.info("Telemetry data: #{data}") diff --git a/app/services/telemetry/send.rb b/app/services/telemetry/send.rb index 46401294..96f222af 100644 --- a/app/services/telemetry/send.rb +++ b/app/services/telemetry/send.rb @@ -9,7 +9,7 @@ class Telemetry::Send end def call - return if ENV['DISABLE_TELEMETRY'] == 'true' + return unless ENV['ENABLE_TELEMETRY'] == 'true' line_protocol = build_line_protocol response = send_request(line_protocol) diff --git a/docker-compose.yml b/docker-compose.yml index cf8dbf62..b3dc7f96 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -69,7 +69,7 @@ services: PROMETHEUS_EXPORTER_ENABLED: false PROMETHEUS_EXPORTER_HOST: 0.0.0.0 PROMETHEUS_EXPORTER_PORT: 9394 - DISABLE_TELEMETRY: false # More on telemetry: https://dawarich.app/docs/tutorials/telemetry + ENABLE_TELEMETRY: false # More on telemetry: https://dawarich.app/docs/tutorials/telemetry logging: driver: "json-file" options: @@ -124,7 +124,7 @@ services: PROMETHEUS_EXPORTER_ENABLED: false PROMETHEUS_EXPORTER_HOST: dawarich_app PROMETHEUS_EXPORTER_PORT: 9394 - DISABLE_TELEMETRY: false # More on telemetry: https://dawarich.app/docs/tutorials/telemetry + ENABLE_TELEMETRY: false # More on telemetry: https://dawarich.app/docs/tutorials/telemetry logging: driver: "json-file" options: diff --git a/spec/jobs/telemetry_sending_job_spec.rb b/spec/jobs/telemetry_sending_job_spec.rb index 0acef0ee..54c63d7c 100644 --- a/spec/jobs/telemetry_sending_job_spec.rb +++ b/spec/jobs/telemetry_sending_job_spec.rb @@ -15,23 +15,25 @@ RSpec.describe TelemetrySendingJob, type: :job do allow(send_service).to receive(:call) end - it 'gathers telemetry data and sends it' do - described_class.perform_now - - expect(gather_service).to have_received(:call) - expect(send_service).to have_received(:call) - end - - context 'when DISABLE_TELEMETRY is set to true' do - before do - stub_const('ENV', ENV.to_h.merge('DISABLE_TELEMETRY' => 'true')) - end - + context 'with default env' do it 'does not send telemetry data' do described_class.perform_now expect(send_service).not_to have_received(:call) end end + + context 'when ENABLE_TELEMETRY is set to true' do + before do + stub_const('ENV', ENV.to_h.merge('ENABLE_TELEMETRY' => 'true')) + end + + it 'gathers telemetry data and sends it' do + described_class.perform_now + + expect(gather_service).to have_received(:call) + expect(send_service).to have_received(:call) + end + end end end