rack-tracker 1.11.1 → 1.11.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f58fd678ef800ce1fb874899514a49c8e5c50ab58297cb5fffddb4da8e6eea4
4
- data.tar.gz: 02304e75ff11256123303d2dd393f0dcd393a918cb04f1d65ae5220cd6510083
3
+ metadata.gz: a22c7f5dec27b8abd60ab5a9cbd1161e336c0063fa2d0171db5d7795a3b79024
4
+ data.tar.gz: 41d811bf5ee13c120791703df76b805a2095a5c517cb763338cf807d0c776e6a
5
5
  SHA512:
6
- metadata.gz: ee39c4be171e10aec3e319b55bea51663a479263c13aeb2274c630d560511f27ee3c4533e911c305728b0399a99a118388b184af9f79383d00a4342a6e774f8a
7
- data.tar.gz: db3ab55fead72f230b48f1e9785853f3dae007561ba5bd311d1d6a41d0aa9d7978313993dbdf96519f357bc82b9300c0f953fb5f28e39296d40972d3d4677189
6
+ metadata.gz: b2d88b11dc5d33c7639dc41058832ef5e8ca8b06121e46b72dfe08697e7b990b8588f3c50b6f30aa9fe094cd37bbcd42cfa87de71d769c2e8d2c088417149366
7
+ data.tar.gz: 6067ba21908d7724eaf70a77d06887af81486315604dca450ea8740039625d4858f517ef4791617eb03918b250bd59e82a5122a982ebeba7f0d15dd1cfdc2639
@@ -1,3 +1,7 @@
1
+ # 1.12.0
2
+
3
+ * [ENHANCEMENT] Allows disabling the Google Analytics pageview send. Defaults to true #131 (thx @ChrisCoffey)
4
+
1
5
  # 1.11.1
2
6
 
3
7
  * [BUGFIX] Uncaught ReferenceError Fix: wrap Drift account ID in quotes #140 (thx @sassela)
data/README.md CHANGED
@@ -140,6 +140,7 @@ end
140
140
  * `:enhanced_ecommerce` - Enables [Enhanced Ecommerce Tracking](https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce)
141
141
  * `:optimize` - pass [Google Optimize container ID](https://support.google.com/360suite/optimize/answer/6262084#example-combined-snippet) as value (e.g. `optimize: 'GTM-1234'`).
142
142
  * `:pageview_url_script` - a String containing a custom js script evaluating to the url that shoudl be given to the pageview event. Default to `window.location.pathname + window.location.search`.
143
+ * `:explicit_pageview` - A boolean that controls whether to send the `pageview` event on pageload. This defaults to true.
143
144
 
144
145
  #### Events
145
146
 
@@ -2,6 +2,11 @@ class Rack::Tracker::GoogleAnalytics < Rack::Tracker::Handler
2
2
 
3
3
  self.allowed_tracker_options = [:cookie_domain, :user_id]
4
4
 
5
+ def initialize(env, options = {})
6
+ options[:explicit_pageview] = true if !options.has_key?(:explicit_pageview)
7
+ super(env, options)
8
+ end
9
+
5
10
  class Send < OpenStruct
6
11
  def initialize(attrs = {})
7
12
  attrs.reverse_merge!(type: 'event')
@@ -38,7 +38,7 @@
38
38
  <% if options[:ecommerce] && ecommerce_events.any? %>
39
39
  ga('ecommerce:send');
40
40
  <% end %>
41
- <% if tracker %>
41
+ <% if tracker && options[:explicit_pageview] %>
42
42
  ga('send', 'pageview', <%= pageview_url_script %>);
43
43
  <% end %>
44
44
  </script>
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Tracker
3
- VERSION = '1.11.1'
3
+ VERSION = '1.11.2'
4
4
  end
5
5
  end
@@ -284,5 +284,21 @@ RSpec.describe Rack::Tracker::GoogleAnalytics do
284
284
  expect(subject.pageview_url_script).to eql ("{ 'page': location.pathname + location.search + location.hash }")
285
285
  end
286
286
  end
287
+
288
+ context 'with explicit_pageview disabled' do
289
+ subject { described_class.new(env, {tracker: 'afake', explicit_pageview: false }).render }
290
+
291
+ it 'does not send a pageview event' do
292
+ expect(subject).not_to include %q{ga('send', 'pageview',}
293
+ end
294
+ end
295
+
296
+ context 'defaults to sending the pageview event' do
297
+ subject { described_class.new(env, {tracker: 'afake'}).render }
298
+
299
+ it 'does not send a pageview event' do
300
+ expect(subject).to include "ga('send', 'pageview'"
301
+ end
302
+ end
287
303
  end
288
304
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.1
4
+ version: 1.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Brillert
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-01 00:00:00.000000000 Z
12
+ date: 2019-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack