split-analytics 0.4.0 → 1.1.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
- SHA1:
3
- metadata.gz: 1c137bdda5d58e5be423f480171b8db9a33ca43b
4
- data.tar.gz: c2a14e14b278cccfd05b8173439eb30c1d45be2c
2
+ SHA256:
3
+ metadata.gz: 78147218626221c2bfaeda3b5172d09e8338e790fceb638a7308151405dc9648
4
+ data.tar.gz: f29e658301c364bc48bf6bd1ff461b1c7cce5c615020693304957f7cce6653c9
5
5
  SHA512:
6
- metadata.gz: 75686f802c2e7089d5fa8b0653c7a063c90cf3cfb9058d58fcff56a981a3d0c26eb58bd0a84d7fd15601b7c4711ccc33991b8fbd1a18a63d80f933eaddece03c
7
- data.tar.gz: d0a2ed6631741fc21ba09282f92524060e27cf98a0581dbe2b005d61e18a6ee7c82971c8ff7c3e117f09e6c8e53fc096a73acf4a04de6b3fc7e532d222d6ba29
6
+ metadata.gz: 2a579209e8040b7e2f6eb003fe93efa4b29d936dd01568febfd2c435b51ccf4713b4284baba0c317838da522b3d80fbf185635d59e985a6ac4dbab17d81bf766
7
+ data.tar.gz: 3a3f1f0656cb0bd7e97601dc9844e4549659ddfd2f8b5670cecdf5a5193cd61b7ebf8e1f318bb81258713deef5cf1f54d3b2b4b51932dc15fe5dfa662df153ee
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
@@ -0,0 +1,43 @@
1
+ name: split-analytics
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ matrix:
9
+ os: [ubuntu-latest]
10
+ ruby:
11
+ - 2.5
12
+ - 2.6
13
+ - 2.7
14
+ - '3.0'
15
+ # - 3.1
16
+
17
+ services:
18
+ redis:
19
+ image: redis
20
+ ports: ['6379:6379']
21
+ options: >-
22
+ --health-cmd "redis-cli ping"
23
+ --health-interval 10s
24
+ --health-timeout 5s
25
+ --health-retries 5
26
+
27
+ runs-on: ${{ matrix.os }}
28
+
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+
32
+ - uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: ${{ matrix.ruby }}
35
+
36
+ - name: Install dependencies
37
+ run: bundle install
38
+
39
+ - name: Display Ruby version
40
+ run: ruby -v
41
+
42
+ - name: Test
43
+ run: bundle exec rspec --backtrace
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at andrewnez@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,20 @@
1
+ # Contributing
2
+
3
+ Source hosted at [GitHub](http://github.com/splitrb/split-analytics).
4
+ Report Issues/Feature requests on [GitHub Issues](http://github.com/splitrb/split-analytics/issues).
5
+
6
+ Please follow the [Code of Conduct](CODE_OF_CONDUCT.md).
7
+
8
+ ## Note on Patches/Pull Requests
9
+
10
+ * Fork the project.
11
+ * Make your feature addition or bug fix.
12
+ * Add tests for it. This is important so I don't break it in a
13
+ future version unintentionally.
14
+ * Commit, do not mess with rakefile, version, or history.
15
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
16
+ * Send me a pull request. Bonus points for topic branches.
17
+
18
+ ## Testing
19
+
20
+ Tests can be ran with `rake spec`.`
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Andrew Nesbitt
1
+ Copyright (c) 2015-2018 Andrew Nesbitt
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -4,4 +4,4 @@ require 'rspec/core/rake_task'
4
4
 
5
5
  RSpec::Core::RakeTask.new('spec')
6
6
 
7
- task :default => :spec
7
+ task default: :spec
data/Readme.md ADDED
@@ -0,0 +1,120 @@
1
+ # [Split Analytics](http://libraries.io/rubygems/split-analytics)
2
+
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)
8
+
9
+ ## Install
10
+
11
+ ### Requirements
12
+
13
+ The split gem and its dependencies.
14
+
15
+ ### Setup
16
+
17
+ If you are using bundler add split to your Gemfile:
18
+
19
+ ```ruby
20
+ gem 'split-analytics', require: 'split/analytics'
21
+ ```
22
+
23
+ Then run:
24
+
25
+ ```bash
26
+ bundle install
27
+ ```
28
+
29
+ Otherwise install the gem:
30
+
31
+ ```bash
32
+ gem install split-analytics
33
+ ```
34
+
35
+ and require it in your project:
36
+
37
+ ```ruby
38
+ require 'split/analytics'
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ Use in your application layout template
44
+
45
+ erb example:
46
+
47
+ ```erb
48
+ <%= tracking_code(account: 'UA-12345-6') %>
49
+ ```
50
+
51
+ haml example:
52
+
53
+ ```haml
54
+ = tracking_code(account: 'UA-12345-6')
55
+ ```
56
+
57
+ ### With Tracking Methods
58
+
59
+ See [Google Analytics Tracking Methods](https://developers.google.com/analytics/devguides/collection/gajs/methods/) for available options.
60
+
61
+ ```ruby
62
+ tracker_methods = {
63
+ setDomainName: "example.com", # String argument
64
+ setAllowLinker: true, # Boolean argument
65
+ require: ['inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js'] # Array argument (will be splattered)
66
+ clearOrganic: "" # No argument
67
+ }
68
+ ```
69
+
70
+ erb example:
71
+
72
+ ```erb
73
+ <%= tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods) %>
74
+ ```
75
+
76
+ haml example:
77
+
78
+ ```haml
79
+ = tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods)
80
+ ```
81
+ ### Other Tracking URLs
82
+
83
+ You can use other Tracking URLs with the option tracker_url and ssl_tracker_url.
84
+
85
+ erb example:
86
+
87
+ ```erb
88
+ <%= tracking_code(account: 'UA-12345-6', tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js') %>
89
+ ```
90
+
91
+ haml example:
92
+
93
+ ```haml
94
+ = tracking_code(account: 'UA-12345-6', tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js')
95
+ ```
96
+
97
+ ## Contributing
98
+
99
+ Source hosted at [GitHub](http://github.com/splitrb/split-analytics).
100
+ Report Issues/Feature requests on [GitHub Issues](http://github.com/splitrb/split-analytics/issues).
101
+
102
+ Please follow the [Code of Conduct](CODE_OF_CONDUCT.md).
103
+
104
+ ### Note on Patches/Pull Requests
105
+
106
+ * Fork the project.
107
+ * Make your feature addition or bug fix.
108
+ * Add tests for it. This is important so I don't break it in a
109
+ future version unintentionally.
110
+ * Commit, do not mess with rakefile, version, or history.
111
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
112
+ * Send me a pull request. Bonus points for topic branches.
113
+
114
+ ### Testing
115
+
116
+ Tests can be ran with `rake spec`.
117
+
118
+ ## License
119
+
120
+ Copyright (c) 2015-2018 Andrew Nesbitt. See [LICENSE](LICENSE) for details.
@@ -1,5 +1,5 @@
1
1
  module Split
2
2
  module Analytics
3
- VERSION = "0.4.0"
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -1,8 +1,8 @@
1
- require "split/helper"
1
+ require 'split/helper'
2
2
 
3
3
  module Split
4
4
  module Analytics
5
- def tracking_code(options={})
5
+ def tracking_code(options = {})
6
6
  # needs more options: http://code.google.com/apis/analytics/docs/gaJS/gaJSApi.html
7
7
  account = options.delete(:account)
8
8
  tracker_url = options.delete(:tracker_url)
@@ -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}');
@@ -26,15 +26,16 @@ module Split
26
26
  })();
27
27
  </script>
28
28
  EOF
29
- code = raw(code)if defined?(raw)
29
+ code = raw(code) if defined?(raw)
30
30
  code
31
31
  end
32
32
 
33
33
  def custom_variables
34
- return nil if session[:split].nil?
34
+ return nil if ab_user.nil?
35
35
  arr = []
36
- session[:split].each_with_index do |h,i|
37
- arr << "_gaq.push(['_setCustomVar', #{i+1}, '#{h[0]}', '#{h[1]}', 1]);"
36
+
37
+ ab_user.active_experiments.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
@@ -44,25 +45,25 @@ module Split
44
45
  def insert_tracker_methods(tracker_methods)
45
46
  return nil if tracker_methods.nil?
46
47
  arr = []
47
- tracker_methods.each do |k,v|
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
@@ -80,4 +81,4 @@ if defined?(Rails)
80
81
  ActionController::Base.send :include, Split::Analytics
81
82
  ActionController::Base.helper Split::Analytics
82
83
  end
83
- end
84
+ end
@@ -2,33 +2,31 @@ require 'spec_helper'
2
2
 
3
3
  describe Split::Analytics do
4
4
  include Split::Helper
5
- it "should generate valid analytics javascript" do
6
- tracking_code = tracking_code(:account => 'UA-12345-6')
7
- tracking_code.should 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")
5
+ it 'should generate valid analytics javascript' do
6
+ tracking_code = tracking_code(account: 'UA-12345-6')
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
- it "should generate valid analytics javascript with arbitrary tracker object methods" do
10
+ it 'should generate valid analytics javascript with arbitrary tracker object methods' do
11
11
  tracker_methods = {
12
- :setDomainName => "example.com", # String argument
13
- :setAllowLinker => true, # Boolean argument
14
- :clearOrganic => "" # No argument
12
+ setDomainName: 'example.com', # String argument
13
+ setAllowLinker: true, # Boolean argument
14
+ clearOrganic: '' # No argument
15
15
  }
16
- tracking_code = tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
17
- tracking_code.should 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")
16
+ tracking_code = tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods)
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
- it "should add custom variables for every test the user is involved in" do
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
- second_alt = ab_test('link_text', 'Join', 'Signup')
22
+ expect(ab_user.active_experiments).to eql({'link_colour' => first_alt})
23
23
 
24
- session[:split].should eql({'link_colour' => first_alt,'link_text' => second_alt})
25
-
26
- tracking_code = tracking_code(:account => 'UA-12345-6')
27
- tracking_code.should eql(" <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', 'UA-12345-6']);\n _gaq.push(['_setCustomVar', 1, 'link_colour', '#{first_alt}', 1]);\n_gaq.push(['_setCustomVar', 2, 'link_text', '#{second_alt}', 1]);\n\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")
24
+ tracking_code = tracking_code(account: 'UA-12345-6')
25
+ 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})
28
26
  end
29
27
 
30
- it "uses doubleclick as tracker url" do
31
- 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')
32
- tracking_code.should 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")
28
+ it 'uses doubleclick as tracker url' do
29
+ 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')
30
+ 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})
33
31
  end
34
32
  end
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,24 @@ require 'split/helper'
5
5
  require 'split/analytics'
6
6
  require 'ostruct'
7
7
 
8
+ module GlobalSharedContext
9
+ extend RSpec::SharedContext
10
+ let(:ab_user){ Split::User.new(double(session: {})) }
11
+
12
+ before(:each) do
13
+ Split.configuration = Split::Configuration.new
14
+ Split.redis = Redis.new(db: 10)
15
+ Split.redis.flushall
16
+ @ab_user = ab_user
17
+ params = nil
18
+ end
19
+ end
20
+
21
+ RSpec.configure do |config|
22
+ config.order = 'random'
23
+ config.include GlobalSharedContext
24
+ end
25
+
8
26
  def session
9
27
  @session ||= {}
10
28
  end
@@ -14,8 +32,10 @@ def params
14
32
  end
15
33
 
16
34
  def request(ua = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27')
17
- r = OpenStruct.new
18
- r.user_agent = ua
19
- r.ip = '192.168.1.1'
20
- @request ||= r
21
- end
35
+ @request ||= begin
36
+ r = OpenStruct.new
37
+ r.user_agent = ua
38
+ r.ip = '192.168.1.1'
39
+ r
40
+ end
41
+ end
@@ -1,23 +1,23 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "split/analytics/version"
2
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
+ require 'split/analytics/version'
4
4
 
5
5
  Gem::Specification.new do |gem|
6
- gem.authors = ["Andrew Nesbitt"]
7
- gem.email = ["andrewnez@gmail.com"]
8
- gem.summary = %q{Split extension to push test data to google analytics}
9
- gem.homepage = "https://github.com/andrew/split-analytics"
6
+ gem.authors = ['Andrew Nesbitt']
7
+ gem.email = ['andrewnez@gmail.com']
8
+ gem.summary = 'Split extension to push test data to Google Analytics'
9
+ gem.homepage = 'https://github.com/splitrb/split-analytics'
10
10
  gem.license = 'MIT'
11
11
 
12
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
13
13
  gem.files = `git ls-files`.split("\n")
14
14
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- gem.name = "split-analytics"
15
+ gem.name = 'split-analytics'
16
16
  gem.require_paths = ['lib']
17
17
  gem.version = Split::Analytics::VERSION
18
18
 
19
- gem.add_dependency(%q<split>, [">= 0.3.0"])
19
+ gem.add_dependency('split', '>= 3.0.0')
20
20
 
21
- # Development Dependencies
22
- gem.add_development_dependency(%q<rspec>, ["~> 2.14"])
21
+ gem.add_development_dependency('rspec', '~> 3.1')
22
+ gem.add_development_dependency('rake', '~> 13.0')
23
23
  end
metadata CHANGED
@@ -1,84 +1,101 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: split
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.0
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.14'
33
+ version: '3.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.14'
41
- description:
40
+ version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ description:
42
56
  email:
43
57
  - andrewnez@gmail.com
44
58
  executables: []
45
59
  extensions: []
46
60
  extra_rdoc_files: []
47
61
  files:
48
- - .gitignore
62
+ - ".github/dependabot.yml"
63
+ - ".github/workflows/ci.yml"
64
+ - ".gitignore"
65
+ - CODE_OF_CONDUCT.md
66
+ - CONTRIBUTING.md
49
67
  - Gemfile
50
68
  - LICENSE
51
69
  - Rakefile
52
- - Readme.mdown
70
+ - Readme.md
53
71
  - lib/split/analytics.rb
54
72
  - lib/split/analytics/version.rb
55
73
  - spec/analytics_spec.rb
56
74
  - spec/spec_helper.rb
57
75
  - split-analytics.gemspec
58
- homepage: https://github.com/andrew/split-analytics
76
+ homepage: https://github.com/splitrb/split-analytics
59
77
  licenses:
60
78
  - MIT
61
79
  metadata: {}
62
- post_install_message:
80
+ post_install_message:
63
81
  rdoc_options: []
64
82
  require_paths:
65
83
  - lib
66
84
  required_ruby_version: !ruby/object:Gem::Requirement
67
85
  requirements:
68
- - - '>='
86
+ - - ">="
69
87
  - !ruby/object:Gem::Version
70
88
  version: '0'
71
89
  required_rubygems_version: !ruby/object:Gem::Requirement
72
90
  requirements:
73
- - - '>='
91
+ - - ">="
74
92
  - !ruby/object:Gem::Version
75
93
  version: '0'
76
94
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.0.3
79
- signing_key:
95
+ rubygems_version: 3.2.3
96
+ signing_key:
80
97
  specification_version: 4
81
- summary: Split extension to push test data to google analytics
98
+ summary: Split extension to push test data to Google Analytics
82
99
  test_files:
83
100
  - spec/analytics_spec.rb
84
101
  - spec/spec_helper.rb
data/Readme.mdown DELETED
@@ -1,110 +0,0 @@
1
- # Split::Analytics
2
-
3
- An extension to [Split](http://github.com/andrew/split) to push test data to google analytics.
4
-
5
- ## Requirements
6
-
7
- The split gem and its dependencies.
8
-
9
- ## Setup
10
-
11
- If you are using bundler add split to your Gemfile:
12
-
13
- ```ruby
14
- gem 'split-analytics', :require => 'split/analytics'
15
- ```
16
-
17
- Then run:
18
-
19
- ```bash
20
- bundle install
21
- ```
22
-
23
- Otherwise install the gem:
24
-
25
- ```bash
26
- gem install split-analytics
27
- ```
28
-
29
- and require it in your project:
30
-
31
- ```ruby
32
- require 'split/analytics'
33
- ```
34
-
35
- ## Usage
36
-
37
- Use in your application layout template
38
-
39
- erb example:
40
-
41
- ```erb
42
- <%= tracking_code(:account => 'UA-12345-6') %>
43
- ```
44
-
45
- haml example:
46
-
47
- ```haml
48
- = tracking_code(:account => 'UA-12345-6')
49
- ```
50
-
51
- ### With Tracking Methods
52
-
53
- See [Google Analytics Tracking Methods](https://developers.google.com/analytics/devguides/collection/gajs/methods/) for available options.
54
-
55
- ```
56
- tracker_methods = {
57
- :setDomainName => "example.com", # String argument
58
- :setAllowLinker => true, # Boolean argument
59
- :require => ['inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js'] # Array argument (will be splattered)
60
- :clearOrganic => "" # No argument
61
- }
62
- ```
63
-
64
- erb example:
65
-
66
- ```erb
67
- <%= tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods) %>
68
- ```
69
-
70
- haml example:
71
-
72
- ```haml
73
- = tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
74
- ```
75
- ### Other Tracking URLs
76
-
77
- You can use other Tracking URLs with the option tracker_url and ssl_tracker_url.
78
-
79
- erb example:
80
-
81
- ```erb
82
- <%= tracking_code(:account => 'UA-12345-6', :tracker_url => 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js') %>
83
- ```
84
-
85
- haml example:
86
-
87
- ```haml
88
- = tracking_code(:account => 'UA-12345-6', :tracker_url => 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js')
89
- ```
90
-
91
- ## Development
92
-
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).
95
-
96
- Tests can be ran with `rake spec`
97
-
98
- ### Note on Patches/Pull Requests
99
-
100
- * Fork the project.
101
- * Make your feature addition or bug fix.
102
- * Add tests for it. This is important so I don't break it in a
103
- future version unintentionally.
104
- * Commit, do not mess with rakefile, version, or history.
105
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
106
- * Send me a pull request. Bonus points for topic branches.
107
-
108
- ## Copyright
109
-
110
- Copyright (c) 2013 Andrew Nesbitt. See LICENSE for details.