google-analytics-rails 1.1.0 → 1.1.1

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
  SHA1:
3
- metadata.gz: d1026e04facb047892c44b293f01e87c63af110c
4
- data.tar.gz: 052fff54d9f1dc5dcb2b9972764bfaac52492f18
3
+ metadata.gz: d9237482619d3cc567f0190f9279b949e45671bc
4
+ data.tar.gz: c32c4208d568145c4e6ca07f22f5fa0960e97824
5
5
  SHA512:
6
- metadata.gz: 011c446e38f25ca1fdb7b1eb1079fd584fdca5d79b1ff6141d6943c24d8caf802772241f38af6a3a888db0e25180b8b162146104dbf64d8a0cbfb6f172b4aec0
7
- data.tar.gz: c4b798ef8c48bff11a32a9c0f33f4830312fe84560fe0c72ac138abff89c212d83f4306cd03237f6c9c6f5e5708a0c624dfd728af93bab3e040e32f284b8708e
6
+ metadata.gz: '0960adf90b52e1bf2a4dc5e6f6c879d1ba98870acfcc4d781f4c1b7d78be189ababa7ab492be31199d7853708591790103c304ce61f38695f8e6386f2c62b8e8'
7
+ data.tar.gz: f77d3211e125e777488d5897a006651cc89151e2b7ac0467ddef1ec811d74c350991cc106985964a90b4af120f7d799b68427cc54c44273cc95a0284075e2381
@@ -3,12 +3,12 @@ bundler_args: --without development
3
3
  before_install:
4
4
  - gem update bundler
5
5
  rvm:
6
- - 1.9.2
7
6
  - 1.9.3
8
7
  - 2.0.0
9
8
  - 2.1
10
9
  - 2.2.1
11
10
  - 2.3.0
11
+ - 2.4.0
12
12
  - rbx-2
13
13
  - ruby-head
14
14
  matrix:
@@ -23,4 +23,4 @@ matrix:
23
23
  - rvm: jruby-head
24
24
  - rvm: rbx-2
25
25
  - rvm: ruby-head
26
- fast_finish: true
26
+ fast_finish: true
@@ -1,3 +1,8 @@
1
+ 1.1.1
2
+ =====
3
+
4
+ * BUGFIX: https://github.com/bgarret/google-analytics-rails/issues/36
5
+
1
6
  1.1.0
2
7
  =====
3
8
 
@@ -9,7 +9,7 @@ Installation
9
9
 
10
10
  Add the following to your `Gemfile`:
11
11
 
12
- gem 'google-analytics-rails', '1.1.0'
12
+ gem 'google-analytics-rails', '1.1.1'
13
13
 
14
14
  Then run:
15
15
 
@@ -11,23 +11,18 @@ module GoogleAnalytics
11
11
 
12
12
  def to_s
13
13
  if @event.class.name == 'GoogleAnalytics::Events::SetupAnalytics'
14
- "ga('#{@event.action}',#{array_to_json([@event.name, *@event.params])});"
14
+ %{ga("#{@event.action}",#{array_to_json([@event.name, *@event.params])});}
15
15
  elsif @event.single_event?
16
- "ga('#{@tracker_id ? [@tracker_id, @event.action].join('.') : @event.action}');"
16
+ %{ga("#{@tracker_id ? [@tracker_id, @event.action].join('.') : @event.action}");}
17
17
  else
18
- "ga('#{@tracker_id ? [@tracker_id, @event.action].join('.') : @event.action}',#{array_to_json([@event.name, *@event.params])});"
18
+ %{ga("#{@tracker_id ? [@tracker_id, @event.action].join('.') : @event.action}",#{array_to_json([@event.name, *@event.params])});}
19
19
  end
20
20
  end
21
21
 
22
22
  private
23
23
 
24
24
  def array_to_json(array)
25
- array.map {|string| string_to_json(string) } .join(',')
26
- end
27
-
28
- def string_to_json(string)
29
- # replace double quotes with single ones
30
- string.to_json.gsub(/^"/, "'").gsub(/"$/, "'")
25
+ array.map {|val| val.to_json } .join(',')
31
26
  end
32
27
  end
33
28
  end
@@ -29,6 +29,9 @@ module GoogleAnalytics::Rails
29
29
  # '11.99', # total - required
30
30
  # '1.29', # tax
31
31
  # '5' # shipping
32
+ # 'San Jose', # city
33
+ # 'California', # state or province
34
+ # 'USA' # country
32
35
  # )
33
36
  #
34
37
  # # add an item to the transaction
@@ -2,5 +2,5 @@
2
2
 
3
3
  module GoogleAnalytics
4
4
  # Gem version
5
- VERSION = "1.1.0"
5
+ VERSION = "1.1.1"
6
6
  end
@@ -11,10 +11,10 @@ class AsyncTrackingQueueTest < Test::Unit::TestCase
11
11
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
12
12
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
13
13
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
14
- ga('send','event',1);
15
- ga('send','event',2);
16
- ga('t2.send','event',1);
17
- ga('t2.send','event',2);
14
+ ga("send","event",1);
15
+ ga("send","event",2);
16
+ ga("t2.send","event",1);
17
+ ga("t2.send","event",2);
18
18
  </script>
19
19
  JAVASCRIPT
20
20
 
@@ -37,10 +37,10 @@ ga('t2.send','event',2);
37
37
  # VALID_DOUBLECLICK_SNIPPET = <<-JAVASCRIPT
38
38
  # <script type="text/javascript">
39
39
  # var _gaq = _gaq || [];
40
- # _gaq.push(['event1',1]);
41
- # _gaq.push(['event2',2]);
42
- # _gaq.push(['t2.event1',1]);
43
- # _gaq.push(['t2.event2',2]);
40
+ # _gaq.push(["event1",1]);
41
+ # _gaq.push(["event2",2]);
42
+ # _gaq.push(["t2.event1",1]);
43
+ # _gaq.push(["t2.event2",2]);
44
44
  # (function() {
45
45
  # var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
46
46
  # ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
@@ -70,10 +70,10 @@ ga('t2.send','event',2);
70
70
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
71
71
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
72
72
  })(window,document,'script','http://127.0.0.1/custom.js','ga');
73
- ga('send','event',1);
74
- ga('send','event',2);
75
- ga('t2.send','event',1);
76
- ga('t2.send','event',2);
73
+ ga("send","event",1);
74
+ ga("send","event",2);
75
+ ga("t2.send","event",1);
76
+ ga("t2.send","event",2);
77
77
  </script>
78
78
  JAVASCRIPT
79
79
 
@@ -8,7 +8,16 @@ class EventCollectionRendererTest < Test::Unit::TestCase
8
8
  event_collection << GA::Event.new('send', 'evt', '3')
9
9
 
10
10
  ecr = GA::EventCollectionRenderer.new(event_collection, nil)
11
- assert_equal("ga('send','evt','1');\nga('send','evt','2');\nga('send','evt','3');", ecr.to_s)
11
+ assert_equal(%{ga("send","evt","1");\nga("send","evt","2");\nga("send","evt","3");}, ecr.to_s)
12
+ end
13
+
14
+ def test_event_collection_renderer_escapes_quotes
15
+ event_collection = GA::EventCollection.new
16
+ event_collection << GA::Event.new('send', 'evt', "foo'sbar")
17
+ event_collection << GA::Event.new('send', 'evt', "foo\"sbar")
18
+
19
+ ecr = GA::EventCollectionRenderer.new(event_collection, nil)
20
+ assert_equal(%{ga("send","evt","foo'sbar");\nga("send","evt","foo\\"sbar");}, ecr.to_s)
12
21
  end
13
22
 
14
23
  def test_event_collection_renderer_yield_proper_javascript_snippit_for_custom_tracker
@@ -18,6 +27,6 @@ class EventCollectionRendererTest < Test::Unit::TestCase
18
27
  event_collection << GA::Event.new('send', 'evt', 3)
19
28
 
20
29
  ecr = GA::EventCollectionRenderer.new(event_collection, 't2')
21
- assert_equal("ga('t2.send','evt',1);\nga('t2.send','evt',2);\nga('t2.send','evt',3);", ecr.to_s)
30
+ assert_equal(%{ga("t2.send","evt",1);\nga("t2.send","evt",2);\nga("t2.send","evt",3);}, ecr.to_s)
22
31
  end
23
32
  end
@@ -3,12 +3,12 @@ require 'test_helper'
3
3
  class EventRendererTest < Test::Unit::TestCase
4
4
  def test_event_renderer_yield_proper_javascript_snippit_for_default_tracker
5
5
  er = GA::EventRenderer.new(GA::Event.new('send', 'something', 1, 2, 3), nil)
6
- assert_equal("ga('send','something',1,2,3);", er.to_s)
6
+ assert_equal(%{ga("send","something",1,2,3);}, er.to_s)
7
7
  end
8
8
 
9
9
  def test_event_renderer_yield_proper_javascript_snippit_for_custom_tracker
10
10
  er = GA::EventRenderer.new(GA::Event.new('send', 'something', 1, 2, 3), 't2')
11
- assert_equal("ga('t2.send','something',1,2,3);", er.to_s)
11
+ assert_equal(%{ga("t2.send","something",1,2,3);}, er.to_s)
12
12
  end
13
13
 
14
14
  def test_event_renderer_yield_proper_javascript_snippit_for_custom_tracker_creation
@@ -19,10 +19,10 @@ class EventRendererTest < Test::Unit::TestCase
19
19
 
20
20
  def test_single_event_renderer_yield_proper_javascript_snippit_for_transaction_send
21
21
  er = GA::EventRenderer.new(GA::Events::Ecommerce::TrackTransaction.new, nil)
22
- assert_equal("ga('ecommerce:send');", er.to_s)
22
+ assert_equal(%{ga("ecommerce:send");}, er.to_s)
23
23
  end
24
24
  def test_single_event_renderer_yield_proper_javascript_snippit_for_transaction_send_with_custom_tracker
25
25
  er = GA::EventRenderer.new(GA::Events::Ecommerce::TrackTransaction.new, 't2')
26
- assert_equal("ga('t2.ecommerce:send');", er.to_s)
26
+ assert_equal(%{ga("t2.ecommerce:send");}, er.to_s)
27
27
  end
28
28
  end
@@ -17,8 +17,8 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
17
17
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
18
18
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
19
19
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
20
- ga('create','TEST','auto');
21
- ga('send','pageview');
20
+ ga("create","TEST","auto");
21
+ ga("send","pageview");
22
22
  </script>
23
23
  JAVASCRIPT
24
24
 
@@ -29,24 +29,24 @@ ga('send','pageview');
29
29
  def test_analytics_init_with_special_name
30
30
  str = analytics_init(:name => 't2').to_s
31
31
  assert(str.include?(VALID_JS_INCLUDE))
32
- assert_match(/.+ga\('create','TEST',\{.+\}\);.+/m, str)
32
+ assert_match(/.+ga\("create","TEST",\{.+\}\);.+/m, str)
33
33
  assert_match(/.+"cookieDomain":"auto".+/m, str)
34
34
  assert_match(/.+"name":"t2".+/m, str)
35
- assert_match(/.+ga\('t2.send','pageview'\);.+/m, str)
35
+ assert_match(/.+ga\("t2.send","pageview"\);.+/m, str)
36
36
  end
37
37
 
38
38
  def test_analytics_init_with_virtual_pageview
39
39
  str = analytics_init(:page => '/some/virtual/url').to_s
40
40
  assert(str.include?(VALID_JS_INCLUDE))
41
- assert_match(/.+ga\('create','TEST','auto'\);.+/m, str)
42
- assert_match(/.+ga\('send','pageview','\/some\/virtual\/url'\);.+/m, str)
41
+ assert_match(/.+ga\("create","TEST","auto"\);.+/m, str)
42
+ assert_match(/.+ga\("send","pageview","\/some\/virtual\/url"\);.+/m, str)
43
43
  end
44
44
 
45
45
  def test_analytics_init_with_virtual_pageview_and_custom_title
46
46
  str = analytics_init(:page => '/some/virtual/url', :title => 'Hello World').to_s
47
47
  assert(str.include?(VALID_JS_INCLUDE))
48
- assert_match(/.+ga\('create','TEST','auto'\);.+/m, str)
49
- assert_match(/.+ga\('send','pageview'.+/m, str)
48
+ assert_match(/.+ga\("create","TEST","auto"\);.+/m, str)
49
+ assert_match(/.+ga\("send","pageview".+/m, str)
50
50
  assert_match(/.+"page":"\/some\/virtual\/url".+/m, str)
51
51
  assert_match(/.+"title":"Hello World".+/m, str)
52
52
  end
@@ -54,77 +54,77 @@ ga('send','pageview');
54
54
  def test_analytics_init_with_custom_tracker
55
55
  str = analytics_init(:tracker => 'UA-CUSTOM-XX').to_s
56
56
  assert(str.include?(VALID_JS_INCLUDE))
57
- assert_match(/.+ga\('create','UA-CUSTOM-XX','auto'\);.+/m, str)
58
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
57
+ assert_match(/.+ga\("create","UA-CUSTOM-XX","auto"\);.+/m, str)
58
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
59
59
  end
60
60
 
61
61
  def test_analytics_init_with_custom_domain
62
62
  str = analytics_init(:domain => 'example.com').to_s
63
63
  assert(str.include?(VALID_JS_INCLUDE))
64
- assert_match(/.+ga\('create','TEST',\{"cookieDomain":"example.com"\}\);.+/m, str)
65
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
64
+ assert_match(/.+ga\("create","TEST",\{"cookieDomain":"example.com"\}\);.+/m, str)
65
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
66
66
  end
67
67
 
68
68
  def test_local_analytics_init
69
69
  str = analytics_init(:local => true).to_s
70
70
  assert(str.include?(VALID_JS_INCLUDE))
71
- assert_match(/.+ga\('create','TEST',\{.+\}\);.+/m, str)
71
+ assert_match(/.+ga\("create","TEST",\{.+\}\);.+/m, str)
72
72
  assert_match(/.+"cookieDomain":"none".+/m, str)
73
73
  assert_match(/.+"allowLinker":true.+/m, str)
74
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
74
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
75
75
  end
76
76
 
77
77
  def test_analytics_init_with_anonymized_ip
78
78
  str = analytics_init(:anonymize => true).to_s
79
79
  assert(str.include?(VALID_JS_INCLUDE))
80
- assert_match(/.+ga\('create','TEST','auto'\);.+/m, str)
81
- assert_match(/.+ga\('set','anonymizeIp',true\);.+/m, str)
82
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
80
+ assert_match(/.+ga\("create","TEST","auto"\);.+/m, str)
81
+ assert_match(/.+ga\("set","anonymizeIp",true\);.+/m, str)
82
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
83
83
  end
84
84
 
85
85
  def test_analytics_init_with_link_attribution
86
86
  str = analytics_init(:enhanced_link_attribution => true).to_s
87
87
  assert(str.include?(VALID_JS_INCLUDE))
88
- assert_match(/.+ga\('create','TEST','auto'\);.+/m, str)
89
- assert_match(/.+ga\('require','linkid'\);.+/m, str)
90
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
88
+ assert_match(/.+ga\("create","TEST","auto"\);.+/m, str)
89
+ assert_match(/.+ga\("require","linkid"\);.+/m, str)
90
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
91
91
  end
92
92
 
93
93
  def test_analytics_init_with_events
94
94
  str = analytics_init(:add_events => GA::Events::SetAllowLinker.new(true)).to_s
95
95
  assert(str.include?(VALID_JS_INCLUDE))
96
- assert_match(/.+ga\('create','TEST',\{.+\}\);.+/m, str)
96
+ assert_match(/.+ga\("create","TEST",\{.+\}\);.+/m, str)
97
97
  assert_match(/.+"cookieDomain":"auto".+/m, str)
98
98
  assert_match(/.+"allowLinker":true.+/m, str)
99
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
99
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
100
100
  end
101
101
 
102
102
  def test_analytics_init_with_samplerate_events
103
103
  str = analytics_init(:add_events => GA::Events::SetSiteSpeedSampleRate.new(5)).to_s
104
104
  assert(str.include?(VALID_JS_INCLUDE))
105
- assert_match(/.+ga\('create','TEST',\{.+\}\);.+/m, str)
105
+ assert_match(/.+ga\("create","TEST",\{.+\}\);.+/m, str)
106
106
  assert_match(/.+"cookieDomain":"auto".+/m, str)
107
107
  assert_match(/.+"siteSpeedSampleRate":5.+/m, str)
108
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
108
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
109
109
  end
110
110
 
111
111
  def test_analytics_init_with_custom_vars
112
112
  str = analytics_init(:custom_vars => GA::Events::SetCustomVar.new(1, 'test', 'hoge',1)).to_s
113
113
  assert(str.include?(VALID_JS_INCLUDE))
114
- assert_match(/.+ga\('create','TEST','auto'\);.+/m, str)
115
- assert_match(/.+ga\('set','dimension1','hoge'\);.+/m, str)
116
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
114
+ assert_match(/.+ga\("create","TEST","auto"\);.+/m, str)
115
+ assert_match(/.+ga\("set","dimension1","hoge"\);.+/m, str)
116
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
117
117
  end
118
118
 
119
119
  def test_analytics_init_with_custom_dimension
120
120
  str = analytics_init(:custom_vars => GA::Events::SetCustomDimension.new(1, 'hoge')).to_s
121
121
  assert(str.include?(VALID_JS_INCLUDE))
122
- assert_match(/.+ga\('create','TEST','auto'\);.+/m, str)
123
- assert_match(/.+ga\('set','dimension1','hoge'\);.+/m, str)
124
- assert_match(/.+ga\('send','pageview'\);.+/m, str)
122
+ assert_match(/.+ga\("create","TEST","auto"\);.+/m, str)
123
+ assert_match(/.+ga\("set","dimension1","hoge"\);.+/m, str)
124
+ assert_match(/.+ga\("send","pageview"\);.+/m, str)
125
125
  end
126
126
 
127
- VALID_TRACK_EVENT = "ga('send','event','Videos','Play','Gone With the Wind',null);"
127
+ VALID_TRACK_EVENT = %{ga("send","event","Videos","Play","Gone With the Wind",null);}
128
128
 
129
129
  def test_analytics_track_event
130
130
  event = analytics_track_event("Videos", "Play", "Gone With the Wind")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-analytics-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoit Garret
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-27 00:00:00.000000000 Z
12
+ date: 2017-07-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rails helpers to manage google analytics tracking
15
15
  email:
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 2.4.8
67
+ rubygems_version: 2.5.2
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: Rails helpers to manage google analytics tracking