split-analytics 1.0.0 → 1.0.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: ae9c0830e8d0f8a173d397c71c090971e1584cf2
4
- data.tar.gz: 3fff2e89f8c222d0973d2c24ec6070c452ef9277
3
+ metadata.gz: 37226a44a019f3dfdb48e667631cc012389cc588
4
+ data.tar.gz: 2dd4cb0f15a3cfa437d8cc003947c91ac38f14c4
5
5
  SHA512:
6
- metadata.gz: aa31c9bd3443748b92677377ca8f29e6868f1b78c51e7a4677ac2375e06412c83a76f94f496aba0a94d06f820d3fd6dc166240774923b2f33b862a425f9a3d60
7
- data.tar.gz: 2f4bd0c27bfdd1cc8141ba93b77d38ee254e8c8b4ff0c065da6848149115fb24ed89607807cf7b4029df9b71b2193d01a2cefaaeed6c2374939120170919773a
6
+ metadata.gz: 428b4424100c1285bf16814e04911c0514d1336cbacd731c5fb24c3bb0e29adea3938e013d622f8286d2e4460142f57e8f1ee21680e1a4d1e10c2cfd80266e39
7
+ data.tar.gz: f044584b79505ca14a492881bdc6797e0f0b0158407d474f21a175cd3333b53955bb176558006abde7e646d609701587b8ecf90dd6de6966180b8b71c76d4975
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.5
3
+ - 2.2.4
4
4
 
5
5
  services:
6
6
  - redis-server
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/Readme.md CHANGED
@@ -1,6 +1,10 @@
1
- # Split::Analytics
1
+ # [Split Analytics](http://libraries.io/rubygems/split-analytics)
2
2
 
3
- An extension to [Split](http://github.com/andrew/split) to push test data to google analytics.
3
+ An extension to [Split](http://github.com/splitrb/split) to push test data to google analytics.
4
+
5
+ [![Build Status](https://secure.travis-ci.org/splitrb/split-analytics.svg?branch=master)](http://travis-ci.org/andrew/split-analytics)
6
+ [![Gem Version](https://badge.fury.io/rb/split-analytics.svg)](http://badge.fury.io/rb/split-analytics)
7
+ [![Dependency Status](https://gemnasium.com/splitrb/split-analytics.svg)](https://gemnasium.com/andrew/split-analytics)
4
8
 
5
9
  ## Requirements
6
10
 
@@ -52,7 +56,7 @@ haml example:
52
56
 
53
57
  See [Google Analytics Tracking Methods](https://developers.google.com/analytics/devguides/collection/gajs/methods/) for available options.
54
58
 
55
- ```
59
+ ```ruby
56
60
  tracker_methods = {
57
61
  :setDomainName => "example.com", # String argument
58
62
  :setAllowLinker => true, # Boolean argument
@@ -90,8 +94,8 @@ haml example:
90
94
 
91
95
  ## Development
92
96
 
93
- Source hosted at [GitHub](http://github.com/andrew/split-analytics).
94
- Report Issues/Feature requests on [GitHub Issues](http://github.com/andrew/split-analytics/issues).
97
+ Source hosted at [GitHub](http://github.com/splitrb/split-analytics).
98
+ Report Issues/Feature requests on [GitHub Issues](http://github.com/splitrb/split-analytics/issues).
95
99
 
96
100
  Tests can be ran with `rake spec`
97
101
 
@@ -15,10 +15,10 @@ module Split
15
15
  code = <<-EOF
16
16
  <script type="text/javascript">
17
17
  var _gaq = _gaq || [];
18
- _gaq.push(['_setAccount', '#{account}']);
18
+ _gaq.push(["_setAccount", "#{account}"]);
19
19
  #{insert_tracker_methods(tracker_methods)}
20
20
  #{custom_variables}
21
- _gaq.push(['_trackPageview']);
21
+ _gaq.push(["_trackPageview"]);
22
22
  (function() {
23
23
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
24
24
  ga.src = ('https:' == document.location.protocol ? '#{ssl_tracker_url}' : '#{tracker_url}');
@@ -31,10 +31,11 @@ module Split
31
31
  end
32
32
 
33
33
  def custom_variables
34
- return nil if ab_user.nil?
34
+ return nil if session.nil?
35
35
  arr = []
36
- ab_user.each_with_index do |h, i|
37
- arr << "_gaq.push(['_setCustomVar', #{i + 1}, '#{h[0]}', '#{h[1]}', 1]);"
36
+
37
+ session.each_with_index do |h, i|
38
+ arr << "_gaq.push([\"_setCustomVar\", #{i + 1}, \"#{h[0]}\", \"#{h[1]}\", 1]);"
38
39
  end
39
40
  arr.reverse[0..4].reverse.join("\n")
40
41
  end
@@ -47,22 +48,22 @@ module Split
47
48
  tracker_methods.each do |k, v|
48
49
  if v.class == String && v.empty?
49
50
  # No argument tracker method
50
- arr << "_gaq.push(['" + "_" + "#{k}']);"
51
+ arr << "_gaq.push([\"" + "_" + "#{k}\"]);"
51
52
  else
52
53
  case v
53
54
  when String
54
55
  # String argument tracker method
55
- arr << "_gaq.push(['" + '_' + "#{k}', '#{v}']);"
56
+ arr << "_gaq.push([\"" + '_' + "#{k}\", \"#{v}\"]);"
56
57
  when TrueClass
57
58
  # Boolean argument tracker method
58
- arr << "_gaq.push(['" + '_' + "#{k}', #{v}]);"
59
+ arr << "_gaq.push([\"" + '_' + "#{k}\", #{v}]);"
59
60
  when FalseClass
60
61
  # Boolean argument tracker method
61
- arr << "_gaq.push(['" + '_' + "#{k}', #{v}]);"
62
+ arr << "_gaq.push([\"" + '_' + "#{k}\", #{v}]);"
62
63
  when Array
63
64
  # Array argument tracker method
64
- values = v.map { |value| "'#{value}'" }.join(', ')
65
- arr << "_gaq.push(['" + '_' + "#{k}', #{values}]);"
65
+ values = v.map { |value| "\"#{value}\"" }.join(', ')
66
+ arr << "_gaq.push([\"" + '_' + "#{k}\", #{values}]);"
66
67
  end
67
68
  end
68
69
  end
@@ -1,5 +1,5 @@
1
1
  module Split
2
2
  module Analytics
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ describe Split::Analytics do
4
4
  include Split::Helper
5
5
  it 'should generate valid analytics javascript' do
6
6
  tracking_code = tracking_code(account: 'UA-12345-6')
7
- expect(tracking_code).to eql(" <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-12345-6']);\n \n \n _gaq.push(['_trackPageview']);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n")
7
+ expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n \n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
8
8
  end
9
9
 
10
10
  it 'should generate valid analytics javascript with arbitrary tracker object methods' do
@@ -14,18 +14,20 @@ describe Split::Analytics do
14
14
  clearOrganic: '' # No argument
15
15
  }
16
16
  tracking_code = tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
17
- expect(tracking_code).to eql(" <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-12345-6']);\n _gaq.push(['_setDomainName', 'example.com']);\n_gaq.push(['_setAllowLinker', true]);\n_gaq.push(['_clearOrganic']);\n \n _gaq.push(['_trackPageview']);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n")
17
+ expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n _gaq.push(["_setDomainName", "example.com"]);\n_gaq.push(["_setAllowLinker", true]);\n_gaq.push(["_clearOrganic"]);\n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
18
18
  end
19
19
 
20
20
  it 'should add custom variables for every test the user is involved in' do
21
21
  first_alt = ab_test('link_colour', 'red', 'blue')
22
22
 
23
+ expect(session).to eql({'link_colour' => first_alt})
24
+
23
25
  tracking_code = tracking_code(account: 'UA-12345-6')
24
- expect(tracking_code).to eql(" <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-12345-6']);\n \n _gaq.push(['_setCustomVar', 1, 'link_colour', '#{first_alt}', 1]);\n _gaq.push(['_trackPageview']);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n")
26
+ expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n \n _gaq.push(["_setCustomVar", 1, "link_colour", "#{first_alt}", 1]);\n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
25
27
  end
26
28
 
27
29
  it 'uses doubleclick as tracker url' do
28
- tracking_code = tracking_code(account: 'UA-12345-6', tracker_url: 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js')
29
- expect(tracking_code).to eql(" <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-12345-6']);\n \n \n _gaq.push(['_trackPageview']);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://stats.g.doubleclick.net/dc.js' : 'http://stats.g.doubleclick.net/dc.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n")
30
+ tracking_code = tracking_code(account: "UA-12345-6", tracker_url: 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js')
31
+ expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n \n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://stats.g.doubleclick.net/dc.js' : 'http://stats.g.doubleclick.net/dc.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
30
32
  end
31
33
  end
@@ -5,6 +5,10 @@ require 'split/helper'
5
5
  require 'split/analytics'
6
6
  require 'ostruct'
7
7
 
8
+ def session
9
+ @ab_user ||= {}
10
+ end
11
+
8
12
  RSpec.configure do |config|
9
13
  config.order = 'random'
10
14
  config.before(:each) do
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
6
6
  gem.authors = ['Andrew Nesbitt']
7
7
  gem.email = ['andrewnez@gmail.com']
8
8
  gem.summary = 'Split extension to push test data to google analytics'
9
- gem.homepage = 'https://github.com/andrew/split-analytics'
9
+ gem.homepage = 'https://github.com/splitrb/split-analytics'
10
10
  gem.license = 'MIT'
11
11
 
12
12
  gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-03 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: split
@@ -70,7 +70,7 @@ files:
70
70
  - spec/analytics_spec.rb
71
71
  - spec/spec_helper.rb
72
72
  - split-analytics.gemspec
73
- homepage: https://github.com/andrew/split-analytics
73
+ homepage: https://github.com/splitrb/split-analytics
74
74
  licenses:
75
75
  - MIT
76
76
  metadata: {}
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 2.4.5
93
+ rubygems_version: 2.5.1
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Split extension to push test data to google analytics