gamco 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/README.md +16 -0
- data/lib/gamco/builder.rb +4 -6
- data/lib/gamco/configuration.rb +1 -0
- data/lib/gamco/errors/no_tag_id.rb +5 -1
- data/lib/gamco/helper.rb +2 -0
- data/lib/gamco/version.rb +1 -1
- data/lib/gamco.rb +1 -0
- data/lib/generators/gamco/templates/gamco.rb +1 -0
- 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: f9d7669e0d92350bceb06b3a05a23d44138ae1ad4ab7314ce55eb0dcde41aa43
|
4
|
+
data.tar.gz: 6f35eb96d66b13d7ac550f52e206de841f60626c42aba204cd8bbd048fe2d642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 044b24d61425016ba9306e1f98baa7727931125d6d06f4da3758e4959de3241abf8ba1c87997e0bf1b1018e91f32cafd78d30b231f528f32e1038a3740e1d1c4
|
7
|
+
data.tar.gz: f69ffbfe20862849c52ff21ea58ead2665fee86a637ed03d30177e04598a8243b23a51b35427ef571c7b4096d7cca2fd47887d5dff2af92fa3fa9ecb0a73297a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [Released]
|
4
|
+
|
5
|
+
## [0.2.0] - 2022-10-05
|
6
|
+
|
7
|
+
- Add Configuration.active option to control if data should
|
8
|
+
be sent to Google Analytics.
|
9
|
+
|
10
|
+
## [0.1.1] - 2022-10-04
|
11
|
+
|
12
|
+
- Improve `ga_secure` helper to avoid using it when passed
|
13
|
+
value is nil or empty.
|
14
|
+
|
15
|
+
## [0.1.0] - 2022-10-04
|
4
16
|
|
5
17
|
- Initial release
|
data/README.md
CHANGED
@@ -98,6 +98,22 @@ Gamco.setup do |config|
|
|
98
98
|
end
|
99
99
|
```
|
100
100
|
|
101
|
+
### Usage per environment
|
102
|
+
|
103
|
+
It is possible that you want to send data to Google Analytics just in
|
104
|
+
production environments. You can control that using the `active` configuration
|
105
|
+
option in the initializer `config/initializers/gamco.rb`:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
Gamco.setup do |config|
|
109
|
+
# ===> Required GA4 configuration options
|
110
|
+
config.tag_id = "G-XXXXXXXXX"
|
111
|
+
config.active = Rails.application.credentials.dig(:gamco, :active)
|
112
|
+
|
113
|
+
...
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
101
117
|
## Development
|
102
118
|
|
103
119
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
data/lib/gamco/builder.rb
CHANGED
@@ -34,12 +34,10 @@ module Gamco
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def gtag_script_content(tag_id, options)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
gtag('
|
41
|
-
gtag('config', '#{tag_id}', #{options.to_json});
|
42
|
-
FOO
|
37
|
+
"window.dataLayer = window.dataLayer || [];"\
|
38
|
+
"function gtag(){dataLayer.push(arguments);}"\
|
39
|
+
"gtag('js', new Date());"\
|
40
|
+
"gtag('config', '#{tag_id}', #{options.to_json});"
|
43
41
|
end
|
44
42
|
|
45
43
|
def tag_manager_script_url
|
data/lib/gamco/configuration.rb
CHANGED
data/lib/gamco/helper.rb
CHANGED
@@ -3,11 +3,13 @@
|
|
3
3
|
module Gamco
|
4
4
|
module Helper
|
5
5
|
def ga_javascript_tags(tag_id: Configuration.tag_id, **options)
|
6
|
+
return unless Configuration.active
|
6
7
|
raise Errors::NoTagId unless tag_id.present?
|
7
8
|
ga_builder.javascript_tags(tag_id, options)
|
8
9
|
end
|
9
10
|
|
10
11
|
def ga_tag(type, event, options = {})
|
12
|
+
return unless Configuration.active
|
11
13
|
ga_builder.tag(type, event, options)
|
12
14
|
end
|
13
15
|
|
data/lib/gamco/version.rb
CHANGED
data/lib/gamco.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gamco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Gutiérrez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|