diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-05 12:18:12 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-05 12:18:12 +0300 |
commit | 3b39cf4e0c5d0ca680a40bb7232fee4f7fdfb02e (patch) | |
tree | ef2c85a93d787ca15ee857f1aa3754e58dbc163e /app/services | |
parent | e90ca0f0fcae087f95b92a4699f884167b47eaaf (diff) | |
parent | d913ce176351094e2908344206a6136163fdfa89 (diff) |
Merge branch '30469-convdev-index' into 'master'
ConvDev Index
Closes #30469
See merge request !11377
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/submit_usage_ping_service.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/services/submit_usage_ping_service.rb b/app/services/submit_usage_ping_service.rb new file mode 100644 index 00000000000..17857ca62f2 --- /dev/null +++ b/app/services/submit_usage_ping_service.rb @@ -0,0 +1,41 @@ +class SubmitUsagePingService + URL = 'https://version.gitlab.com/usage_data'.freeze + + include Gitlab::CurrentSettings + + def execute + return false unless current_application_settings.usage_ping_enabled? + + response = HTTParty.post( + URL, + body: Gitlab::UsageData.to_json(force_refresh: true), + headers: { 'Content-type' => 'application/json' } + ) + + store_metrics(response) + + true + rescue HTTParty::Error => e + Rails.logger.info "Unable to contact GitLab, Inc.: #{e}" + + false + end + + private + + def store_metrics(response) + return unless response['conv_index'].present? + + ConversationalDevelopmentIndex::Metric.create!( + response['conv_index'].slice( + 'leader_issues', 'instance_issues', 'leader_notes', 'instance_notes', + 'leader_milestones', 'instance_milestones', 'leader_boards', 'instance_boards', + 'leader_merge_requests', 'instance_merge_requests', 'leader_ci_pipelines', + 'instance_ci_pipelines', 'leader_environments', 'instance_environments', + 'leader_deployments', 'instance_deployments', 'leader_projects_prometheus_active', + 'instance_projects_prometheus_active', 'leader_service_desk_issues', + 'instance_service_desk_issues' + ) + ) + end +end |