analytical 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,7 +10,7 @@ Service implementations include:
10
10
  * Hubspot[http://hubspot.com]
11
11
  * CrazyEgg[http://www.crazyegg.com]
12
12
  * Chartbeat[http://chartbeat.com]
13
- * comScore Direct[http://direct.comscore.com]
13
+ * "ComScore Direct"[http://direct.comscore.com]
14
14
  * Optimizely[http://www.optimizely.com]
15
15
 
16
16
  == Usage
@@ -75,6 +75,16 @@ I would be extremely happy to accept contributions to this project! If you thin
75
75
  (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)
76
76
  * Send me a pull request. Bonus points for topic branches.
77
77
 
78
+ == Current Contributors
79
+
80
+ These fine folks have contributed patches and new features to this project:
81
+
82
+ * "Adam Anderson"[http://github.com/scudco]
83
+ * "Bryan Liles"[http://github.com/bryanl]
84
+
85
+ Thanks guys!
86
+
87
+
78
88
  == Copyright
79
89
 
80
90
  Copyright (c) 2010 Joshua Krall. See LICENSE for details.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  gem.description = %Q{Gem for managing multiple analytics services in your rails app.}
10
10
  gem.email = "josh@transfs.com"
11
11
  gem.homepage = "http://github.com/jkrall/analytical"
12
- gem.authors = ["Joshua Krall", "Nathan Phelps"]
12
+ gem.authors = ["Joshua Krall", "Nathan Phelps", "Adam Anderson"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  gem.add_dependency "activesupport"
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.7.0
data/analytical.gemspec CHANGED
@@ -5,10 +5,10 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{analytical}
8
- s.version = "1.6.0"
8
+ s.version = "1.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Joshua Krall", "Nathan Phelps"]
11
+ s.authors = ["Joshua Krall", "Nathan Phelps", "Adam Anderson"]
12
12
  s.date = %q{2010-09-10}
13
13
  s.description = %q{Gem for managing multiple analytics services in your rails app.}
14
14
  s.email = %q{josh@transfs.com}
@@ -106,7 +106,7 @@ Gem::Specification.new do |s|
106
106
  s.homepage = %q{http://github.com/jkrall/analytical}
107
107
  s.rdoc_options = ["--charset=UTF-8"]
108
108
  s.require_paths = ["lib"]
109
- s.rubygems_version = %q{1.3.7}
109
+ s.rubygems_version = %q{1.3.6}
110
110
  s.summary = %q{Gem for managing multiple analytics services in your rails app.}
111
111
  s.test_files = [
112
112
  "spec/analytical/api_spec.rb",
@@ -126,7 +126,7 @@ Gem::Specification.new do |s|
126
126
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
127
127
  s.specification_version = 3
128
128
 
129
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
129
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
130
130
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
131
131
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
132
132
  else
@@ -12,25 +12,31 @@ module Analytical
12
12
  @commands = []
13
13
  end
14
14
 
15
+ #
16
+ # The core methods that most analytics services implement are listed below.
17
+ # Modules will ignore any calls that they don't respond to, allowing them to
18
+ # only partially implement this basic template (or implement their own arbitrary custom methods)
19
+ #
20
+
15
21
  # This is used to record page-view events, where you want to pass a URL to an analytics service
16
- def track(*args); ''; end
22
+ # def track(*args)
17
23
 
18
24
  # Identify provides a unique identifier to an analytics service to keep track of the current user
19
25
  # id should be a unique string (depending on which service you use), and some services also
20
26
  # make use of a data hash as a second parameters, containing :email=>'test@test.com', for instance
21
- def identify(id, *args); ''; end
27
+ # def identify(id, *args)
22
28
 
23
29
  # Event is meant to track important funnel conversions in your app, or other important events
24
30
  # that you want to inform a funnel analytics service about. You can pass optional data to this method as well.
25
- def event(name, *args); ''; end
31
+ # def event(name, *args)
26
32
 
27
33
  # Set passes some data to the analytics service that should be attached to the current user identity
28
34
  # It can be used to set AB-testing choices and other unique data, so that split testing results can be
29
35
  # reported by an analytics service
30
- def set(data); ''; end
36
+ # def set(data)
31
37
 
32
38
  # This method generates the initialization javascript that an analytics service uses to track your site
33
- def init_javascript(location); ''; end
39
+ # def init_javascript(location)
34
40
 
35
41
  def queue(*args)
36
42
  if args.first==:identify
@@ -40,7 +46,9 @@ module Analytical
40
46
  end
41
47
  end
42
48
  def process_queued_commands
43
- command_strings = @commands.collect {|c| send(*c) }
49
+ command_strings = @commands.collect do |c|
50
+ send(*c) if respond_to?(c.first)
51
+ end.compact
44
52
  @commands = []
45
53
  command_strings
46
54
  end
@@ -68,4 +76,4 @@ module Analytical
68
76
 
69
77
  end
70
78
  end
71
- end
79
+ end
@@ -51,6 +51,12 @@ module Analytical
51
51
  HERE
52
52
  end
53
53
 
54
+ def alias_identity(old_identity,new_identity)
55
+ check_for_console <<-HERE
56
+ console.log("Analytical Alias: #{old_identity} => #{new_identity}");
57
+ HERE
58
+ end
59
+
54
60
  private
55
61
 
56
62
  CONSOLE_JS_ESCAPE_MAP = {
@@ -61,7 +67,7 @@ module Analytical
61
67
  "\r" => '\n',
62
68
  '"' => '\\"',
63
69
  "'" => "\\'"
64
- }
70
+ } unless defined?(CONSOLE_JS_ESCAPE_MAP)
65
71
 
66
72
  def escape(js)
67
73
  js.to_s.gsub(/(\\|<\/|\r\n|[\n\r"'])/) { CONSOLE_JS_ESCAPE_MAP[$1] }
@@ -45,6 +45,10 @@ module Analytical
45
45
  "_kmq.push([\"set\", #{data.to_json}]);"
46
46
  end
47
47
 
48
+ def alias_identity(old_identity, new_identity)
49
+ "_kmq.push([\"alias\", \"#{old_identity}\", \"#{new_identity}\"]);"
50
+ end
51
+
48
52
  end
49
53
  end
50
- end
54
+ end
@@ -1,11 +1,11 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Analytical::Base::Api do
4
-
4
+
5
5
  class BaseApiDummy
6
6
  include Analytical::Base::Api
7
7
  end
8
-
8
+
9
9
  describe '#queue' do
10
10
  before(:each) do
11
11
  @api = BaseApiDummy.new(:parent=>mock('parent'))
@@ -30,7 +30,7 @@ describe Analytical::Base::Api do
30
30
  @api = BaseApiDummy.new(:parent=>mock('parent'))
31
31
  @api.commands = [[:a, 1, 2, 3], [:b, {:some=>:args}]]
32
32
  @api.stub!(:a).and_return('a')
33
- @api.stub!(:b).and_return('b')
33
+ @api.stub!(:b).and_return('b')
34
34
  end
35
35
  it 'should send each of the args arrays in the command list' do
36
36
  @api.should_receive(:a).with(1, 2, 3).and_return('a')
@@ -44,6 +44,10 @@ describe Analytical::Base::Api do
44
44
  @api.process_queued_commands
45
45
  @api.commands == []
46
46
  end
47
+ it "should not store an unrecognized command" do
48
+ @api.commands << [:c, 1]
49
+ @api.process_queued_commands.should == ['a','b']
50
+ end
47
51
  end
48
52
 
49
53
  describe '#init_location?' do
@@ -72,7 +76,7 @@ describe Analytical::Base::Api do
72
76
  @api.init_location(:some_location)
73
77
  end
74
78
  describe 'for a valid init location' do
75
- before(:each) { @api.stub!(:init_location?).and_return(true) }
79
+ before(:each) { @api.stub!(:init_location?).and_return(true) }
76
80
  it 'should set initialized to true' do
77
81
  @api.init_location(:some_location)
78
82
  @api.initialized.should be_true
@@ -92,5 +96,5 @@ describe Analytical::Base::Api do
92
96
  end
93
97
  end
94
98
  end
95
-
99
+
96
100
  end
@@ -14,18 +14,6 @@ describe "Analytical::Chartbeat::Api" do
14
14
  a.options.should == {:key=>12345, :domain => 'abcdef.com', :parent=>@parent}
15
15
  end
16
16
  end
17
- describe '#track' do
18
- it 'should return the tracking javascript' do
19
- @api = Analytical::Chartbeat::Api.new :parent=>@parent, :key=>12345
20
- @api.track.should == ''
21
- end
22
- end
23
- describe '#identify' do
24
- it 'should return an empty string' do
25
- @api = Analytical::Chartbeat::Api.new :parent=>@parent, :key=>12345
26
- @api.identify('nothing', {:matters=>'at all'}).should == ''
27
- end
28
- end
29
17
  describe '#init_javascript' do
30
18
  it 'should return the init javascript' do
31
19
  @api = Analytical::Chartbeat::Api.new :parent=>@parent, :key=>12345, :domain =>'abcdef.com'
@@ -14,20 +14,6 @@ describe "Analytical::Comscore::Api" do
14
14
  a.options.should == {:key=>1234, :parent=>@parent}
15
15
  end
16
16
  end
17
- describe '#track' do
18
- it 'should return the tracking javascript' do
19
- @api = Analytical::Comscore::Api.new :parent=>@parent, :key=>123
20
- @api.track('pagename', {:some=>'data'}).should == ''
21
- end
22
- end
23
-
24
- describe '#identify' do
25
- it 'should return an empty string' do
26
- @api = Analytical::Comscore::Api.new :parent=>@parent, :key=>123
27
- @api.identify('nothing', {:matters=>'at all'}).should == ''
28
- end
29
- end
30
-
31
17
  describe '#init_javascript' do
32
18
  it 'should return the init javascript' do
33
19
  @api = Analytical::Comscore::Api.new :parent=>@parent, :key=>1234
@@ -21,12 +21,6 @@ describe "Analytical::Google::Api" do
21
21
  @api.track('pagename', {:some=>'data'}).should == "_gaq.push(['_trackPageview', \"pagename\"]);"
22
22
  end
23
23
  end
24
- describe '#identify' do
25
- it 'should return an empty string' do
26
- @api = Analytical::Google::Api.new :parent=>@parent, :key=>'abcdef'
27
- @api.identify('nothing', {:matters=>'at all'}).should == ''
28
- end
29
- end
30
24
  describe '#init_javascript' do
31
25
  it 'should return the init javascript' do
32
26
  @api = Analytical::Google::Api.new :parent=>@parent, :key=>'abcdef'
@@ -14,12 +14,6 @@ describe "Analytical::KissMetrics::Api" do
14
14
  a.options.should == {:js_url_key=>'abc', :parent=>@parent}
15
15
  end
16
16
  end
17
- describe '#track' do
18
- it 'should return the tracking javascript' do
19
- @api = Analytical::KissMetrics::Api.new :parent=>@parent, :js_url_key=>'abcdef'
20
- @api.track('pagename', {:some=>'data'}).should == ''
21
- end
22
- end
23
17
  describe '#identify' do
24
18
  it 'should return a js string' do
25
19
  @api = Analytical::KissMetrics::Api.new :parent=>@parent, :js_url_key=>'abcdef'
@@ -38,13 +32,19 @@ describe "Analytical::KissMetrics::Api" do
38
32
  @api.set({:something=>'good', :b=>2}).should == "_kmq.push([\"set\", #{{:something=>'good', :b=>2}.to_json}]);"
39
33
  end
40
34
  end
35
+ describe '#alias_identity' do
36
+ it 'should return a js string' do
37
+ @api = Analytical::KissMetrics::Api.new :parent=>@parent, :js_url_key=>'abcdef'
38
+ @api.alias_identity('foo', 'bar').should == "_kmq.push([\"alias\", \"foo\", \"bar\"]);"
39
+ end
40
+ end
41
41
  describe '#init_javascript' do
42
42
  it 'should return the init javascript' do
43
43
  @api = Analytical::KissMetrics::Api.new :parent=>@parent, :js_url_key=>'abcdef'
44
44
  @api.init_javascript(:head_prepend).should == ''
45
45
  @api.init_javascript(:head_append).should == ''
46
46
  @api.init_javascript(:body_prepend).should =~ /i\.kissmetrics\.com/
47
- @api.init_javascript(:body_prepend).should =~ /abcdef/
47
+ @api.init_javascript(:body_prepend).should =~ /abcdef/
48
48
  @api.init_javascript(:body_append).should == ''
49
49
  end
50
50
  end
@@ -14,20 +14,6 @@ describe "Analytical::Optimizely::Api" do
14
14
  a.options.should == {:key=>'abc', :parent=>@parent}
15
15
  end
16
16
  end
17
- describe '#track' do
18
- it 'should return the tracking javascript' do
19
- @api = Analytical::Optimizely::Api.new :parent=>@parent, :key=>'abcdef'
20
- @api.track('pagename', {:some=>'data'}).should == ''
21
- end
22
- end
23
-
24
- describe '#identify' do
25
- it 'should return an empty string' do
26
- @api = Analytical::Optimizely::Api.new :parent=>@parent, :key=>'abcdef'
27
- @api.identify('nothing', {:matters=>'at all'}).should == ''
28
- end
29
- end
30
-
31
17
  describe '#init_javascript' do
32
18
  it 'should return the init javascript' do
33
19
  @api = Analytical::Optimizely::Api.new :parent=>@parent, :key=>'abcdef'
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytical
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
- - 6
7
+ - 7
9
8
  - 0
10
- version: 1.6.0
9
+ version: 1.7.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Joshua Krall
14
13
  - Nathan Phelps
14
+ - Adam Anderson
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
@@ -23,11 +23,9 @@ dependencies:
23
23
  name: rspec
24
24
  prerelease: false
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
26
  requirements:
28
27
  - - ">="
29
28
  - !ruby/object:Gem::Version
30
- hash: 13
31
29
  segments:
32
30
  - 1
33
31
  - 2
@@ -39,11 +37,9 @@ dependencies:
39
37
  name: activesupport
40
38
  prerelease: false
41
39
  requirement: &id002 !ruby/object:Gem::Requirement
42
- none: false
43
40
  requirements:
44
41
  - - ">="
45
42
  - !ruby/object:Gem::Version
46
- hash: 3
47
43
  segments:
48
44
  - 0
49
45
  version: "0"
@@ -154,27 +150,23 @@ rdoc_options:
154
150
  require_paths:
155
151
  - lib
156
152
  required_ruby_version: !ruby/object:Gem::Requirement
157
- none: false
158
153
  requirements:
159
154
  - - ">="
160
155
  - !ruby/object:Gem::Version
161
- hash: 3
162
156
  segments:
163
157
  - 0
164
158
  version: "0"
165
159
  required_rubygems_version: !ruby/object:Gem::Requirement
166
- none: false
167
160
  requirements:
168
161
  - - ">="
169
162
  - !ruby/object:Gem::Version
170
- hash: 3
171
163
  segments:
172
164
  - 0
173
165
  version: "0"
174
166
  requirements: []
175
167
 
176
168
  rubyforge_project:
177
- rubygems_version: 1.3.7
169
+ rubygems_version: 1.3.6
178
170
  signing_key:
179
171
  specification_version: 3
180
172
  summary: Gem for managing multiple analytics services in your rails app.