2021-07-06 21:07:50 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module ServicePing
|
|
|
|
class BuildPayloadService
|
|
|
|
def execute
|
|
|
|
return {} unless allowed_to_report?
|
|
|
|
|
|
|
|
raw_payload
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def allowed_to_report?
|
|
|
|
product_intelligence_enabled? && !User.single_user&.requires_usage_stats_consent?
|
|
|
|
end
|
|
|
|
|
|
|
|
def product_intelligence_enabled?
|
|
|
|
::Gitlab::CurrentSettings.usage_ping_enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
def raw_payload
|
2022-02-08 15:12:33 +00:00
|
|
|
@raw_payload ||= ::Gitlab::Usage::ServicePingReport.for(output: :all_metrics_values)
|
2021-07-06 21:07:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ServicePing::BuildPayloadService.prepend_mod_with('ServicePing::BuildPayloadService')
|