Skip to content

Commit f5020ea

Browse files
committed
Revert "Use ab_user instead of session"
This reverts commit 22b1c37.
1 parent 5079fd8 commit f5020ea

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

lib/split/analytics.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def tracking_code(options = {})
3131
end
3232

3333
def custom_variables
34-
return nil if ab_user.nil?
34+
return nil if session[:split].nil?
3535
arr = []
36-
ab_user.each_with_index do |h, i|
36+
session[:split].each_with_index do |h, i|
3737
arr << "_gaq.push(['_setCustomVar', #{i + 1}, '#{h[0]}', '#{h[1]}', 1]);"
3838
end
3939
arr.reverse[0..4].reverse.join("\n")

spec/analytics_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
it 'should add custom variables for every test the user is involved in' do
2121
first_alt = ab_test('link_colour', 'red', 'blue')
2222

23+
session[:split].should eql({'link_colour' => first_alt})
24+
2325
tracking_code = tracking_code(account: 'UA-12345-6')
2426
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")
2527
end

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
require 'split/analytics'
66
require 'ostruct'
77

8+
def session
9+
@ab_user ||= {}
10+
end
11+
812
RSpec.configure do |config|
913
config.order = 'random'
1014
config.before(:each) do

0 commit comments

Comments
 (0)