Commit 90c1f1f2 authored by Stan Hu's avatar Stan Hu

Merge branch 'feature/add-uuid-usage-ping' into 'master'

Add uuid to usage ping

Closes #1894

See merge request !1521
parents cf91b76a 4807fa3c
---
title: Add uuid to usage ping
merge_request:
author:
class AddUuidToApplicationSettings < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column :application_settings, :uuid, :string
execute("UPDATE application_settings SET uuid = #{quote(SecureRandom.uuid)}")
end
def down
remove_column :application_settings, :uuid
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170317203554) do ActiveRecord::Schema.define(version: 20170328010804) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -129,6 +129,7 @@ ActiveRecord::Schema.define(version: 20170317203554) do ...@@ -129,6 +129,7 @@ ActiveRecord::Schema.define(version: 20170317203554) do
t.string "elasticsearch_aws_access_key" t.string "elasticsearch_aws_access_key"
t.string "elasticsearch_aws_secret_access_key" t.string "elasticsearch_aws_secret_access_key"
t.integer "geo_status_timeout", default: 10 t.integer "geo_status_timeout", default: 10
t.string "uuid"
end end
create_table "approvals", force: :cascade do |t| create_table "approvals", force: :cascade do |t|
......
module Gitlab module Gitlab
class UsageData class UsageData
include Gitlab::CurrentSettings
class << self class << self
def data(force_refresh: false) def data(force_refresh: false)
Rails.cache.fetch('usage_data', force: force_refresh, expires_in: 2.weeks) { uncached_data } Rails.cache.fetch('usage_data', force: force_refresh, expires_in: 2.weeks) { uncached_data }
...@@ -51,7 +53,8 @@ module Gitlab ...@@ -51,7 +53,8 @@ module Gitlab
end end
def license_usage_data def license_usage_data
usage_data = { version: Gitlab::VERSION, usage_data = { uuid: current_application_settings.uuid,
version: Gitlab::VERSION,
active_user_count: User.active.count, active_user_count: User.active.count,
mattermost_enabled: Gitlab.config.mattermost.enabled } mattermost_enabled: Gitlab.config.mattermost.enabled }
......
...@@ -22,6 +22,7 @@ describe Gitlab::UsageData do ...@@ -22,6 +22,7 @@ describe Gitlab::UsageData do
recorded_at recorded_at
version version
mattermost_enabled mattermost_enabled
uuid
)) ))
end end
...@@ -72,6 +73,7 @@ describe Gitlab::UsageData do ...@@ -72,6 +73,7 @@ describe Gitlab::UsageData do
it "gathers license data" do it "gathers license data" do
license = ::License.current license = ::License.current
expect(subject[:uuid]).to eq(current_application_settings.uuid)
expect(subject[:license_md5]).to eq(Digest::MD5.hexdigest(license.data)) expect(subject[:license_md5]).to eq(Digest::MD5.hexdigest(license.data))
expect(subject[:version]).to eq(Gitlab::VERSION) expect(subject[:version]).to eq(Gitlab::VERSION)
expect(subject[:licensee]).to eq(license.licensee) expect(subject[:licensee]).to eq(license.licensee)
......
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