card-mod-google_analytics 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e19af019c23ce9bd0f711e62ed0ca9373227bbb5695e14703b91fd28acb18194
4
+ data.tar.gz: 3be3413e66bd1249adf5db3e8c105f7b08d92b1d6050a633117b39def00e9c05
5
+ SHA512:
6
+ metadata.gz: 43d7b6769ec3ef8988440d0e52c790625f060079894a0166234001ae33ba94aaebd867a0207757565b5623ccab112f8e8b65d95ad35d5db9f1c42672f190d440
7
+ data.tar.gz: dbf8a7b78db513970b323b6e325f5896824ab5db7430b4f23ba2da760700dff0dfdb882f9340cdfa73e3fdfe35a72e3966ec0318511b50e3c71f6d62a3b6ee8a
File without changes
@@ -0,0 +1,42 @@
1
+ require "staccato"
2
+
3
+ mattr_accessor :server_side_tracking_formats
4
+
5
+ self.server_side_tracking_formats = %i[csv json]
6
+
7
+ event :track_page, before: :show_page, when: :track_page? do
8
+ tracker.pageview path: Env.controller.request&.path, host: Env.host, title: name
9
+ end
10
+
11
+ def track_page?
12
+ google_analytics_key &&
13
+ Env.controller&.response_format&.in?(server_side_tracking_formats)
14
+ end
15
+
16
+ def tracker
17
+ return unless google_analytics_key
18
+
19
+ ::Staccato.tracker google_analytics_key # , nil, ssl: true
20
+ end
21
+
22
+ def google_analytics_key
23
+ @google_analytics_key ||=
24
+ Card::Rule.global_setting(:google_analytics_key) ||
25
+ Card.config.google_analytics_key
26
+ end
27
+
28
+ format :html do
29
+ delegate :tracker, :google_analytics_key, to: :card
30
+
31
+ def views_in_head
32
+ super << :google_analytics_snippet
33
+ end
34
+
35
+ view :google_analytics_snippet, unknown: true, perms: :none do
36
+ haml :google_analytics_snippet if google_analytics_key
37
+ end
38
+
39
+ def google_analytics_snippet_vars
40
+ { anonymizeIp: true }
41
+ end
42
+ end
@@ -0,0 +1,13 @@
1
+ / Google Analytics
2
+ %script
3
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
4
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
6
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
7
+
8
+ ga('create', '#{google_analytics_key}', 'auto');
9
+ - google_analytics_snippet_vars.each do |key, value|
10
+ - value = "'#{value}'" if value.is_a? String
11
+ ga('set', '#{key}', #{value})
12
+ ga('send', 'pageview');
13
+ / End Google Analytics
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: card-mod-google_analytics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.0
5
+ platform: ruby
6
+ authors:
7
+ - Ethan McCutchen
8
+ - Philipp Kühl
9
+ - Gerry Gleason
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2020-12-24 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: card
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.101.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 1.101.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: staccato
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ description: ''
44
+ email:
45
+ - info@decko.org
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - lib/card/mod/google_analytics.rb
51
+ - set/all/google_analytics.rb
52
+ - set/all/google_analytics_snippet.haml
53
+ homepage: http://decko.org
54
+ licenses:
55
+ - GPL-3.0
56
+ metadata:
57
+ card-mod: google_analytics
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '2.5'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubygems_version: 3.0.3
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Google Analytics support for decko
77
+ test_files: []