Commit 620bf1c9 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '271263-piwik-support-the-disabling-of-cookies' into 'master'

Matomo: Support the disabling of cookies

See merge request gitlab-org/gitlab!52831
parents fafb3dd6 3c773379
<!-- Matomo -->
- matomo_disable_cookies = extra_config.has_key?('matomo_disable_cookies') && extra_config.matomo_disable_cookies
= javascript_tag do
:plain
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
#{matomo_disable_cookies ? '_paq.push(["disableCookies"])' : ""};
(function() {
var u="//#{extra_config.matomo_url}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
......
---
title: 'Matomo: Support the disabling of cookies'
merge_request: 52831
author: 'otheus@gmail.com'
type: added
......@@ -1242,6 +1242,7 @@ production: &base
## Matomo analytics.
# matomo_url: '_your_matomo_url'
# matomo_site_id: '_your_matomo_site_id'
# matomo_disable_cookies: false
rack_attack:
git_basic_auth:
......
......@@ -102,6 +102,44 @@ RSpec.describe 'layouts/_head' do
expect(rendered).to match(/<script.*>.*var u="\/\/#{matomo_host}\/".*<\/script>/m)
expect(rendered).to match(%r(<noscript>.*<img src="//#{matomo_host}/matomo.php.*</noscript>))
end
context 'matomo_disable_cookies' do
context 'when true' do
before do
stub_config(extra: { matomo_url: matomo_host, matomo_site_id: 12345, matomo_disable_cookies: true })
end
it 'disables cookies' do
render
expect(rendered).to include('_paq.push(["disableCookies"])')
end
end
context 'when false' do
before do
stub_config(extra: { matomo_url: matomo_host, matomo_site_id: 12345, matomo_disable_cookies: false })
end
it 'does not disable cookies' do
render
expect(rendered).not_to include('_paq.push(["disableCookies"])')
end
end
context 'when absent' do
before do
stub_config(extra: { matomo_url: matomo_host, matomo_site_id: 12345 })
end
it 'does not disable cookies' do
render
expect(rendered).not_to include('_paq.push(["disableCookies"])')
end
end
end
end
def stub_helper_with_safe_string(method)
......
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