Skip to content

Commit

Permalink
(maint) Clean up requires in pdk/analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
rodjek committed Sep 30, 2019
1 parent 9f813e8 commit 2d038fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/pdk/analytics.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require 'securerandom'
require 'pdk/analytics/util'
require 'pdk/analytics/client/google_analytics'
require 'pdk/analytics/client/noop'

module PDK
def self.analytics
require 'pdk/config'
require 'pdk/logger'
require 'pdk/util'
require 'pdk/version'

@analytics ||= PDK::Analytics.build_client(
logger: PDK.logger,
disabled: ENV['PDK_DISABLE_ANALYTICS'] || PDK.config.user['analytics']['disabled'],
Expand Down
3 changes: 3 additions & 0 deletions lib/pdk/analytics/client/google_analytics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def initialize(opts)
require 'concurrent/future'
require 'httpclient'
require 'locale'
require 'pdk/analytics/util'

@http = HTTPClient.new
@user_id = opts[:user_id]
Expand Down Expand Up @@ -78,6 +79,8 @@ def submit(params)
# Handle analytics submission in the background to avoid blocking the
# app or polluting the log with errors
Concurrent::Future.execute(executor: @executor) do
require 'json'

logger.debug "Submitting analytics: #{JSON.pretty_generate(params)}"
@http.post(TRACKING_URL, params)
logger.debug 'Completed analytics submission'
Expand Down
1 change: 1 addition & 0 deletions spec/unit/pdk/analytics/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'concurrent/configuration'
require 'concurrent/future'
require 'facter'
require 'pdk/analytics/util'

describe PDK::Analytics::Util do
describe '.fetch_os_async' do
Expand Down

0 comments on commit 2d038fa

Please sign in to comment.