card-mod-google_analytics 0.11.7 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/set/all/google_analytics.rb +30 -15
  3. metadata +8 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c62de7ae5b72ea83cd7fa399ec4479d7a409ebd828c4404c701c3b50ef82582
4
- data.tar.gz: 04bae4fd6e6dbe93baed706f09dfc908ec76b026c9290ddd0152a0bdbb777235
3
+ metadata.gz: 5dcd36529299fa6c209403d904e0b455d9d0e3e8db3ac3ee9a0428fcbfe23e1c
4
+ data.tar.gz: 105361cca8e531c4f91c85161af734f1d5df844a541bad42230cf559f262dee8
5
5
  SHA512:
6
- metadata.gz: f18385028bae1d28e5d1077933a9998635143fc1798f0e4c0b8424e94d44a3cb8c6997a5d4e8160e33c85559ed0a09f08dd7416015d4bb69246b7857fac0abce
7
- data.tar.gz: e036842e0929c40b8f63f4977dc30d1414dae3ed3463addb1f8640cf7c58893a9122922e792444ba29bb3c1f0f5d998730d1326de48e37be883018ae485d24ab
6
+ metadata.gz: 9a05facf0d7bd4e0dfc24c9af7517d875c5aeb7e819aa7e1aeb0b385594e69bfe852b7948b8ef4c458faa6b5fe1fa029dfda8a37ebf693b64e955e9284e033dd
7
+ data.tar.gz: c90bfb04ceee1f794f7a840f2a129931f6b6597310a8d30e3cdb074c6cb54398ae7608f400cd8c83c9f5abc91625e3a2bde6a1b1134f60b35ef322812bb7feaa
@@ -1,32 +1,47 @@
1
1
  require "staccato"
2
2
 
3
- mattr_accessor :server_side_tracking_formats
4
-
5
- self.server_side_tracking_formats = %i[csv json]
3
+ event :track_page, before: :show_page, when: :track_page_from_server? do
4
+ track_page!
5
+ end
6
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
7
+ def track_page!
8
+ tracker.pageview tracker_options
9
9
  end
10
10
 
11
- def track_page?
12
- google_analytics_key &&
13
- Env.controller&.response_format&.in?(server_side_tracking_formats)
11
+ # TODO: optimize so it doesn't keep doing lookup if there is no key.
12
+ def google_analytics_key
13
+ @google_analytics_key ||=
14
+ Card::Rule.global_setting(:google_analytics_key) ||
15
+ Card.config.google_analytics_key
14
16
  end
15
17
 
16
18
  def tracker
17
- return unless google_analytics_key
19
+ tracker_key && ::Staccato.tracker(tracker_key) # , nil, ssl: true
20
+ end
18
21
 
19
- ::Staccato.tracker google_analytics_key # , nil, ssl: true
22
+ # can override to have separate keys for web and API
23
+ def tracker_key
24
+ google_analytics_key
20
25
  end
21
26
 
22
- def google_analytics_key
23
- @google_analytics_key ||=
24
- Card::Rule.global_setting(:google_analytics_key) ||
25
- Card.config.google_analytics_key
27
+ def tracker_options
28
+ r = Env.controller.request
29
+ {
30
+ path: r.path,
31
+ host: Env.host,
32
+ title: name,
33
+ user_id: Auth.current_id,
34
+ user_ip: r.remote_ip
35
+ }
36
+ end
37
+
38
+ # for override
39
+ def track_page_from_server?
40
+ false
26
41
  end
27
42
 
28
43
  format :html do
29
- delegate :tracker, :google_analytics_key, to: :card
44
+ delegate :google_analytics_key, to: :card
30
45
 
31
46
  def views_in_head
32
47
  super << :google_analytics_snippet
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-google_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.7
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-08-01 00:00:00.000000000 Z
13
+ date: 2021-08-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.101.7
21
+ version: 1.103.2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.101.7
28
+ version: 1.103.2
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: staccato
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ">="
33
+ - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: '0'
35
+ version: '0.5'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ">="
40
+ - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '0'
42
+ version: '0.5'
43
43
  description: ''
44
44
  email:
45
45
  - info@decko.org