Commit cf93bbad authored by Stan Hu's avatar Stan Hu

Display the JSON payload in settings page for EE usage ping

parent 6a9dc4cb
Please view this file on the master branch, on stable branches it's out of date.
v 8.10.0 (unreleased)
- Add EE license usage ping !557
- Rename Git Hooks to Push Rules
- Fix EE keys fingerprint add index migration if came from CE
- Add todos for MR approvers !547
......
......@@ -17,6 +17,25 @@ module LicenseHelper
end
end
def license_usage_data
usage_data = { version: Gitlab::VERSION,
active_user_count: current_active_user_count }
license = License.current
if license
usage_data[:license_md5] = Digest::MD5.hexdigest(license.data)
usage_data[:historical_max_users] = max_historical_user_count
usage_data[:licensee] = license.licensee
usage_data[:license_user_count] = license.user_count
usage_data[:license_starts_at] = license.starts_at
usage_data[:license_expires_at] = license.expires_at
usage_data[:license_add_ons] = license.add_ons
usage_data[:recorded_at] = Time.now
end
usage_data
end
private
def no_license_message(signed_in, is_admin)
......
......@@ -63,7 +63,8 @@
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.
Disable this option if you do not want this to occur. This is the JSON payload that will be sent:
%pre.js-syntax-highlight.code.highlight= Gitlab::Highlight.highlight('payload.json', license_usage_data.to_json)
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
......
......@@ -16,7 +16,7 @@ class GitlabUsagePingWorker
begin
HTTParty.post(url,
body: data.to_json,
body: license_usage_data.to_json,
headers: { 'Content-type' => 'application/json' }
)
rescue HTTParty::Error => e
......@@ -28,25 +28,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: current_active_user_count }
license = License.current
if license
usage_data[:license_md5] = Digest::MD5.hexdigest(license.data)
usage_data[:historical_max_users] = max_historical_user_count
usage_data[:licensee] = license.licensee
usage_data[:license_user_count] = license.user_count
usage_data[:license_starts_at] = license.starts_at
usage_data[:license_expires_at] = license.expires_at
usage_data[:license_add_ons] = license.add_ons
usage_data[:recorded_at] = Time.now
end
usage_data
end
def url
'https://version.gitlab.com/usage_data'
end
......
......@@ -20,4 +20,22 @@ describe LicenseHelper do
end
end
end
describe '#license_usage_data' do
it "gathers license data" do
data = license_usage_data
license = License.current
expect(data[:license_md5]).to eq(Digest::MD5.hexdigest(license.data))
expect(data[:version]).to eq(Gitlab::VERSION)
expect(data[:licensee]).to eq(license.licensee)
expect(data[:active_user_count]).to eq(User.active.count)
expect(data[:licensee]).to eq(license.licensee)
expect(data[:license_user_count]).to eq(license.user_count)
expect(data[:license_starts_at]).to eq(license.starts_at)
expect(data[:license_expires_at]).to eq(license.expires_at)
expect(data[:license_add_ons]).to eq(license.add_ons)
expect(data[:recorded_at]).to be_a(Time)
end
end
end
......@@ -3,22 +3,6 @@ require 'spec_helper'
describe GitlabUsagePingWorker do
subject { GitlabUsagePingWorker.new }
it "gathers license data" do
data = subject.data
license = License.current
expect(data[:license_md5]).to eq(Digest::MD5.hexdigest(license.data))
expect(data[:version]).to eq(Gitlab::VERSION)
expect(data[:licensee]).to eq(license.licensee)
expect(data[:active_user_count]).to eq(User.active.count)
expect(data[:licensee]).to eq(license.licensee)
expect(data[:license_user_count]).to eq(license.user_count)
expect(data[:license_starts_at]).to eq(license.starts_at)
expect(data[:license_expires_at]).to eq(license.expires_at)
expect(data[:license_add_ons]).to eq(license.add_ons)
expect(data[:recorded_at]).to be_a(Time)
end
it "sends POST request" do
stub_application_setting(usage_ping_enabled: true)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment