split-analytics 1.0.1 → 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: 37226a44a019f3dfdb48e667631cc012389cc588
4
- data.tar.gz: 2dd4cb0f15a3cfa437d8cc003947c91ac38f14c4
2
+ SHA256:
3
+ metadata.gz: 78147218626221c2bfaeda3b5172d09e8338e790fceb638a7308151405dc9648
4
+ data.tar.gz: f29e658301c364bc48bf6bd1ff461b1c7cce5c615020693304957f7cce6653c9
5
5
  SHA512:
6
- metadata.gz: 428b4424100c1285bf16814e04911c0514d1336cbacd731c5fb24c3bb0e29adea3938e013d622f8286d2e4460142f57e8f1ee21680e1a4d1e10c2cfd80266e39
7
- data.tar.gz: f044584b79505ca14a492881bdc6797e0f0b0158407d474f21a175cd3333b53955bb176558006abde7e646d609701587b8ecf90dd6de6966180b8b71c76d4975
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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 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
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 CHANGED
@@ -1,21 +1,23 @@
1
1
  # [Split Analytics](http://libraries.io/rubygems/split-analytics)
2
2
 
3
- An extension to [Split](http://github.com/splitrb/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
4
 
5
5
  [![Build Status](https://secure.travis-ci.org/splitrb/split-analytics.svg?branch=master)](http://travis-ci.org/andrew/split-analytics)
6
6
  [![Gem Version](https://badge.fury.io/rb/split-analytics.svg)](http://badge.fury.io/rb/split-analytics)
7
7
  [![Dependency Status](https://gemnasium.com/splitrb/split-analytics.svg)](https://gemnasium.com/andrew/split-analytics)
8
8
 
9
- ## Requirements
9
+ ## Install
10
+
11
+ ### Requirements
10
12
 
11
13
  The split gem and its dependencies.
12
14
 
13
- ## Setup
15
+ ### Setup
14
16
 
15
17
  If you are using bundler add split to your Gemfile:
16
18
 
17
19
  ```ruby
18
- gem 'split-analytics', :require => 'split/analytics'
20
+ gem 'split-analytics', require: 'split/analytics'
19
21
  ```
20
22
 
21
23
  Then run:
@@ -43,13 +45,13 @@ Use in your application layout template
43
45
  erb example:
44
46
 
45
47
  ```erb
46
- <%= tracking_code(:account => 'UA-12345-6') %>
48
+ <%= tracking_code(account: 'UA-12345-6') %>
47
49
  ```
48
50
 
49
51
  haml example:
50
52
 
51
53
  ```haml
52
- = tracking_code(:account => 'UA-12345-6')
54
+ = tracking_code(account: 'UA-12345-6')
53
55
  ```
54
56
 
55
57
  ### With Tracking Methods
@@ -58,23 +60,23 @@ See [Google Analytics Tracking Methods](https://developers.google.com/analytics/
58
60
 
59
61
  ```ruby
60
62
  tracker_methods = {
61
- :setDomainName => "example.com", # String argument
62
- :setAllowLinker => true, # Boolean argument
63
- :require => ['inpage_linkid', '//www.google-analytics.com/plugins/ga/inpage_linkid.js'] # Array argument (will be splattered)
64
- :clearOrganic => "" # No argument
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
65
67
  }
66
68
  ```
67
69
 
68
70
  erb example:
69
71
 
70
72
  ```erb
71
- <%= tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods) %>
73
+ <%= tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods) %>
72
74
  ```
73
75
 
74
76
  haml example:
75
77
 
76
78
  ```haml
77
- = tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
79
+ = tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods)
78
80
  ```
79
81
  ### Other Tracking URLs
80
82
 
@@ -83,21 +85,21 @@ You can use other Tracking URLs with the option tracker_url and ssl_tracker_url.
83
85
  erb example:
84
86
 
85
87
  ```erb
86
- <%= tracking_code(:account => 'UA-12345-6', :tracker_url => 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js') %>
88
+ <%= tracking_code(account: 'UA-12345-6', tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js') %>
87
89
  ```
88
90
 
89
91
  haml example:
90
92
 
91
93
  ```haml
92
- = tracking_code(:account => 'UA-12345-6', :tracker_url => 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js')
94
+ = tracking_code(account: 'UA-12345-6', tracker_url: 'stats.g.doubleclick.net/dc.js', ssl_tracker_url: 'stats.g.doubleclick.net/dc.js')
93
95
  ```
94
96
 
95
- ## Development
97
+ ## Contributing
96
98
 
97
99
  Source hosted at [GitHub](http://github.com/splitrb/split-analytics).
98
100
  Report Issues/Feature requests on [GitHub Issues](http://github.com/splitrb/split-analytics/issues).
99
101
 
100
- Tests can be ran with `rake spec`
102
+ Please follow the [Code of Conduct](CODE_OF_CONDUCT.md).
101
103
 
102
104
  ### Note on Patches/Pull Requests
103
105
 
@@ -109,6 +111,10 @@ Tests can be ran with `rake spec`
109
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)
110
112
  * Send me a pull request. Bonus points for topic branches.
111
113
 
112
- ## Copyright
114
+ ### Testing
115
+
116
+ Tests can be ran with `rake spec`.
117
+
118
+ ## License
113
119
 
114
- Copyright (c) 2015 Andrew Nesbitt. See LICENSE for details.
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 = '1.0.1'
3
+ VERSION = '1.1.0'
4
4
  end
5
5
  end
@@ -31,10 +31,10 @@ module Split
31
31
  end
32
32
 
33
33
  def custom_variables
34
- return nil if session.nil?
34
+ return nil if ab_user.nil?
35
35
  arr = []
36
36
 
37
- session.each_with_index do |h, i|
37
+ ab_user.active_experiments.each_with_index do |h, i|
38
38
  arr << "_gaq.push([\"_setCustomVar\", #{i + 1}, \"#{h[0]}\", \"#{h[1]}\", 1]);"
39
39
  end
40
40
  arr.reverse[0..4].reverse.join("\n")
@@ -13,21 +13,20 @@ describe Split::Analytics do
13
13
  setAllowLinker: true, # Boolean argument
14
14
  clearOrganic: '' # No argument
15
15
  }
16
- tracking_code = tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
16
+ tracking_code = tracking_code(account: 'UA-12345-6', tracker_methods: tracker_methods)
17
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
-
23
- expect(session).to eql({'link_colour' => first_alt})
22
+ expect(ab_user.active_experiments).to eql({'link_colour' => first_alt})
24
23
 
25
24
  tracking_code = tracking_code(account: 'UA-12345-6')
26
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})
27
26
  end
28
27
 
29
28
  it 'uses doubleclick as tracker url' do
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')
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')
31
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})
32
31
  end
33
32
  end
data/spec/spec_helper.rb CHANGED
@@ -5,15 +5,37 @@ require 'split/helper'
5
5
  require 'split/analytics'
6
6
  require 'ostruct'
7
7
 
8
- def session
9
- @ab_user ||= {}
10
- end
8
+ module GlobalSharedContext
9
+ extend RSpec::SharedContext
10
+ let(:ab_user){ Split::User.new(double(session: {})) }
11
11
 
12
- RSpec.configure do |config|
13
- config.order = 'random'
14
- config.before(:each) do
12
+ before(:each) do
15
13
  Split.configuration = Split::Configuration.new
14
+ Split.redis = Redis.new(db: 10)
16
15
  Split.redis.flushall
17
- @ab_user = {}
16
+ @ab_user = ab_user
17
+ params = nil
18
18
  end
19
19
  end
20
+
21
+ RSpec.configure do |config|
22
+ config.order = 'random'
23
+ config.include GlobalSharedContext
24
+ end
25
+
26
+ def session
27
+ @session ||= {}
28
+ end
29
+
30
+ def params
31
+ @params ||= {}
32
+ end
33
+
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')
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
@@ -5,7 +5,7 @@ require 'split/analytics/version'
5
5
  Gem::Specification.new do |gem|
6
6
  gem.authors = ['Andrew Nesbitt']
7
7
  gem.email = ['andrewnez@gmail.com']
8
- gem.summary = 'Split extension to push test data to google analytics'
8
+ gem.summary = 'Split extension to push test data to Google Analytics'
9
9
  gem.homepage = 'https://github.com/splitrb/split-analytics'
10
10
  gem.license = 'MIT'
11
11
 
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ['lib']
17
17
  gem.version = Split::Analytics::VERSION
18
18
 
19
- gem.add_dependency('split', '>= 1.0.0')
19
+ gem.add_dependency('split', '>= 3.0.0')
20
20
 
21
21
  gem.add_development_dependency('rspec', '~> 3.1')
22
- gem.add_development_dependency('rake', '~> 10.4')
22
+ gem.add_development_dependency('rake', '~> 13.0')
23
23
  end
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.1
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: 2016-01-13 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.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: 1.0.0
26
+ version: 3.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,23 +44,26 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.4'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.4'
55
- description:
54
+ version: '13.0'
55
+ description:
56
56
  email:
57
57
  - andrewnez@gmail.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/dependabot.yml"
63
+ - ".github/workflows/ci.yml"
62
64
  - ".gitignore"
63
- - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - CONTRIBUTING.md
64
67
  - Gemfile
65
68
  - LICENSE
66
69
  - Rakefile
@@ -74,7 +77,7 @@ homepage: https://github.com/splitrb/split-analytics
74
77
  licenses:
75
78
  - MIT
76
79
  metadata: {}
77
- post_install_message:
80
+ post_install_message:
78
81
  rdoc_options: []
79
82
  require_paths:
80
83
  - lib
@@ -89,11 +92,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
92
  - !ruby/object:Gem::Version
90
93
  version: '0'
91
94
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.5.1
94
- signing_key:
95
+ rubygems_version: 3.2.3
96
+ signing_key:
95
97
  specification_version: 4
96
- summary: Split extension to push test data to google analytics
98
+ summary: Split extension to push test data to Google Analytics
97
99
  test_files:
98
100
  - spec/analytics_spec.rb
99
101
  - spec/spec_helper.rb
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.4
4
-
5
- services:
6
- - redis-server
7
- cache: bundler
8
- sudo: false