rack-tracker 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a933eccd9730dfd27db81c2f732ea830762451307897776f8063d7ea7fad50e
4
- data.tar.gz: '0930fcfb478012d19570598db7b8931a25c81bbb4f2d1019c694c8a7c9a0da08'
3
+ metadata.gz: 43c9e6c847d6027e64187d444e7072ad4a403cf57d51f5463e2212321aa6b966
4
+ data.tar.gz: ab96439cd23a92e064741494d7bac62ee71ade68cce37085d9a5618f980fc11a
5
5
  SHA512:
6
- metadata.gz: beb180ef84c7a6c76ad1ed38a7815cdd51c20022d07de6b48779d052b9ce8f6b8431f49d73e74289113cf459d5b1c8c54c159dcee5d9c79b9b8bb0e7378c53a6
7
- data.tar.gz: c78cc4ae1977fbb49cc09a6f673941ed7905fc522fb8f3e7538fcd5e2d8bc2fdd0993d61dcaec338a1a553e1cc723c882ab18d948fdce667142e0bb09816eb81
6
+ metadata.gz: 5baa0bb87f39e551f983ce8c0637c8bb90dbfb70a0f3f9bfd8c011eb6564b5ebf69eefe6d648a1cad54978b267ef2140e0e268ca7e52977e4d782ceb51b737a0
7
+ data.tar.gz: adb6cad395e5d8a4aa3dc81e95314ee415a1d1a6cf82eb8f9477ab75e5f9b04454f5736eab287fa78a8a6c6356db302c89f98a1a42ec91101fcf78182fe7bfec
@@ -1,3 +1,7 @@
1
+ # 1.11.0
2
+
3
+ * [ENHANCEMENT] Add support for Drift #139 (thx @sassela)
4
+
1
5
  # 1.10.0
2
6
 
3
7
  * [ENHANCEMENT] Hubspot integration #136 (thx @ChrisCoffey)
data/README.md CHANGED
@@ -604,6 +604,15 @@ config.middleware.use(Rack::Tracker) do
604
604
  end
605
605
  ```
606
606
 
607
+ ### Drift
608
+
609
+ [Drift](https://www.drift.com/)
610
+
611
+ ```
612
+ config.middleware.use(Rack::Tracker) do
613
+ handler :drift, account_id: 'DRIFT_ID'
614
+ end
615
+ ```
607
616
 
608
617
  ### Custom Handlers
609
618
 
@@ -25,6 +25,7 @@ require "rack/tracker/zanox/zanox"
25
25
  require "rack/tracker/hotjar/hotjar"
26
26
  require "rack/tracker/bing/bing"
27
27
  require "rack/tracker/hubspot/hubspot"
28
+ require "rack/tracker/drift/drift"
28
29
 
29
30
  module Rack
30
31
  class Tracker
@@ -0,0 +1,2 @@
1
+ class Rack::Tracker::Drift < Rack::Tracker::Handler
2
+ end
@@ -0,0 +1,26 @@
1
+ <script>
2
+ "use strict";
3
+
4
+ !function() {
5
+ var t = window.driftt = window.drift = window.driftt || [];
6
+ if (!t.init) {
7
+ if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
8
+ t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
9
+ t.factory = function(e) {
10
+ return function() {
11
+ var n = Array.prototype.slice.call(arguments);
12
+ return n.unshift(e), t.push(n), t;
13
+ };
14
+ }, t.methods.forEach(function(e) {
15
+ t[e] = t.factory(e);
16
+ }), t.load = function(t) {
17
+ var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
18
+ o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
19
+ var i = document.getElementsByTagName("script")[0];
20
+ i.parentNode.insertBefore(o, i);
21
+ };
22
+ }
23
+ }();
24
+ drift.SNIPPET_VERSION = '0.3.1';
25
+ drift.load(<%= options[:account_id] %>);
26
+ </script>
@@ -11,11 +11,10 @@ class Rack::Tracker::GoogleGlobal < Rack::Tracker::Handler
11
11
 
12
12
  class Event < OpenStruct
13
13
  PREFIXED_PARAMS = %i[category label]
14
- LITERAL_PARAMS = %i[value]
15
- PARAMS = PREFIXED_PARAMS + LITERAL_PARAMS
14
+ SKIP_PARAMS = %i[action]
16
15
 
17
16
  def params
18
- Hash[to_h.slice(*PARAMS).map { |key, value| [param_key(key), value] }]
17
+ Hash[to_h.except(*SKIP_PARAMS).map { |key, value| [param_key(key), value] }]
19
18
  end
20
19
 
21
20
  private
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Tracker
3
- VERSION = '1.10.0'
3
+ VERSION = '1.11.0'
4
4
  end
5
5
  end
@@ -0,0 +1,10 @@
1
+ RSpec.describe Rack::Tracker::Drift 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
@@ -210,13 +210,15 @@ RSpec.describe Rack::Tracker::GoogleGlobal do
210
210
  'action' => 'login',
211
211
  'category' => 'engagement',
212
212
  'label' => 'Github',
213
- 'value' => 5 }
213
+ 'value' => 5,
214
+ 'transaction_id' => 1001,
215
+ }
214
216
  ]
215
217
  }}
216
218
  end
217
219
 
218
220
  it "will show event" do
219
- expect(subject).to match(%r{gtag\('event', 'login', {\"event_category\":\"engagement\",\"event_label\":\"Github\",\"value\":5}\);})
221
+ expect(subject).to match(%r{gtag\('event', 'login', {\"event_category\":\"engagement\",\"event_label\":\"Github\",\"value\":5,\"transaction_id\":1001}\);})
220
222
  end
221
223
  end
222
224
  end
@@ -0,0 +1,18 @@
1
+ require 'support/capybara_app_helper'
2
+
3
+ RSpec.describe 'Drift Integration' do
4
+ before do
5
+ setup_app(action: :drift) do |tracker|
6
+ tracker.handler :drift, account_id: 'DRIFT_ID'
7
+ end
8
+
9
+ visit '/'
10
+ end
11
+
12
+ subject { page }
13
+
14
+ it 'embeds the script with account_id' do
15
+ expect(page.find('script')).to have_content('js.driftt.com')
16
+ expect(page.find('script')).to have_content('DRIFT_ID')
17
+ end
18
+ end
@@ -124,4 +124,8 @@ class MetalController < ActionController::Metal
124
124
  def bing
125
125
  render "metal/index"
126
126
  end
127
+
128
+ def drift
129
+ render "metal/index"
130
+ end
127
131
  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.10.0
4
+ version: 1.11.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-06-27 00:00:00.000000000 Z
12
+ date: 2019-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -163,6 +163,8 @@ files:
163
163
  - lib/rack/tracker/controller.rb
164
164
  - lib/rack/tracker/criteo/criteo.rb
165
165
  - lib/rack/tracker/criteo/template/criteo.erb
166
+ - lib/rack/tracker/drift/drift.rb
167
+ - lib/rack/tracker/drift/template/drift.erb
166
168
  - lib/rack/tracker/extensions.rb
167
169
  - lib/rack/tracker/facebook/README.md
168
170
  - lib/rack/tracker/facebook/facebook.rb
@@ -203,6 +205,7 @@ files:
203
205
  - spec/fixtures/views/metal/turing.html.erb
204
206
  - spec/handler/bing_spec.rb
205
207
  - spec/handler/criteo_spec.rb
208
+ - spec/handler/drift_spec.rb
206
209
  - spec/handler/facebook_pixel_spec.rb
207
210
  - spec/handler/facebook_spec.rb
208
211
  - spec/handler/go_squared_spec.rb
@@ -217,6 +220,7 @@ files:
217
220
  - spec/handler/zanox_spec.rb
218
221
  - spec/integration/bing_integration_spec.rb
219
222
  - spec/integration/criteo_integration_spec.rb
223
+ - spec/integration/drift_integration_spec.rb
220
224
  - spec/integration/facebook_integration_spec.rb
221
225
  - spec/integration/facebook_pixel_integration_spec.rb
222
226
  - spec/integration/go_squared_integration_spec.rb
@@ -271,6 +275,7 @@ test_files:
271
275
  - spec/fixtures/views/metal/turing.html.erb
272
276
  - spec/handler/bing_spec.rb
273
277
  - spec/handler/criteo_spec.rb
278
+ - spec/handler/drift_spec.rb
274
279
  - spec/handler/facebook_pixel_spec.rb
275
280
  - spec/handler/facebook_spec.rb
276
281
  - spec/handler/go_squared_spec.rb
@@ -285,6 +290,7 @@ test_files:
285
290
  - spec/handler/zanox_spec.rb
286
291
  - spec/integration/bing_integration_spec.rb
287
292
  - spec/integration/criteo_integration_spec.rb
293
+ - spec/integration/drift_integration_spec.rb
288
294
  - spec/integration/facebook_integration_spec.rb
289
295
  - spec/integration/facebook_pixel_integration_spec.rb
290
296
  - spec/integration/go_squared_integration_spec.rb