# HG changeset patch # User Alishan Ladhani <aladhani@gitlab.com> # Date 1613062412 0 # Thu Feb 11 16:53:32 2021 +0000 # Node ID 1daeb331beacb60a15a0d09cd7d363bcb2cbb2c7 # Parent 68dd1b76fe20241e8b6b9f6f8fe0b384bcecfcdb Add matomo_disable_cookies setting diff --git a/changelogs/unreleased/5744-gitlab-yml-piwik-disable-cookies.yml b/changelogs/unreleased/5744-gitlab-yml-piwik-disable-cookies.yml new file mode 100644 --- /dev/null +++ b/changelogs/unreleased/5744-gitlab-yml-piwik-disable-cookies.yml @@ -0,0 +1,5 @@ +--- +title: Add matomo_disable_cookies setting +merge_request: 4979 +author: +type: added diff --git a/files/gitlab-config-template/gitlab.rb.template b/files/gitlab-config-template/gitlab.rb.template --- a/files/gitlab-config-template/gitlab.rb.template +++ b/files/gitlab-config-template/gitlab.rb.template @@ -618,6 +618,7 @@ # gitlab_rails['extra_google_tag_manager_id'] = '_your_tracking_id' # gitlab_rails['extra_matomo_url'] = '_your_matomo_url' # gitlab_rails['extra_matomo_site_id'] = '_your_matomo_site_id' +# gitlab_rails['extra_matomo_disable_cookies'] = false ##! Docs: https://docs.gitlab.com/omnibus/settings/environment-variables.html # gitlab_rails['env'] = { diff --git a/files/gitlab-cookbooks/gitlab/attributes/default.rb b/files/gitlab-cookbooks/gitlab/attributes/default.rb --- a/files/gitlab-cookbooks/gitlab/attributes/default.rb +++ b/files/gitlab-cookbooks/gitlab/attributes/default.rb @@ -384,6 +384,7 @@ default['gitlab']['gitlab-rails']['extra_google_tag_manager_id'] = nil default['gitlab']['gitlab-rails']['extra_matomo_url'] = nil default['gitlab']['gitlab-rails']['extra_matomo_site_id'] = nil +default['gitlab']['gitlab-rails']['extra_matomo_disable_cookies'] = nil default['gitlab']['gitlab-rails']['rack_attack_git_basic_auth'] = nil default['gitlab']['gitlab-rails']['db_adapter'] = "postgresql" diff --git a/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb b/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb --- a/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb @@ -930,6 +930,7 @@ ## matomo analytics. matomo_url: <%= quote(@extra_matomo_url) %> matomo_site_id: <%= quote(@extra_matomo_site_id) %> + matomo_disable_cookies: <%= @extra_matomo_disable_cookies %> <% end %> rack_attack: diff --git a/spec/chef/recipes/gitlab-rails_spec.rb b/spec/chef/recipes/gitlab-rails_spec.rb --- a/spec/chef/recipes/gitlab-rails_spec.rb +++ b/spec/chef/recipes/gitlab-rails_spec.rb @@ -392,6 +392,50 @@ end end + context 'matomo_disable_cookies' do + context 'when true' do + before do + stub_gitlab_rb( + gitlab_rails: { extra_matomo_disable_cookies: true } + ) + end + + it 'should set matomo_disable_cookies to true' do + expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables( + hash_including( + 'extra_matomo_disable_cookies' => true + ) + ) + end + end + + context 'when false' do + before do + stub_gitlab_rb( + gitlab_rails: { extra_matomo_disable_cookies: false } + ) + end + + it 'should set matomo_disable_cookies to false' do + expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables( + hash_including( + 'extra_matomo_disable_cookies' => false + ) + ) + end + end + + context 'when absent' do + it 'should set matomo_disable_cookies to nil' do + expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables( + hash_including( + 'extra_matomo_disable_cookies' => nil + ) + ) + end + end + end + context 'when sentry is disabled' do it 'should set sentry variable to nil' do expect(chef_run).to create_templatesymlink('Create a gitlab.yml and create a symlink to Rails root').with_variables(