Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4bcd079d
Commit
4bcd079d
authored
Feb 09, 2021
by
Alishan Ladhani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add default setting for matomo_disable_cookies
parent
d566a31e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
35 deletions
+11
-35
app/views/layouts/_matomo.html.haml
app/views/layouts/_matomo.html.haml
+1
-2
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
spec/views/layouts/_head.html.haml_spec.rb
spec/views/layouts/_head.html.haml_spec.rb
+9
-33
No files found.
app/views/layouts/_matomo.html.haml
View file @
4bcd079d
<!-- 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"])'
:
""
}
;
#{
extra_config
.
matomo_disable_cookies
?
'_paq.push(["disableCookies"])'
:
""
}
;
(function() {
var u="//
#{
extra_config
.
matomo_url
}
/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
...
...
config/initializers/1_settings.rb
View file @
4bcd079d
...
...
@@ -819,6 +819,7 @@ Settings.forti_token_cloud['enabled'] = false if Settings.forti_token_cloud['ena
Settings
[
'extra'
]
||=
Settingslogic
.
new
({})
Settings
.
extra
[
'matomo_site_id'
]
||=
Settings
.
extra
[
'piwik_site_id'
]
if
Settings
.
extra
[
'piwik_site_id'
].
present?
Settings
.
extra
[
'matomo_url'
]
||=
Settings
.
extra
[
'piwik_url'
]
if
Settings
.
extra
[
'piwik_url'
].
present?
Settings
.
extra
[
'matomo_disable_cookies'
]
=
false
if
Settings
.
extra
[
'matomo_disable_cookies'
].
nil?
#
# Rack::Attack settings
...
...
spec/views/layouts/_head.html.haml_spec.rb
View file @
4bcd079d
...
...
@@ -92,7 +92,8 @@ RSpec.describe 'layouts/_head' do
before
do
stub_config
(
extra:
{
matomo_url:
matomo_host
,
matomo_site_id:
12345
matomo_site_id:
12345
,
matomo_disable_cookies:
false
})
end
...
...
@@ -101,10 +102,10 @@ 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>)
)
expect
(
rendered
).
not_to
include
(
'_paq.push(["disableCookies"])'
)
end
context
'matomo_disable_cookies'
do
context
'when true'
do
context
'when matomo_disable_cookies is true'
do
before
do
stub_config
(
extra:
{
matomo_url:
matomo_host
,
matomo_site_id:
12345
,
matomo_disable_cookies:
true
})
end
...
...
@@ -115,31 +116,6 @@ RSpec.describe 'layouts/_head' do
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment