rack-tracker 1.11.2 → 1.12.0

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: a22c7f5dec27b8abd60ab5a9cbd1161e336c0063fa2d0171db5d7795a3b79024
4
- data.tar.gz: 41d811bf5ee13c120791703df76b805a2095a5c517cb763338cf807d0c776e6a
3
+ metadata.gz: 96cc84b108179e10df6c41c10fb536597f8ba93ac7106d38bbfe9b8d36e6da6e
4
+ data.tar.gz: dccdd57d1f3c8985ef500c45a6441b0821e7a1dc33dd232503bd1ca73d5ed1ef
5
5
  SHA512:
6
- metadata.gz: b2d88b11dc5d33c7639dc41058832ef5e8ca8b06121e46b72dfe08697e7b990b8588f3c50b6f30aa9fe094cd37bbcd42cfa87de71d769c2e8d2c088417149366
7
- data.tar.gz: 6067ba21908d7724eaf70a77d06887af81486315604dca450ea8740039625d4858f517ef4791617eb03918b250bd59e82a5122a982ebeba7f0d15dd1cfdc2639
6
+ metadata.gz: 78b014112e736701afb694c07384cd368a37054c8d734a8b38d9bb9224a33d0b857e8596e486a9e06d8c0038a54e9917835e7e2ba64efc96ecb5f06a21bc7b30
7
+ data.tar.gz: 9d81d707139e7393409c15a2e1f9fe7289394988bf1804613550bab4a114d3c393e175c512062bca1b3816b97ad3aa4c913614fd51a27cbc736a57bd8517aa96
@@ -6,8 +6,18 @@ rvm:
6
6
  - 2.5.3
7
7
  - 2.6.1
8
8
  - jruby-9.1.10.0
9
+ - jruby-9.2.7.0
9
10
  gemfile:
10
11
  - Gemfile
11
12
  - Gemfile.rails-3.2
12
13
  - Gemfile.rails-4.2
13
14
  - Gemfile.rails-5.2
15
+ - Gemfile.rails-6.0
16
+ matrix:
17
+ exclude:
18
+ - rvm: 2.3.8
19
+ gemfile: Gemfile.rails-6.0
20
+ - rvm: 2.4.5
21
+ gemfile: Gemfile.rails-6.0
22
+ - rvm: jruby-9.1.10.0
23
+ gemfile: Gemfile.rails-6.0
@@ -1,5 +1,9 @@
1
1
  # 1.12.0
2
2
 
3
+ * [ENHANCEMENT] Add support for Heap #147 (thx @mohanzhang)
4
+
5
+ # 1.11.2
6
+
3
7
  * [ENHANCEMENT] Allows disabling the Google Analytics pageview send. Defaults to true #131 (thx @ChrisCoffey)
4
8
 
5
9
  # 1.11.1
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'activesupport', '~> 6.0.0'
6
+ gem 'actionpack', '~> 6.0.0'
data/README.md CHANGED
@@ -615,6 +615,18 @@ config.middleware.use(Rack::Tracker) do
615
615
  end
616
616
  ```
617
617
 
618
+ ### Heap
619
+
620
+ [Heap](https://heap.io/). Heap has Projects (e.g. "Main") which have multiple
621
+ Environments (e.g. "Production" or "Development"). `env_id` is therefore the numerical ID
622
+ that represents the Environment. See Settings -> Projects -> Environments in your dashboard.
623
+
624
+ ```
625
+ config.middleware.use(Rack::Tracker) do
626
+ handler :heap, env_id: 'HEAP_ID'
627
+ end
628
+ ```
629
+
618
630
  ### Custom Handlers
619
631
 
620
632
  Tough we give you handlers for a few tracking services right out of the box, you might
@@ -26,6 +26,7 @@ require "rack/tracker/hotjar/hotjar"
26
26
  require "rack/tracker/bing/bing"
27
27
  require "rack/tracker/hubspot/hubspot"
28
28
  require "rack/tracker/drift/drift"
29
+ require "rack/tracker/heap/heap"
29
30
 
30
31
  module Rack
31
32
  class Tracker
@@ -1,5 +1,5 @@
1
- <script type="text/javascript">
2
1
  <% if tracker %>
2
+ <script type="text/javascript">
3
3
  if(typeof ga === 'undefined') {
4
4
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5
5
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@@ -40,5 +40,5 @@
40
40
  <% end %>
41
41
  <% if tracker && options[:explicit_pageview] %>
42
42
  ga('send', 'pageview', <%= pageview_url_script %>);
43
- <% end %>
44
43
  </script>
44
+ <% end %>
@@ -0,0 +1,2 @@
1
+ class Rack::Tracker::Heap < Rack::Tracker::Handler
2
+ end
@@ -0,0 +1,4 @@
1
+ <script>
2
+ window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=t.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=(r?"https:":"http:")+"//cdn.heapanalytics.com/js/heap-"+e+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","resetIdentity","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c<p.length;c++)heap[p[c]]=o(p[c])};
3
+ heap.load("<%= options[:env_id] %>");
4
+ </script>
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Tracker
3
- VERSION = '1.11.2'
3
+ VERSION = '1.12.0'
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ RSpec.describe Rack::Tracker::Heap do
2
+ def env
3
+ { foo: 'bar' }
4
+ end
5
+
6
+ it 'will be placed in the head' do
7
+ expect(described_class.position).to eq(:head)
8
+ expect(described_class.new(env).position).to eq(:head)
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ require 'support/capybara_app_helper'
2
+
3
+ RSpec.describe "Heap Integration" do
4
+ before do
5
+ setup_app(action: :heap) do |tracker|
6
+ tracker.handler :heap, { env_id: '12341234' }
7
+ end
8
+
9
+ visit '/'
10
+ end
11
+
12
+ subject { page }
13
+
14
+ it 'embeds the script with site_id' do
15
+ expect(page).to have_content('heap.load("12341234");')
16
+ end
17
+ end
@@ -1,10 +1,19 @@
1
1
  require 'support/capybara_app_helper'
2
2
 
3
3
  RSpec.describe "Rails Integration" do
4
+ let(:callable_skip_inject) do
5
+ lambda do |env|
6
+ # check for anything in the env hash to decide
7
+ # if you return the `tracker id` or `nil` to skip injection
8
+ nil
9
+ end
10
+ end
11
+
4
12
  before do
5
13
  setup_app(action: :index) do |tracker|
6
14
  tracker.handler :track_all_the_things, { custom_key: 'SomeKey123' }
7
15
  tracker.handler :another_handler, { custom_key: 'AnotherKey42' }
16
+ tracker.handler :google_analytics, { tracker: callable_skip_inject }
8
17
  end
9
18
 
10
19
  visit '/'
@@ -17,15 +26,15 @@ RSpec.describe "Rails Integration" do
17
26
  <html>
18
27
  <head>
19
28
  <title>Metal Layout</title>
20
- <script type="text/javascript">
21
- myAwesomeFunction("tracks", "like", "no-one-else", "SomeKey123");
22
- </script>
23
- </head>
29
+ <script type="text/javascript">
30
+ myAwesomeFunction("tracks", "like", "no-one-else", "SomeKey123");
31
+ </script>
32
+ </head>
24
33
  <body class="do-we-support-attributes-on-the-body-tag">
25
34
  <h1>welcome to metal#index</h1>
26
- <script type="text/javascript">
27
- anotherFunction("tracks-event-from-down-under", "AnotherKey42");
28
- </script>
35
+ <script type="text/javascript">
36
+ anotherFunction("tracks-event-from-down-under", "AnotherKey42");
37
+ </script>
29
38
  </body>
30
39
  </html>
31
40
  HTML
@@ -128,4 +128,8 @@ class MetalController < ActionController::Metal
128
128
  def drift
129
129
  render "metal/index"
130
130
  end
131
+
132
+ def heap
133
+ render "metal/index"
134
+ end
131
135
  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.2
4
+ version: 1.12.0
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-25 00:00:00.000000000 Z
12
+ date: 2019-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -154,6 +154,7 @@ files:
154
154
  - Gemfile.rails-3.2
155
155
  - Gemfile.rails-4.2
156
156
  - Gemfile.rails-5.2
157
+ - Gemfile.rails-6.0
157
158
  - LICENSE.txt
158
159
  - README.md
159
160
  - Rakefile
@@ -184,6 +185,8 @@ files:
184
185
  - lib/rack/tracker/google_tag_manager/template/google_tag_manager_head.erb
185
186
  - lib/rack/tracker/handler.rb
186
187
  - lib/rack/tracker/handler_delegator.rb
188
+ - lib/rack/tracker/heap/heap.rb
189
+ - lib/rack/tracker/heap/template/heap.erb
187
190
  - lib/rack/tracker/hotjar/hotjar.rb
188
191
  - lib/rack/tracker/hotjar/template/hotjar.erb
189
192
  - lib/rack/tracker/hubspot/hubspot.rb
@@ -214,6 +217,7 @@ files:
214
217
  - spec/handler/google_global_spec.rb
215
218
  - spec/handler/google_tag_manager_spec.rb
216
219
  - spec/handler/handler_spec.rb
220
+ - spec/handler/heap_spec.rb
217
221
  - spec/handler/hotjar_spec.rb
218
222
  - spec/handler/hubspot_spec.rb
219
223
  - spec/handler/vwo_spec.rb
@@ -228,6 +232,7 @@ files:
228
232
  - spec/integration/google_analytics_integration_spec.rb
229
233
  - spec/integration/google_global_integration_spec.rb
230
234
  - spec/integration/google_tag_manager_integration_spec.rb
235
+ - spec/integration/heap_integration_spec.rb
231
236
  - spec/integration/hotjar_integration_spec.rb
232
237
  - spec/integration/hubspot_integration_spec.rb
233
238
  - spec/integration/rails_integration_spec.rb
@@ -261,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
266
  - !ruby/object:Gem::Version
262
267
  version: '0'
263
268
  requirements: []
264
- rubygems_version: 3.0.1
269
+ rubygems_version: 3.0.6
265
270
  signing_key:
266
271
  specification_version: 4
267
272
  summary: Tracking made easy
@@ -284,6 +289,7 @@ test_files:
284
289
  - spec/handler/google_global_spec.rb
285
290
  - spec/handler/google_tag_manager_spec.rb
286
291
  - spec/handler/handler_spec.rb
292
+ - spec/handler/heap_spec.rb
287
293
  - spec/handler/hotjar_spec.rb
288
294
  - spec/handler/hubspot_spec.rb
289
295
  - spec/handler/vwo_spec.rb
@@ -298,6 +304,7 @@ test_files:
298
304
  - spec/integration/google_analytics_integration_spec.rb
299
305
  - spec/integration/google_global_integration_spec.rb
300
306
  - spec/integration/google_tag_manager_integration_spec.rb
307
+ - spec/integration/heap_integration_spec.rb
301
308
  - spec/integration/hotjar_integration_spec.rb
302
309
  - spec/integration/hubspot_integration_spec.rb
303
310
  - spec/integration/rails_integration_spec.rb