eff_matomo 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -5
- data/README.md +2 -0
- data/lib/matomo.rb +3 -2
- data/lib/matomo/version.rb +1 -1
- data/lib/matomo/view_helpers.rb +20 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0f5b9b6c1622f1a82e57fe91150c994d1d57ae7a8de6065a9ff0fd88270da07
|
4
|
+
data.tar.gz: 14296b4c803bf9de66d973e9600c2056be23eb809a0102ee49e352c356c8398f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5345b9422957311b1ff545419a8e2ad77e1b94e7a1919ce7b47aa4efc2ffd98848073123e92ad235c372e25067681d3fcbdc9b6204b20504586d5c7ef6ab9d19
|
7
|
+
data.tar.gz: 6bbb7991f745609bfc6bea23e4caf0efba75477464c6f2f10fd7cdfe8c435675cd28ad380212fae423f81adba0ee909c72d2ba30f418fad9d2b30eb1e31d05b3
|
data/Gemfile.lock
CHANGED
@@ -1,29 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eff_matomo (0.2.
|
4
|
+
eff_matomo (0.2.3)
|
5
5
|
activesupport
|
6
6
|
httparty
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (5.2.
|
11
|
+
activesupport (5.2.2)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 0.7, < 2)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
tzinfo (~> 1.1)
|
16
16
|
addressable (2.5.2)
|
17
17
|
public_suffix (>= 2.0.2, < 4.0)
|
18
|
-
concurrent-ruby (1.
|
18
|
+
concurrent-ruby (1.1.4)
|
19
19
|
crack (0.4.3)
|
20
20
|
safe_yaml (~> 1.0.0)
|
21
21
|
diff-lcs (1.3)
|
22
22
|
hashdiff (0.3.7)
|
23
|
-
httparty (0.16.
|
23
|
+
httparty (0.16.4)
|
24
|
+
mime-types (~> 3.0)
|
24
25
|
multi_xml (>= 0.5.2)
|
25
|
-
i18n (1.
|
26
|
+
i18n (1.6.0)
|
26
27
|
concurrent-ruby (~> 1.0)
|
28
|
+
mime-types (3.2.2)
|
29
|
+
mime-types-data (~> 3.2015)
|
30
|
+
mime-types-data (3.2018.0812)
|
27
31
|
minitest (5.11.3)
|
28
32
|
multi_xml (0.6.0)
|
29
33
|
public_suffix (3.0.3)
|
data/README.md
CHANGED
@@ -30,6 +30,8 @@ This gem reads two environment variables:
|
|
30
30
|
|
31
31
|
Add `<%= matomo_tracking_embed %>` to the footer of your application layout template.
|
32
32
|
|
33
|
+
`{action_name = [NAME]}` can be passed to set the action name manually. Otherwise, eff_matomo will attempt to use a `page_title` helper or else omit the action name.
|
34
|
+
|
33
35
|
### Displaying Matomo data
|
34
36
|
|
35
37
|
This gem provides allows users to import site usage data from Matomo to display in their application. It currently supports two types of data:
|
data/lib/matomo.rb
CHANGED
@@ -8,7 +8,7 @@ module Matomo
|
|
8
8
|
class Referrer
|
9
9
|
attr_accessor :label, :visits
|
10
10
|
|
11
|
-
def initialize(params)
|
11
|
+
def initialize(params = {})
|
12
12
|
@label = params["label"]
|
13
13
|
@visits = params["nb_visits"] || 0
|
14
14
|
@actions = params["nb_actions"] || 0
|
@@ -16,6 +16,7 @@ module Matomo
|
|
16
16
|
|
17
17
|
def actions_per_visit
|
18
18
|
return 0 unless @actions and @visits
|
19
|
+
return 0 if @visits == 0
|
19
20
|
(@actions/@visits.to_f).round(1)
|
20
21
|
end
|
21
22
|
|
@@ -37,7 +38,7 @@ module Matomo
|
|
37
38
|
class Page
|
38
39
|
attr_accessor :hits, :visits, :path
|
39
40
|
|
40
|
-
def initialize(path, params)
|
41
|
+
def initialize(path, params = {})
|
41
42
|
@path = path
|
42
43
|
@label = params["label"]
|
43
44
|
@hits = params["nb_hits"] || 0
|
data/lib/matomo/version.rb
CHANGED
data/lib/matomo/view_helpers.rb
CHANGED
@@ -1,23 +1,31 @@
|
|
1
1
|
module Matomo
|
2
2
|
module ViewHelpers
|
3
|
-
def
|
4
|
-
"#{Matomo.base_url}/js/?" + {
|
5
|
-
idsite: Matomo.site_id,
|
6
|
-
rec: 1,
|
7
|
-
action_name: page_title,
|
8
|
-
url: request.original_url
|
9
|
-
}.to_param
|
10
|
-
end
|
11
|
-
|
12
|
-
def matomo_tracking_embed
|
3
|
+
def matomo_tracking_embed(opts = {})
|
13
4
|
content_tag(:div, id: "anon-stats") do
|
14
5
|
content_tag(:noscript) do
|
15
|
-
tag(:img, src: matomo_tracking_url, style: "border:0", alt: "")
|
6
|
+
tag(:img, src: matomo_tracking_url(opts), style: "border:0", alt: "")
|
16
7
|
end +
|
17
8
|
javascript_tag do
|
18
|
-
"document.getElementById('anon-stats').innerHTML = '<img src=\"#{matomo_tracking_url}\"?urlref=' + encodeURIComponent(document.referrer) + 'style=\"border:0\" alt=\"\" />';".html_safe
|
9
|
+
"document.getElementById('anon-stats').innerHTML = '<img src=\"#{matomo_tracking_url(opts)}\"?urlref=' + encodeURIComponent(document.referrer) + 'style=\"border:0\" alt=\"\" />';".html_safe
|
19
10
|
end
|
20
11
|
end
|
21
12
|
end
|
13
|
+
|
14
|
+
def matomo_tracking_url(opts = {})
|
15
|
+
"#{Matomo.base_url}/js/?" + {
|
16
|
+
idsite: Matomo.site_id,
|
17
|
+
rec: 1,
|
18
|
+
action_name: action_name_or_default(opts[:action_name]),
|
19
|
+
url: request.original_url
|
20
|
+
}.compact.to_param
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def action_name_or_default(name)
|
26
|
+
return name unless name.nil?
|
27
|
+
return page_title if defined?(page_title)
|
28
|
+
return nil
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eff_matomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vivian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|