rack-tracker 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rack/tracker/extensions.rb +9 -0
- data/lib/rack/tracker/google_analytics/google_analytics.rb +2 -2
- data/lib/rack/tracker/version.rb +1 -1
- data/spec/handler/google_analytics_spec.rb +3 -3
- data/spec/integration/google_analytics_integration_spec.rb +2 -1
- data/spec/support/metal_controller.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7d3f0a731a9473254d058fda92f9e088a255470
|
4
|
+
data.tar.gz: 897423fe72752a8dc9a7a49513b6554b70245f53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d298b6b90718d9fbe380dc47c8408b1c9a7e987b2d85b2eafb98b69fb922289e5797e581891304c23f53dd5b9a0c26600a9cea4982ec7147c36f6f8e230cf6c9
|
7
|
+
data.tar.gz: 8480c1144c530cb3ba33739e4c5ecba55e5bcfa036bc14ced3633097590e936464899a49c31011380d1a9be90a8bd126d2034b5fc795aa96160c6de68196069a
|
data/CHANGELOG.md
CHANGED
@@ -10,7 +10,7 @@ class Rack::Tracker::GoogleAnalytics < Rack::Tracker::Handler
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def event
|
13
|
-
{ hitType: self.type }.merge(attributes).compact
|
13
|
+
{ hitType: self.type }.merge(attributes.stringify_values).compact
|
14
14
|
end
|
15
15
|
|
16
16
|
def attributes
|
@@ -20,7 +20,7 @@ class Rack::Tracker::GoogleAnalytics < Rack::Tracker::Handler
|
|
20
20
|
|
21
21
|
class Ecommerce < OpenStruct
|
22
22
|
def write
|
23
|
-
["ecommerce:#{self.type}", self.to_h.except(:type).compact].to_json.gsub(/\[|\]/, '')
|
23
|
+
["ecommerce:#{self.type}", self.to_h.except(:type).compact.stringify_values].to_json.gsub(/\[|\]/, '')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/lib/rack/tracker/version.rb
CHANGED
@@ -48,13 +48,13 @@ RSpec.describe Rack::Tracker::GoogleAnalytics do
|
|
48
48
|
describe "with a event value" do
|
49
49
|
def env
|
50
50
|
{'tracker' => { 'google_analytics' => [
|
51
|
-
Rack::Tracker::GoogleAnalytics::Send.new(category: "Users", action: "Login", label: "Standard", value: 5)
|
51
|
+
Rack::Tracker::GoogleAnalytics::Send.new(category: "Users", action: "Login", label: "Standard", value: "5")
|
52
52
|
]}}
|
53
53
|
end
|
54
54
|
|
55
55
|
subject { described_class.new(env, tracker: 'somebody').render }
|
56
56
|
it "will show events with values" do
|
57
|
-
expect(subject).to match(%r{ga\(\"send\",{\"hitType\":\"event\",\"eventCategory\":\"Users\",\"eventAction\":\"Login\",\"eventLabel\":\"Standard\",\"eventValue\"
|
57
|
+
expect(subject).to match(%r{ga\(\"send\",{\"hitType\":\"event\",\"eventCategory\":\"Users\",\"eventAction\":\"Login\",\"eventLabel\":\"Standard\",\"eventValue\":\"5\"}\)},)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -75,7 +75,7 @@ RSpec.describe Rack::Tracker::GoogleAnalytics do
|
|
75
75
|
expect(subject).to match(%r{ga\(\"ecommerce:addItem\",#{{id: '1234', name: 'Fluffy Pink Bunnies', sku: 'DD23444', category: 'Party Toys', price: '11.99', quantity: '1'}.to_json}})
|
76
76
|
end
|
77
77
|
it "will add transaction" do
|
78
|
-
expect(subject).to match(%r{ga\(\"ecommerce:addTransaction\",#{{id: '1234', affiliation: 'Acme Clothing', revenue: 11.99, shipping: '5', tax: '1.29', currency: 'EUR'}.to_json}})
|
78
|
+
expect(subject).to match(%r{ga\(\"ecommerce:addTransaction\",#{{id: '1234', affiliation: 'Acme Clothing', revenue: '11.99', shipping: '5', tax: '1.29', currency: 'EUR'}.to_json}})
|
79
79
|
end
|
80
80
|
it "will submit cart" do
|
81
81
|
expect(subject).to match(%r{ga\('ecommerce:send'\);})
|
@@ -11,7 +11,8 @@ RSpec.describe "Facebook Integration" do
|
|
11
11
|
subject { page }
|
12
12
|
|
13
13
|
it "embeds the script tag with tracking event from the controller action" do
|
14
|
-
expect(page).to have_content('ga("ecommerce:addItem",{"id":"1234","
|
14
|
+
expect(page).to have_content('ga("ecommerce:addItem",{"id":"1234","name":"Fluffy Pink Bunnies","sku":"DD23444","category":"Party Toys","price":"11.99","quantity":"1"})')
|
15
|
+
expect(page).to have_content('ga("ecommerce:addTransaction",{"id":"1234","affiliation":"Acme Clothing","revenue":"11.99","shipping":"5","tax":"1.29"})')
|
15
16
|
expect(page).to have_content('ga("send",{"hitType":"event","eventCategory":"button","eventAction":"click","eventLabel":"nav-buttons","eventValue":"X"})')
|
16
17
|
end
|
17
18
|
end
|
@@ -24,7 +24,8 @@ class MetalController < ActionController::Metal
|
|
24
24
|
|
25
25
|
def google_analytics
|
26
26
|
tracker do |t|
|
27
|
-
t.google_analytics :ecommerce, { type: '
|
27
|
+
t.google_analytics :ecommerce, { type: 'addTransaction', id: 1234, affiliation: 'Acme Clothing', revenue: 11.99, shipping: 5, tax: 1.29 }
|
28
|
+
t.google_analytics :ecommerce, { type: 'addItem', id: 1234, name: 'Fluffy Pink Bunnies', sku: 'DD23444', category: 'Party Toys', price: 11.99, quantity: 1 }
|
28
29
|
t.google_analytics :send, { type: 'event', category: 'button', action: 'click', label: 'nav-buttons', value: 'X' }
|
29
30
|
end
|
30
31
|
render "metal/index"
|
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: 0.2.
|
4
|
+
version: 0.2.5
|
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: 2014-10-
|
12
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|