Skip to content

Commit

Permalink
Update readme and log telemetry data
Browse files Browse the repository at this point in the history
  • Loading branch information
Freika committed Dec 5, 2024
1 parent 81e34f9 commit 82b3e26
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Data being sent:

- Number of DAU (Daily Active Users)
- App version
- Instance ID
- Instance ID (unique identifier of the Dawarich instance built by hashing the api key of the first user in the database)

The data is being sent to a InfluxDB instance hosted by me and won't be shared with anyone.

Expand Down
1 change: 1 addition & 0 deletions app/jobs/telemetry_sending_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def perform
return if ENV['DISABLE_TELEMETRY'] == 'true'

data = Telemetry::Gather.new.call
Rails.logger.info("Telemetry data: #{data}")

Telemetry::Send.new(data).call
end
Expand Down
2 changes: 2 additions & 0 deletions app/services/telemetry/send.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def initialize(payload)
end

def call
return if ENV['DISABLE_TELEMETRY'] == 'true'

line_protocol = build_line_protocol
response = send_request(line_protocol)
handle_response(response)
Expand Down
12 changes: 12 additions & 0 deletions spec/jobs/telemetry_sending_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,17 @@
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

it 'does not send telemetry data' do
described_class.perform_now

expect(send_service).not_to have_received(:call)
end
end
end
end

0 comments on commit 82b3e26

Please sign in to comment.