From 3c546acf78408087b5062be67ae6b05650e0f27e Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 9 May 2017 20:40:19 +0100 Subject: [PATCH 1/3] Allow disabling usage ping in `gitlab.yml` Setting `usage_ping_enabled` to false in `gitlab.yml`: 1. Disables the usage ping, regardless of the value stored in the database. 2. Prevents the usage ping from being enabled through the admin panel. It can only be enabled by either removing the line from `gitlab.yml` and configuring through the admin panel, or setting it to true in `gitlab.yml`. --- app/models/application_setting.rb | 10 ++- .../application_settings/_form.html.haml | 21 ++++--- changelogs/unreleased/disable-usage-ping.yml | 4 ++ config/initializers/1_settings.rb | 1 + .../admin_area/settings/usage_statistics.md | 18 ++++++ spec/models/application_setting_spec.rb | 62 +++++++++++++++++++ 6 files changed, 108 insertions(+), 8 deletions(-) create mode 100644 changelogs/unreleased/disable-usage-ping.yml diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 54f01f8637e..043f57241a3 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -246,7 +246,7 @@ class ApplicationSetting < ActiveRecord::Base two_factor_grace_period: 48, user_default_external: false, polling_interval_multiplier: 1, - usage_ping_enabled: true + usage_ping_enabled: Settings.gitlab['usage_ping_enabled'] } end @@ -349,6 +349,14 @@ class ApplicationSetting < ActiveRecord::Base sidekiq_throttling_enabled end + def usage_ping_can_be_configured? + Settings.gitlab.usage_ping_enabled + end + + def usage_ping_enabled + usage_ping_can_be_configured? && super + end + private def ensure_uuid! diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 4b6628169ef..e1b4e34cd2b 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -502,17 +502,24 @@ Let GitLab inform you when an update is available. .form-group .col-sm-offset-2.col-sm-10 + - can_be_configured = @application_setting.usage_ping_can_be_configured? .checkbox = f.label :usage_ping_enabled do - = f.check_box :usage_ping_enabled + = f.check_box :usage_ping_enabled, disabled: !can_be_configured Usage ping enabled - = link_to icon('question-circle'), help_page_path("user/admin_area/settings/usage_statistics", anchor: "usage-data") + = link_to icon('question-circle'), help_page_path("user/admin_area/settings/usage_statistics", anchor: "usage-ping") .help-block - Every week GitLab will report license usage back to GitLab, Inc. - Disable this option if you do not want this to occur. To see the - JSON payload that will be sent, visit the - = succeed '.' do - = link_to "Cohorts page", admin_cohorts_path(anchor: 'usage-ping') + - if can_be_configured + Every week GitLab will report license usage back to GitLab, Inc. + Disable this option if you do not want this to occur. To see the + JSON payload that will be sent, visit the + = succeed '.' do + = link_to "Cohorts page", admin_cohorts_path(anchor: 'usage-ping') + - else + The usage ping is disabled, and cannot be configured through this + form. For more information, see the documentation on + = succeed '.' do + = link_to 'deactivating the usage ping', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'deactivate-the-usage-ping') %fieldset %legend Email diff --git a/changelogs/unreleased/disable-usage-ping.yml b/changelogs/unreleased/disable-usage-ping.yml new file mode 100644 index 00000000000..5438eb56dba --- /dev/null +++ b/changelogs/unreleased/disable-usage-ping.yml @@ -0,0 +1,4 @@ +--- +title: Allow usage ping to be disabled completely in gitlab.yml +merge_request: +author: diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 6097ae6534e..ea1815f500a 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -241,6 +241,7 @@ Settings.gitlab['domain_whitelist'] ||= [] Settings.gitlab['import_sources'] ||= %w[github bitbucket gitlab google_code fogbugz git gitlab_project gitea] Settings.gitlab['trusted_proxies'] ||= [] Settings.gitlab['no_todos_messages'] ||= YAML.load_file(Rails.root.join('config', 'no_todos_messages.yml')) +Settings.gitlab['usage_ping_enabled'] = true if Settings.gitlab['usage_ping_enabled'].nil? # # CI diff --git a/doc/user/admin_area/settings/usage_statistics.md b/doc/user/admin_area/settings/usage_statistics.md index 733e70ca9bf..6198d4864fa 100644 --- a/doc/user/admin_area/settings/usage_statistics.md +++ b/doc/user/admin_area/settings/usage_statistics.md @@ -89,6 +89,24 @@ By default, usage ping is opt-out. If you want to deactivate this feature, go to the Settings page of your administration panel and uncheck the Usage ping checkbox. +To disable the usage ping and prevent it from being configured from the +administration panel, Omnibus installs can set the following in +[`gitlab.rb`](https://docs.gitlab.com/omnibus/settings/configuration.html#configuration-options): + +```ruby +gitlab_rails['usage_ping_enabled'] = false +``` + +And source installs can set the following in `gitlab.yml`: + +```yaml +production: &base + # ... + gitlab: + # ... + usage_ping_enabled: false +``` + ## Privacy policy GitLab Inc. does **not** collect any sensitive information, like project names diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 3c3ae3832de..fa229542f70 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -211,4 +211,66 @@ describe ApplicationSetting, models: true do expect(setting.domain_blacklist).to contain_exactly('example.com', 'test.com', 'foo.bar') end end + + describe 'usage ping settings' do + context 'when the usage ping is disabled in gitlab.yml' do + before do + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false) + end + + it 'does not allow the usage ping to be configured' do + expect(setting.usage_ping_can_be_configured?).to be_falsey + end + + context 'when the usage ping is disabled in the DB' do + before do + setting.usage_ping_enabled = false + end + + it 'returns false for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_falsey + end + end + + context 'when the usage ping is enabled in the DB' do + before do + setting.usage_ping_enabled = true + end + + it 'returns false for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_falsey + end + end + end + + context 'when the usage ping is enabled in gitlab.yml' do + before do + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true) + end + + it 'allows the usage ping to be configured' do + expect(setting.usage_ping_can_be_configured?).to be_truthy + end + + context 'when the usage ping is disabled in the DB' do + before do + setting.usage_ping_enabled = false + end + + it 'returns false for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_falsey + end + end + + context 'when the usage ping is enabled in the DB' do + before do + setting.usage_ping_enabled = true + end + + it 'returns true for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_truthy + end + end + end + end end From d2d6435372bd9a68ce1bad1dfe24f34d0924e048 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 9 May 2017 20:58:22 +0100 Subject: [PATCH 2/3] Add hostname to usage ping --- changelogs/unreleased/disable-usage-ping-2.yml | 4 ++++ lib/gitlab/usage_data.rb | 1 + spec/lib/gitlab/usage_data_spec.rb | 1 + 3 files changed, 6 insertions(+) create mode 100644 changelogs/unreleased/disable-usage-ping-2.yml diff --git a/changelogs/unreleased/disable-usage-ping-2.yml b/changelogs/unreleased/disable-usage-ping-2.yml new file mode 100644 index 00000000000..4abd325f120 --- /dev/null +++ b/changelogs/unreleased/disable-usage-ping-2.yml @@ -0,0 +1,4 @@ +--- +title: Add hostname to usage ping +merge_request: +author: diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 14d8e925d0e..4382cf7b12f 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -52,6 +52,7 @@ module Gitlab def license_usage_data usage_data = { uuid: current_application_settings.uuid, + hostname: Gitlab.config.gitlab.host, version: Gitlab::VERSION, active_user_count: User.active.count, recorded_at: Time.now, diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 9046d5c413f..2c46920456b 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -17,6 +17,7 @@ describe Gitlab::UsageData do edition version uuid + hostname )) end From f0b3ed91bc87117194578cfc5f58849886b5a97d Mon Sep 17 00:00:00 2001 From: Job van der Voort Date: Wed, 3 May 2017 14:24:38 +0100 Subject: [PATCH 3/3] update the documentation to reflect upcoming changes to the usage ping --- .../admin_area/settings/usage_statistics.md | 71 +++---------------- 1 file changed, 8 insertions(+), 63 deletions(-) diff --git a/doc/user/admin_area/settings/usage_statistics.md b/doc/user/admin_area/settings/usage_statistics.md index 6198d4864fa..375e7f08e8b 100644 --- a/doc/user/admin_area/settings/usage_statistics.md +++ b/doc/user/admin_area/settings/usage_statistics.md @@ -28,60 +28,13 @@ for all signed in users. [were added][ee-735] in GitLab Enterprise Edition 8.12. [Moved to GitLab Community Edition][ce-23361] in 9.1. -GitLab Inc. can collect non-sensitive information about how GitLab users -use their GitLab instance upon the activation of a ping feature -located in the admin panel (`/admin/application_settings`). +GitLab sends a weekly payload containing usage data to GitLab Inc. The usage +ping uses high-level data to help our product, support, and sales teams. It does +not send any project names, usernames, or any other specific data. The +information from the usage ping is not anonymous, it is linked to the hostname +of the instance. -You can see the **exact** JSON payload that your instance sends to GitLab -in the "Usage statistics" section of the admin panel. - -Nothing qualitative is collected. Only quantitative. That means no project -names, author names, comment bodies, names of labels, etc. - -The usage ping is sent in order for GitLab Inc. to have a better understanding -of how our users use our product, and to be more data-driven when creating or -changing features. - -The total number of the following is sent back to GitLab Inc.: - -- Comments -- Groups -- Users -- Projects -- Issues -- Labels -- CI builds -- Snippets -- Milestones -- Todos -- Pushes -- Merge requests -- Environments -- Triggers -- Deploy keys -- Pages -- Project Services -- Projects using the Prometheus service -- Issue Boards -- CI Runners -- Deployments -- Geo Nodes -- LDAP Groups -- LDAP Keys -- LDAP Users -- LFS objects -- Protected branches -- Releases -- Remote mirrors -- Uploads -- Web hooks - -Also, we track if you've installed Mattermost with GitLab. -For example: `"mattermost_enabled":true"`. - -More data will be added over time. The goal of this ping is to be as light as -possible, so it won't have any performance impact on your installation when -the calculation is made. +You can view the exact JSON payload in the administration panel. ### Deactivate the usage ping @@ -89,8 +42,8 @@ By default, usage ping is opt-out. If you want to deactivate this feature, go to the Settings page of your administration panel and uncheck the Usage ping checkbox. -To disable the usage ping and prevent it from being configured from the -administration panel, Omnibus installs can set the following in +To disable the usage ping and prevent it from being configured in future through +the administration panel, Omnibus installs can set the following in [`gitlab.rb`](https://docs.gitlab.com/omnibus/settings/configuration.html#configuration-options): ```ruby @@ -107,14 +60,6 @@ production: &base usage_ping_enabled: false ``` -## Privacy policy - -GitLab Inc. does **not** collect any sensitive information, like project names -or the content of the comments. GitLab Inc. does not disclose or otherwise make -available any of the data collected on a customer specific basis. - -Read more about this in the [Privacy policy](https://about.gitlab.com/privacy). - [ee-557]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/557 [ee-735]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/735 [ce-23361]: https://gitlab.com/gitlab-org/gitlab-ce/issues/23361