diff options
author | Sean McGivern <sean@gitlab.com> | 2017-04-05 15:29:48 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-04-14 16:20:55 +0300 |
commit | 0483019e9800dc1b4ef4493890f815f047b7c04e (patch) | |
tree | 24430c787a2e69166ccd214cc1e15a489f32e9e9 /app | |
parent | ebd5e9b4549ebc80155a5a8f139efdb40b6f8b12 (diff) |
Port 'Add more usage data to EE ping' to CE
CE port of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/735
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/application_settings.js.es6 | 16 | ||||
-rw-r--r-- | app/assets/javascripts/dispatcher.js | 3 | ||||
-rw-r--r-- | app/controllers/admin/application_settings_controller.rb | 7 | ||||
-rw-r--r-- | app/views/admin/application_settings/_form.html.haml | 8 | ||||
-rw-r--r-- | app/workers/gitlab_usage_ping_worker.rb | 9 |
5 files changed, 32 insertions, 11 deletions
diff --git a/app/assets/javascripts/application_settings.js.es6 b/app/assets/javascripts/application_settings.js.es6 new file mode 100644 index 00000000000..ce7d5129d8d --- /dev/null +++ b/app/assets/javascripts/application_settings.js.es6 @@ -0,0 +1,16 @@ +(global => { + global.gl = global.gl || {}; + + gl.ApplicationSettings = function() { + var usage_data_url = $('.usage-data').data('endpoint'); + + $.ajax({ + type: "GET", + url: usage_data_url, + dataType: "html", + success: function (html) { + $(".usage-data").html(html); + } + }); + }; +})(window); diff --git a/app/assets/javascripts/dispatcher.js b/app/assets/javascripts/dispatcher.js index f277e1dddc7..9d8f965dee0 100644 --- a/app/assets/javascripts/dispatcher.js +++ b/app/assets/javascripts/dispatcher.js @@ -365,6 +365,9 @@ const ShortcutsBlob = require('./shortcuts_blob'); case 'admin': new Admin(); switch (path[1]) { + case 'application_settings': + new gl.ApplicationSettings(); + break; case 'groups': new UsersSelect(); break; diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 82b01be5a11..73b03b41594 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -17,6 +17,13 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController end end + def usage_data + respond_to do |format| + format.html { render html: Gitlab::Highlight.highlight('payload.json', Gitlab::UsageData.to_json) } + format.json { render json: Gitlab::UsageData.to_json } + end + end + def reset_runners_token @application_setting.reset_runners_registration_token! flash[:notice] = 'New runners registration token has been generated!' diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index d8b6ce13ca4..f671af477ad 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -492,9 +492,11 @@ = f.label :usage_ping_enabled do = f.check_box :usage_ping_enabled Usage ping enabled - .help-block - Every week GitLab will report license usage back to GitLab, Inc. - Disable this option if you do not want this to occur. + .container + .help-block + Every week GitLab will report license usage back to GitLab, Inc. + Disable this option if you do not want this to occur. This is the JSON payload that will be sent: + %pre.usage-data.js-syntax-highlight.code.highlight{ "data-endpoint" => usage_data_admin_application_settings_path(format: :html) } %fieldset %legend Email diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb index 2e039b7f3c5..866f5d03d8b 100644 --- a/app/workers/gitlab_usage_ping_worker.rb +++ b/app/workers/gitlab_usage_ping_worker.rb @@ -15,7 +15,7 @@ class GitlabUsagePingWorker begin HTTParty.post(url, - body: data.to_json, + body: Gitlab::UsageData.to_json, headers: { 'Content-type' => 'application/json' } ) rescue HTTParty::Error => e @@ -27,13 +27,6 @@ class GitlabUsagePingWorker Gitlab::ExclusiveLease.new('gitlab_usage_ping_worker:ping', timeout: LEASE_TIMEOUT).try_obtain end - def data - usage_data = { version: Gitlab::VERSION, - active_user_count: User.active.acount } - - usage_data - end - def url 'https://version.gitlab.com/usage_data' end |