analytical 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. data/lib/analytical/api.rb +2 -2
  2. metadata +6 -86
  3. data/.document +0 -5
  4. data/.rspec +0 -2
  5. data/.rvmrc +0 -8
  6. data/Gemfile +0 -18
  7. data/Gemfile.lock +0 -118
  8. data/Guardfile +0 -8
  9. data/Rakefile +0 -34
  10. data/VERSION +0 -1
  11. data/analytical.gemspec +0 -187
  12. data/example/.gitignore +0 -4
  13. data/example/Gemfile +0 -27
  14. data/example/Gemfile.lock +0 -80
  15. data/example/README +0 -244
  16. data/example/Rakefile +0 -10
  17. data/example/app/controllers/application_controller.rb +0 -6
  18. data/example/app/controllers/page_controller.rb +0 -18
  19. data/example/app/helpers/application_helper.rb +0 -2
  20. data/example/app/helpers/page_helper.rb +0 -2
  21. data/example/app/views/layouts/application.html.erb +0 -17
  22. data/example/app/views/page/index.html.erb +0 -6
  23. data/example/app/views/page/test_a.html.erb +0 -11
  24. data/example/app/views/page/test_b.html.erb +0 -7
  25. data/example/config.ru +0 -4
  26. data/example/config/analytical.yml +0 -30
  27. data/example/config/application.rb +0 -46
  28. data/example/config/boot.rb +0 -6
  29. data/example/config/database.yml +0 -22
  30. data/example/config/environment.rb +0 -7
  31. data/example/config/environments/development.rb +0 -21
  32. data/example/config/environments/production.rb +0 -42
  33. data/example/config/environments/test.rb +0 -32
  34. data/example/config/initializers/backtrace_silencers.rb +0 -7
  35. data/example/config/initializers/inflections.rb +0 -10
  36. data/example/config/initializers/mime_types.rb +0 -5
  37. data/example/config/initializers/secret_token.rb +0 -7
  38. data/example/config/initializers/session_store.rb +0 -8
  39. data/example/config/locales/en.yml +0 -5
  40. data/example/config/routes.rb +0 -63
  41. data/example/db/seeds.rb +0 -7
  42. data/example/doc/README_FOR_APP +0 -2
  43. data/example/lib/tasks/.gitkeep +0 -0
  44. data/example/public/404.html +0 -26
  45. data/example/public/422.html +0 -26
  46. data/example/public/500.html +0 -26
  47. data/example/public/favicon.ico +0 -0
  48. data/example/public/images/rails.png +0 -0
  49. data/example/public/javascripts/application.js +0 -2
  50. data/example/public/javascripts/controls.js +0 -965
  51. data/example/public/javascripts/dragdrop.js +0 -974
  52. data/example/public/javascripts/effects.js +0 -1123
  53. data/example/public/javascripts/prototype.js +0 -4874
  54. data/example/public/javascripts/rails.js +0 -118
  55. data/example/public/robots.txt +0 -5
  56. data/example/public/stylesheets/.gitkeep +0 -0
  57. data/example/script/rails +0 -9
  58. data/example/test/functional/page_controller_test.rb +0 -19
  59. data/example/test/performance/browsing_test.rb +0 -9
  60. data/example/test/test_helper.rb +0 -13
  61. data/example/test/unit/helpers/page_helper_test.rb +0 -4
  62. data/example/vendor/plugins/.gitkeep +0 -0
  63. data/spec/analytical/api_spec.rb +0 -167
  64. data/spec/analytical/bot_detector_spec.rb +0 -24
  65. data/spec/analytical/command_store_spec.rb +0 -36
  66. data/spec/analytical/modules/adroll_spec.rb +0 -27
  67. data/spec/analytical/modules/adwords_spec.rb +0 -76
  68. data/spec/analytical/modules/base_spec.rb +0 -138
  69. data/spec/analytical/modules/chartbeat_spec.rb +0 -26
  70. data/spec/analytical/modules/clicky_spec.rb +0 -44
  71. data/spec/analytical/modules/comscore_spec.rb +0 -27
  72. data/spec/analytical/modules/google_spec.rb +0 -54
  73. data/spec/analytical/modules/kiss_metrics_spec.rb +0 -51
  74. data/spec/analytical/modules/mixpanel_spec.rb +0 -49
  75. data/spec/analytical/modules/optimizely_spec.rb +0 -26
  76. data/spec/analytical/modules/quantcast.rb +0 -26
  77. data/spec/analytical/modules/reinvigorate_spec.rb +0 -35
  78. data/spec/analytical/session_command_store_spec.rb +0 -50
  79. data/spec/analytical_spec.rb +0 -118
  80. data/spec/config/analytical.yml +0 -19
  81. data/spec/spec.opts +0 -5
  82. data/spec/spec_helper.rb +0 -22
@@ -1,76 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::Adwords" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:google=>{:key=>'abc'}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abc'
10
- a.tracking_command_location.should == :body_append
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abc'
14
- a.options.should == {:key=>'abc', :parent=>@parent}
15
- end
16
- end
17
- describe '#event' do
18
- it 'should return an empty string' do
19
- @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef'
20
- @api.event('Nothing', {:some=>'data'}).should == ''
21
- end
22
- end
23
- describe '#init_javascript' do
24
- describe 'when a matching conversion event is not found' do
25
- it 'should return the event js' do
26
- @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef'
27
- @api.queue :event, 'Nothing', {:some=>'data'}
28
- @api.init_javascript(:body_append).should.should =~ /<!-- No Adwords Conversion for: Nothing -->/
29
- end
30
- end
31
- describe 'for a given conversion event' do
32
- before(:each) do
33
- @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef', :'TheBigEvent'=>{
34
- :id=>'55555',
35
- :language=>'en',
36
- :format=>'2',
37
- :color=>'ffffff',
38
- :label=>'abcdef',
39
- :value=>'0',
40
- }
41
- end
42
- it 'should return the event js' do
43
- @api.queue :event, 'TheBigEvent'
44
- body_append = @api.init_javascript(:body_append).should
45
- body_append.should =~ /google_conversion_id = 55555/m
46
- body_append.should =~ /google_conversion_language = "en";/m
47
- body_append.should =~ /google_conversion_format = "2";/m
48
- body_append.should =~ /google_conversion_color = "ffffff";/m
49
- body_append.should =~ /google_conversion_label = "abcdef";/m
50
- body_append.should =~ /google_conversion_value = 0;/m
51
- body_append.should =~ /http:\/\/www.googleadservices.com\/pagead\/conversion.js/m
52
- end
53
- describe 'with a custom value' do
54
- it 'should return the event js' do
55
- @api.queue :event, 'TheBigEvent', :value=>666.66
56
- body_append = @api.init_javascript(:body_append).should
57
- body_append.should =~ /google_conversion_value = 666.66;/m
58
- end
59
- end
60
- describe 'for https' do
61
- it 'should return the event js' do
62
- @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef', :ssl=>true, :'TheBigEvent'=>{
63
- :id=>'55555',
64
- :language=>'en',
65
- :format=>'2',
66
- :color=>'ffffff',
67
- :label=>'abcdef',
68
- :value=>'0',
69
- }
70
- @api.queue :event, 'TheBigEvent'
71
- @api.init_javascript(:body_append).should =~ /https:\/\/www.googleadservices.com\/pagead\/conversion.js/
72
- end
73
- end
74
- end
75
- end
76
- end
@@ -1,138 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe Analytical::Modules::Base do
4
-
5
- class BaseApiDummy
6
- include Analytical::Modules::Base
7
- end
8
-
9
- describe '#protocol' do
10
- before(:each) do
11
- @api = BaseApiDummy.new(:parent=>mock('parent'))
12
- end
13
- describe 'with :ssl=>true option' do
14
- it 'should return https' do
15
- @api = BaseApiDummy.new(:parent=>mock('parent'), :ssl=>true)
16
- @api.protocol.should == 'https'
17
- end
18
- end
19
- it 'should return http' do
20
- @api.protocol.should == 'http'
21
- end
22
- end
23
-
24
- describe '#queue' do
25
- before(:each) do
26
- @api = BaseApiDummy.new(:parent=>mock('parent'))
27
- @api.command_store.commands = [:a, :b, :c]
28
- end
29
- describe 'with an identify command' do
30
- it 'should store it at the head of the command list' do
31
- @api.queue :identify, 'someone', {:some=>:args}
32
- @api.command_store.commands.should == [[:identify, 'someone', {:some=>:args}], :a, :b, :c]
33
- end
34
- end
35
- describe 'with any other command' do
36
- it 'should store it at the end of the command list' do
37
- @api.queue :other, {:some=>:args}
38
- @api.command_store.commands.should == [:a, :b, :c, [:other, {:some=>:args}]]
39
- end
40
- end
41
- describe 'ignoring duplicates' do
42
- before(:each) do
43
- @api = BaseApiDummy.new(:parent=>mock('parent'), :ignore_duplicates=>true)
44
- @api.command_store.commands = [[:a]]
45
- end
46
- it 'should store only unique commands' do
47
- @api.queue :other, {:some=>:args}
48
- @api.queue :a
49
- @api.queue :other, {:some=>:args}
50
- @api.queue :b
51
- @api.command_store.commands.should == [[:a], [:other, {:some=>:args}], [:b]]
52
- end
53
- end
54
- end
55
-
56
- describe '#process_queued_commands' do
57
- before(:each) do
58
- @api = BaseApiDummy.new(:parent=>mock('parent'))
59
- @api.command_store.commands = [[:a, 1, 2, 3], [:b, {:some=>:args}]]
60
- @api.stub!(:a).and_return('a')
61
- @api.stub!(:b).and_return('b')
62
- end
63
- it 'should send each of the args arrays in the command list' do
64
- @api.should_receive(:a).with(1, 2, 3).and_return('a')
65
- @api.should_receive(:b).with({:some=>:args}).and_return('b')
66
- @api.process_queued_commands
67
- end
68
- it 'should return the results as an array' do
69
- @api.process_queued_commands.should == ['a', 'b']
70
- end
71
- it 'should clear the commands list' do
72
- @api.process_queued_commands
73
- @api.command_store.commands == []
74
- end
75
- it "should not store an unrecognized command" do
76
- @api.command_store.commands << [:c, 1]
77
- @api.process_queued_commands.should == ['a','b']
78
- end
79
- end
80
-
81
- describe '#init_location?' do
82
- before(:each) do
83
- @api = BaseApiDummy.new(:parent=>mock('parent'))
84
- @api.instance_variable_set '@tracking_command_location', :my_location
85
- end
86
- describe 'when the command location matches the init location' do
87
- it 'should return true' do
88
- @api.init_location?(:my_location).should be_true
89
- end
90
- end
91
- describe 'when the command location does not match the init location' do
92
- it 'should return false' do
93
- @api.init_location?(:not_my_location).should be_false
94
- end
95
- end
96
- end
97
-
98
- describe '#init_location' do
99
- before(:each) do
100
- @api = BaseApiDummy.new
101
- end
102
- it 'should check for the init_location' do
103
- @api.should_receive(:init_location?).with(:some_location).and_return(false)
104
- @api.init_location(:some_location)
105
- end
106
- describe 'for a valid init location' do
107
- before(:each) { @api.stub!(:init_location?).and_return(true) }
108
- it 'should set initialized to true' do
109
- @api.init_location(:some_location)
110
- @api.initialized.should be_true
111
- end
112
- it 'should yield to the block and return its result' do
113
- @api.init_location(:some_location) do
114
- 'result from the block'
115
- end.should == 'result from the block'
116
- end
117
- end
118
- describe 'not for an init location' do
119
- before(:each) do
120
- @api.stub!(:init_location?).and_return(false)
121
- end
122
- it 'should return an empty string' do
123
- @api.init_location(:not_my_init_location).should == ''
124
- end
125
- end
126
- end
127
-
128
- describe 'with a custom session_store' do
129
- before(:each) do
130
- @session = {}
131
- @store = Analytical::SessionCommandStore.new @session, :some_module
132
- end
133
- it 'should use the session_store' do
134
- @api = BaseApiDummy.new :session_store=>@store
135
- @api.command_store.should == @store
136
- end
137
- end
138
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::Chartbeat" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:chartbeat=>{:key=>1234, :domain =>'test.com'}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::Chartbeat.new :parent=>@parent, :key=>1234
10
- a.tracking_command_location.should == [:head_prepend, :body_append]
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::Chartbeat.new :parent=>@parent, :key=>12345, :domain =>'abcdef.com'
14
- a.options.should == {:key=>12345, :domain => 'abcdef.com', :parent=>@parent}
15
- end
16
- end
17
- describe '#init_javascript' do
18
- it 'should return the init javascript' do
19
- @api = Analytical::Modules::Chartbeat.new :parent=>@parent, :key=>12345, :domain =>'abcdef.com'
20
- @api.init_javascript(:head_prepend).should =~ /_sf_startpt=\(new.Date\(\)\)\.getTime\(\);/
21
- @api.init_javascript(:head_append).should == ''
22
- @api.init_javascript(:body_prepend).should == ''
23
- @api.init_javascript(:body_append).should =~ /_sf_async_config=\{uid:12345,.*domain:"abcdef\.com"\};/
24
- end
25
- end
26
- end
@@ -1,44 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::Clicky" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:google=>{:key=>'abc'}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::Clicky.new :parent=>@parent, :key=>'abc'
10
- a.tracking_command_location.should == :body_append
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::Clicky.new :parent=>@parent, :key=>'abc'
14
- a.options.should == {:key=>'abc', :parent=>@parent}
15
- end
16
- end
17
- describe '#track' do
18
- it 'should return the tracking javascript' do
19
- @api = Analytical::Modules::Clicky.new :parent=>@parent, :key=>'abcdef'
20
- @api.track('pagename', {:some=>'data'}).should == "clicky.log(\"pagename\");"
21
- end
22
- end
23
- describe '#identify' do
24
- it 'should return the init code string' do
25
- @api = Analytical::Modules::Clicky.new :parent=>@parent, :key=>'abcdef'
26
- @api.identify('user id', {:a=>'b'}).should =~ /#{Regexp.escape({:id=>'user id', :a=>'b'}.to_json)}/
27
- end
28
- end
29
- describe '#init_javascript' do
30
- it 'should return the init javascript' do
31
- @api = Analytical::Modules::Clicky.new :parent=>@parent, :key=>'abcdef'
32
- @api.init_javascript(:head_prepend).should == ''
33
- @api.init_javascript(:head_append).should == ''
34
- @api.init_javascript(:body_prepend).should == ''
35
- @api.init_javascript(:body_append).should =~ /static.getclicky.com\/js/
36
- @api.init_javascript(:body_append).should =~ /abcdef/
37
- end
38
- describe 'with an identify command queued' do
39
- @api = Analytical::Modules::Clicky.new :parent=>@parent, :key=>'abcdef'
40
- @api.queue :identify, 'user id', {:email=>'someone@test.com'}
41
- @api.init_javascript(:body_append).should =~ /"email":\w*"someone@test\.com"/
42
- end
43
- end
44
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::Comscore" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:comscore=>{:key=>123}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::Comscore.new :parent=>@parent, :key=>123
10
- a.tracking_command_location.should == :head_append
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::Comscore.new :parent=>@parent, :key=>1234
14
- a.options.should == {:key=>1234, :parent=>@parent}
15
- end
16
- end
17
- describe '#init_javascript' do
18
- it 'should return the init javascript' do
19
- @api = Analytical::Modules::Comscore.new :parent=>@parent, :key=>1234
20
- @api.init_javascript(:head_prepend).should == ''
21
- @api.init_javascript(:head_append).should =~ /scorecardresearch.com\/beacon.js/
22
- @api.init_javascript(:head_append).should =~ /1234/
23
- @api.init_javascript(:body_prepend).should == ''
24
- @api.init_javascript(:body_append).should == ''
25
- end
26
- end
27
- end
@@ -1,54 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::Google" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:google=>{:key=>'abc'}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::Google.new :parent=>@parent, :key=>'abc'
10
- a.tracking_command_location.should == :head_append
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::Google.new :parent=>@parent, :key=>'abc'
14
- a.options.should == {:key=>'abc', :parent=>@parent}
15
- end
16
- end
17
- describe '#track' do
18
- it 'should return the tracking javascript' do
19
- @api = Analytical::Modules::Google.new :parent=>@parent, :key=>'abcdef'
20
- @api.track.should == "_gaq.push(['_trackPageview']);"
21
- @api.track('pagename', {:some=>'data'}).should == "_gaq.push(['_trackPageview', \"pagename\"]);"
22
- end
23
- end
24
- describe '#event' do
25
- it 'should return the event javascript' do
26
- @api = Analytical::Modules::Google.new :parent=>@parent, :key=>'abcdef'
27
- @api.event('pagename').should == "_gaq.push(['_trackEvent', \"Event\", \"pagename\"]);"
28
- end
29
-
30
- it 'should include data value' do
31
- @api = Analytical::Modules::Google.new :parent=>@parent, :key=>'abcdef'
32
- @api.event('pagename', {:value=>555, :more=>'info'}).should == "_gaq.push(['_trackEvent', \"Event\", \"pagename\", 555]);"
33
- end
34
- it 'should not include data if there is no value' do
35
- @api = Analytical::Modules::Google.new :parent=>@parent, :key=>'abcdef'
36
- @api.event('pagename', {:more=>'info'}).should == "_gaq.push(['_trackEvent', \"Event\", \"pagename\"]);"
37
- end
38
- it 'should not include data if it is not a hash' do
39
- @api = Analytical::Modules::Google.new :parent=>@parent, :key=>'abcdef'
40
- @api.event('pagename', 555).should == "_gaq.push(['_trackEvent', \"Event\", \"pagename\", 555]);"
41
- end
42
-
43
- end
44
- describe '#init_javascript' do
45
- it 'should return the init javascript' do
46
- @api = Analytical::Modules::Google.new :parent=>@parent, :key=>'abcdef'
47
- @api.init_javascript(:head_prepend).should == ''
48
- @api.init_javascript(:head_append).should =~ /abcdef/
49
- @api.init_javascript(:head_append).should =~ /google-analytics.com\/ga.js/
50
- @api.init_javascript(:body_prepend).should == ''
51
- @api.init_javascript(:body_append).should == ''
52
- end
53
- end
54
- end
@@ -1,51 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::KissMetrics" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:google=>{:js_url_key=>'abc'}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::KissMetrics.new :parent=>@parent, :js_url_key=>'abc'
10
- a.tracking_command_location.should == :body_prepend
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::KissMetrics.new :parent=>@parent, :js_url_key=>'abc'
14
- a.options.should == {:js_url_key=>'abc', :parent=>@parent}
15
- end
16
- end
17
- describe '#identify' do
18
- it 'should return a js string' do
19
- @api = Analytical::Modules::KissMetrics.new :parent=>@parent, :js_url_key=>'abcdef'
20
- @api.identify('id', {:email=>'test@test.com'}).should == "_kmq.push([\"identify\", \"test@test.com\"]);"
21
- end
22
- end
23
- describe '#event' do
24
- it 'should return a js string' do
25
- @api = Analytical::Modules::KissMetrics.new :parent=>@parent, :js_url_key=>'abcdef'
26
- @api.event('Big Deal', {:something=>'good'}).should == "_kmq.push([\"record\", \"Big Deal\", #{{:something=>'good'}.to_json}]);"
27
- end
28
- end
29
- describe '#set' do
30
- it 'should return a js string' do
31
- @api = Analytical::Modules::KissMetrics.new :parent=>@parent, :js_url_key=>'abcdef'
32
- @api.set({:something=>'good', :b=>2}).should == "_kmq.push([\"set\", #{{:something=>'good', :b=>2}.to_json}]);"
33
- end
34
- end
35
- describe '#alias_identity' do
36
- it 'should return a js string' do
37
- @api = Analytical::Modules::KissMetrics.new :parent=>@parent, :js_url_key=>'abcdef'
38
- @api.alias_identity('foo', 'bar').should == "_kmq.push([\"alias\", \"foo\", \"bar\"]);"
39
- end
40
- end
41
- describe '#init_javascript' do
42
- it 'should return the init javascript' do
43
- @api = Analytical::Modules::KissMetrics.new :parent=>@parent, :js_url_key=>'abcdef'
44
- @api.init_javascript(:head_prepend).should == ''
45
- @api.init_javascript(:head_append).should == ''
46
- @api.init_javascript(:body_prepend).should =~ /i\.kissmetrics\.com/
47
- @api.init_javascript(:body_prepend).should =~ /abcdef/
48
- @api.init_javascript(:body_append).should == ''
49
- end
50
- end
51
- end
@@ -1,49 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::Mixpanel" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:google=>{:js_url_key=>'abc'}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::Mixpanel.new :parent=>@parent, :js_url_key=>'abc'
10
- a.tracking_command_location.should == :body_append
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::Mixpanel.new :parent=>@parent, :js_url_key=>'abc'
14
- a.options.should == {:js_url_key=>'abc', :parent=>@parent}
15
- end
16
- end
17
- describe '#identify' do
18
- it 'should return a js string' do
19
- @api = Analytical::Modules::Mixpanel.new :parent=>@parent, :js_url_key=>'abcdef'
20
- @api.identify('id', {:email=>'test@test.com'}).should == "mpmetrics.identify('id');"
21
- end
22
- end
23
- describe '#track' do
24
- it 'should return the tracking javascript' do
25
- @api = Analytical::Modules::Mixpanel.new :parent=>@parent, :key=>'abcdef'
26
- @api.track('pagename', {:some=>'data'}).should == "mpmetrics.track('pagename', {\"some\":\"data\"}, function(){});"
27
- end
28
- it 'should return the tracking javascript with a callback' do
29
- @api = Analytical::Modules::Mixpanel.new :parent=>@parent, :key=>'abcdef'
30
- @api.track('pagename', {:some=>'data', :callback=>'fubar'}).should == "mpmetrics.track('pagename', {\"some\":\"data\"}, fubar);"
31
- end
32
- end
33
- describe '#event' do
34
- it 'should return a js string' do
35
- @api = Analytical::Modules::Mixpanel.new :parent=>@parent, :js_url_key=>'abcdef'
36
- @api.event('An event happened', { :item => 43 }).should == "mpmetrics.track('An event happened', {\"item\":43});"
37
- end
38
- end
39
- describe '#init_javascript' do
40
- it 'should return the init javascript' do
41
- @api = Analytical::Modules::Mixpanel.new :parent=>@parent, :js_url_key=>'abcdef'
42
- @api.init_javascript(:head_prepend).should == ''
43
- @api.init_javascript(:head_append).should == ''
44
- @api.init_javascript(:body_prepend).should == ''
45
- @api.init_javascript(:body_append).should =~ /api\.mixpanel\.com\/site_media\/js\/api\/mixpanel\.js/
46
- @api.init_javascript(:body_append).should =~ /new MixpanelLib\('.*'\)/
47
- end
48
- end
49
- end